Build the Talking ESP32 Clock for the Exact Local Time.

by debinix in Circuits > Clocks

946 Views, 3 Favorites, 0 Comments

Build the Talking ESP32 Clock for the Exact Local Time.

talkingclock-esp32-hackaday.png
The Talking Penguin

The Talking Penguin

The Penguin will regularly voice the actual time in your time zone and use its built-in Neopixels for a cozy Christmas feeling.

An old decoration provides the outer shell for this project. A non-functional Penguin that will be refurbished and enhanced with talking capabilities, plus some flashy multicolor LED lights. The Penguin fell to the floor and broke but glued to hold the outer shell together. Alternatively, any semi-transparent enclosure could host the same parts we will assemble, code, and test.

Find the necessary parts and tools in the next step. The project is, by purpose, made beginner-friendly with a minimum of required components, but some familiarity with Arduino is helpful, but not an absolute must.

Finally, it synchronizes its time over WiFi and the global Network Time Protocol (NTP), thus consistently accurate!

Are you an experienced Arduino/ESP32 maker?

You can update the code from its clock function to speak over 1200+ other words. Or why not record your messages and make a unique Christmas ornament? Learn more at the end of the instructable.

Let’s get started!

Supplies

The Penguin

If you don't have such a Penguin model, use any semi-transparent Christmas ornament to house your Neopixels, the microcontroller, and possible batteries. However, I use a USB adapter to power the Penguin.

Neopixels, in the form of RGB rings.

  • 12 pixels (5050) Neopixel ring - Adafruit

Unexpected Maker ESP32 microcontroller

Female 10-pins headers

  • Stackable long legs female headers - Amazon

Speaker

  • Miniature 0.5-1W speaker, 8 Ohm - Amazon

The speaker amplifier shield. It fits on top of ESP32 TinyPICO.

  • Arduino Talkie Speech Amplifier Shield for ESP32 - Tindie
  • Arduino Talkie Speech Amplifier Shield for ESP32 - Lectronz

Other

Tools

  • Soldering iron
  • Solder wire
  • Glue gun
  • Electrical wires
  • Side cutter

The Speaker and the Neopixel Ring Assembly

speaker-assembly-cables.jpg
ring-cables.jpg

Speaker

Solder two wires between the 8 Ohm/0.5W speaker and the amplifier board. Purchase the board with the terminal block soldered if there is more space to insert the completed final assembly. Then you only need to solder one end. However, the hole in the bottom of my Penguin is very narrow; thus, I can't use the terminal variant.

The amplifier board is a shield that plugs directly into the TinyPICO controller. Be careful in the final building to insert the shield correctly.

Neopixel ring

The 12-pixel ring has three terminals, VCC, GND, and Data/IN. Solder three wires to each of these.

Solder and Cut the Perfboard

four-combined.png

1. Solder the stacking header pins to the TinyPICO controller, i.e., the Penguin brain.

2. Insert the controller in the corner of the perfboard, such that the small antenna is far out from the board's copper.

3. Mark where to cut the board, which is about the length of the controller.

4. Use a sharp hobby knife to score the board several times. Then, break it off by hand.

Solder Neopixel Wires

two-in-one.png

1. Solder the four corner pins to the perfboard.

2. Bend down the '+5V' and the 'GND' in the opposite direction, as shown in the pictures. The Penguin code uses IO4 for data, which is the fifth pin. Which pin to use for 'Neopixel data' is customizable in the program.

3. Carefully cut all pins, except the three used pins, or solder all to the board and then cut unused pins.

4. Solder three wires to the pins matching the function on the Neopixel ring.

5. Use the glue gun (optionally) to add some strain relief to the wires.

Final Assembly

ring-sub-assembly.jpg
complete-assembly-new.jpg

We complete the hardware part of the project by adding the speaker assembly simply by inserting the shield on top of the controller.

Ensure speaker cables from the amplifier shield are above the USB connector on the TinyPICO controller.

Install Arduino IDE

To use the ESP32 board with the Arduino libraries, you'll have to use the Arduino Integrated Development Environment (IDE), with added ESP32 board support.

Visit Arduino's official site and download the current stable version (1.8.19 as of this writing and used for the instructable here) for Windows, macOS, and Linux. You can also use Arduino IDE 2.0.3 or later.

Add support for ESP32 boards.

Next is to add support for ESP32 boards with Arduino's Board Manager.

Under the top menu, select "File-> Preferences". Then, in the new window, click the small, far-right symbol on the line that says "Additional Boards Managers URLs.".

Select this, which opens up a list of URLs for other boards.

Next, visit Arduino's GitHub page for 3rd party board support URLs.

  • Scroll down the long list until you find Expressif's ESP32 support.

Please copy the link address, i.e., 'https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json' and add it to the end of the existing board's list in the small text box.

  • Press OK when done.

Board Manager

In the main menu, go to "Tools-> Board: *-> Board Manager", and in the search box, type ESP32 and click the Install button to install Expressifs support for many ESP32 models manufactured by various suppliers.

  • Close when done.

Open Boards Manager from the "Tools-> Board:-> ESP32 Arduino" menu and select the correct ESP32 board.

  • Choose "UM TinyPICO" from the list.

Install Libraries

libraries.png

Library Manager

The project requires a few Arduino libraries. The easiest way is to use Arduino Library Manager to install them.

Select "Tools--> Manage Libraries" in the Arduino menu and search for the required libraries.

  • 'Talkie' by Armin Joachimsmeyer.
  • 'AsyncElegantOTA' by Ayush Sharma.
  • 'ESP32Time' by Felix Biego.
  • 'Adafruit_NeoPixel' by Adafruit.

The final library 'ESPAsyncWebServer' by 'me-no-dev' can not be installed with the Library Manager. Instead, visit his GitHub repository and download the library zip archive with the green Code button to a temporary folder on the computer.

Go to "Sketch-> Include Library-> Add .ZIP Library..." in the Arduino IDE and the main menu. Select the downloaded zip file, and Arduino IDE will handle the installation automatically.

After finishing the installation, let us continue with the main project code.

The Talking Penguin code

Download my latest released zip archive from GitHub to your sketchbook folder, and extract the source code there. You find the sketchbook location if you look in the Arduino menu, select "File-> Preferences" and "Sketchbook location."

After extracting the project archive, you have a folder named 'TheTalkingPenguin-1.0.0'.

In the examples folder, you will find the Arduino sketch 'talkingpenguin.ino' ready for upload to the ESP32 module, which we will do next.

Configuration and Test

main-code.png

The main sketch is split into multiple files based on their function. This way, it's easy to maintain the code without having one huge, very long, hard-to-read single file.

WiFi configuration

Now open the downloaded code folder in Arduino IDE and click on the 'talkingpenguin.ino' file. There are a few quick and straightforward configurations that need to be updated.

Open the file 'secret.h' and set your WiFi network name (SSID) and your password like this:

#define MY_SSID "penguin"
#define MY_PWD "happyfeet"
  • Save the 'secret.h' file when done.

Penguin configuration

Open the file 'config.h' and set or confirm the following:

  • Next, set the Neopixel data pin (4), the number of pixels (12), and the LEDs brightness level (25).
#define LED_PIN 4         // ESP32 TinyPICO GPIO 4
#define LED_COUNT 12 // 12 LEDs Neopixel pixel ring
#define LED_BRIGHTNESS 25 // Adjust LED brightness (max = 255)

Note that an excessively high brightness puts high stress and is potentially fatal for the TinyPICO.

  • Set time zone and time offset (in seconds) to GMT:
#define NTP_POOL "us.pool.ntp.org" 
#define SEC_GMT_OFFSET 68400 // New York, EST (GMT-5, i.e., GMT+19)
// #define SEC_GMT_OFFSET 64800 // Dallas, CST (GMT-6, i.e., GMT+18)
// #define SEC_GMT_OFFSET 57600 // San Francisco, PST (GMT-8, i.e., GMT+16)
  • Penguin talking period (uncomment only one)

Decide how often the Penguin will speak, measured in milliseconds.

// #define MS_UPDATE_TM 3600000 // 1 hour
// #define MS_UPDATE_TM 1800000 // 30 minutes
// #define MS_UPDATE_TM 900000 // 15 minutes
// #define MS_UPDATE_TM 60000 // 1 minutes
#define MS_UPDATE_TM 10000 // 10 seconds, for test
  • Clock setting
#define CLOCK_12HOUR   // Comment out for the 24-hour clock
  • Save the 'config.h' file when done.

Neopixel color LEDs pattern

Different color effects can be included or excluded in the loop()-function in 'talkingpenguin.ino'. A few patterns are already enabled.

Upload code

Now you are ready to upload the code, connect the ESP32 TinyPICO USB cable and hit the upload arrow button.

The Penguin should voice the actual time frequently, i.e., with the set 'MS_UPDATE_TM' value, after acquiring the first-time data from the NTP server. In addition, the Neopixel ring should flash its LEDs.

Enclosure Installation

penguin-bottom-cable.jpg
talking-penguin.png

Install the completed assembly in the Penguin body. Keeping all the wires and parts together may require some extra support. But, again, this depends on your semi-transparent Christmas ornament.

I pushed the completed build through the narrow bottom slot 20x70mm (0.79"x2.76"). Thanks to the low height of the combination of TinyPICO and the amplifier shield of only 18 mm (0.71"), this was easy. The only cable that comes from the bottom is the USB power cable.

The project is complete when you connect to power via the USB cable. Then, of course, you can add more Neopixels, but then connect 5V direct to the rings VCC.


Remote Updates

wifi-ota-update.png

OTA WiFi updates

In this step, we will look into a smart way to change the function by updating the code via WiFi. In this way, we don't need to touch or try to extract the assembly from the Penguin but can do this remotely from the computer.

As an example update, compile a new version with the Arduino IDE menu "Sketch-> Export compiled Binary".

The new binary file is named 'talkingpenguin.ino.um_tinypico.bin'.

OTA server

A webserver is running on port 80 on the TinyPICO. Thus we can connect to it with a web browser.

Use your phone with an app, like 'Network Scanner' from Google Play. Scan your local WiFi network to find the server IP address for the WiFi device that has 'penguin' in its name or address.

For example, type 'http://192.168.1.236' in the browser, but do not use 'https.//'.

Click the update link and browse for the above bin file.

The server landing page updates the Penguin code with ElegantOTA.

Wait, We Want More

shell-talkie.png

Yes, at the beginning of the project, I promised more than a talking clock.

If you are an advanced Arduino user, you may want to enhance and modify the penguin code to suit your ideas.

The Talkie library

The library has more than 1200+ words pre-defined, and the sketch only uses the clock phrases in the 'talkie_helper.h' file. So first, install the Talkie library (if not already done above). Then, explore all available words with the shell script '/script/talkie-vocab.sh', which you will find on my GitHub.

  • Finally, run the script in a terminal window.

Let the Penguin use your voice to talk.

Audacity audio software is well-known for editing audio projects. It Works for Windows, Linux, and macOS.

The sketch 'talkingpenguin.ino' is easy enough to understand to allow for your experiments. Enjoy!

Conclusions

Your feedback and thoughts

Please, feel free to provide your experience with this project or if you want to give some constructive comments, good or bad.

The Talking Penguin repository

Find all source code at my GitHub repository for this project.

Check back for updates and potential issues.

Credits

Several excellent Arduino ESP32 libraries made this project possible.

Talkie by Armin Joachimsmeyer, AsyncElegantOTA by Ayush Sharma, ESPAsyncWebServer by 'me-no-dev', ESP32Time by Felix Biego, and Adafruit_NeoPixel by Adafruit.

And finally, the helpful OTA server landing page by Ralph S Bacon.