Arduino: Text-to-Speech talking clock


Today’s project is an Arduino talking clock. Whenever one moves its hand in front of the proximity sensor, the clock will talk the current time. As for the hardware, I will use one Arduino Mega with a MikroElektronika Arduino Mega click shield, and three click boards: Proximity, RTC2, and Text-To-Speech click. All three click boards were configured for 5V operation by placing the PWR_SEL jumper in the 5V position.

I chose Arduino Mega for several reasons: first is that I needed three mikroBUS sockets for the click boards, and the MEGA Click shield was a perfect choice. Second, the S1V30120 IC onboard the Text-to_Speech click needs a large chunk of data to be uploaded in the initialization phase. The Mega has 256kb or FLASH memory, so plenty of space to store that data.

Another reason for choosing the Arduino Mega is that both RTC2 and Proximity click boards use I2C communication. The VCNL4010 onboard the Proximity click is not fussy regarding I2C communication. As the data sheet specifies, “The stop condition between these write and read sequences is not mandatory. It works also with a repeated start condition”. On the other hand, the DS1307 serial real-time clock (RTC) is more strict regarding I2C communication, and it requires repeated start conditions to be sent over the I2C bus as part of its communication protocol.

Unfortunately, the I2C libraries for Arduino Due (and its cousin Flip & Click) are still flawed, and a repeated start condition cannot be issued on the SAM3X8E. Ironically, this problem is at least three years old. In that time there were a few updates of the Arduino IDE, including the major jump to 1.8.0 version just after the two Arduino teams came back together as one. Still, no one cares about fixing the I2C communication on the SAM boards.

So, three click boards, three problems to solve: getting the distance, setting and keeping the current time, and doing all the talking. Luckily, all three problems were already solved. Code libraries for VCNL4010 and DS1307 are already written, and I’ve covered the basics of S1V30120 text-to-speech in another blog post. Parsing the time into words is also solved, I’ve done it before in my PIC18F45K22 “word clock” with GLCD display.

As usual with MikroElektronika click boards, building the hardware is just like playing with Lego bricks. The Text-to-Speech click board is placed in the first socket of the Mega Click Shield, the Proximity click stays in the second socket, and the RTC2 click occupies the third mikroBUS socket. As both Proximity click and RTC2 click boards use I2C communication, their position can be swapped and the project will still work.

Arduino Mega talking clock with S1V30120, VCNL4010 and DS1307, implemented with Arduino Mega plus several MikroElektronika parts: Arduino Mega click shield, text to speech click, proximity click, RTC2 click

Arduino Mega talking clock with S1V30120, VCNL4010 and DS1307

As for the software, I used the libraries provided by Adafuit, as over the course of time I found their libraries are second to none. The link for the VCNL4010 library is You can get the code for DS1307 from

The Text-to-Speech click board uses SPI communication, plus three dedicated control lines. So, leave it in the first socket (or you will have to change the pin definitions yourself). The code is largely based on my previous tutorial.

1 2 3

Leave A Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.