HackerBox 0085: Kronos
Welcome to HackerBox 0085 where we will discover the S3 variant of the ESP32 system-on-chip and configure the Arduino IDE for use with the T-Display-S3 module. Integrate the ESP32-S3 with a 98357A Class-D audio amplifier, a resonant cavity speaker, two arcade-style buttons, and sixteen RGB LEDs. Assemble a five panel PCB enclosure into a hackable clock appliance. Explore the Network Time Protocol (ntp) for time synchronization.
HackerBox is the original monthly subscription box for electronics, computer technology, and hacker culture. Each HackerBox is a discovery box, which means all members await and enjoy a new surprise each month. Tech, toys, knowledge, and fun. It's like having a hacker convention, your birthday, and the first day of school - every month - right in your mailbox.
There is a wealth of information for current and prospective members in the HackerBoxes FAQ. Almost all of the non-technical support emails that we receive are already answered there, so we'd really appreciate it if you can take a few minutes to read the FAQ.
Supplies
This Instructable contains information for getting started with HackerBox 0085. The full box contents are listed on the product page for HackerBox 0085 where the box is also available for purchase while supplies last. If you would like to automatically receive a HackerBox like this right in your mailbox each month, you can subscribe at HackerBoxes.com and join the party! Subscribers save at least $15 every month and get each new HackerBox shipped immediately off of the production line.
A soldering iron, solder, and basic assembly tools are generally needed to work on the monthly HackerBox. A computer for running software tools is also required. Have a look at the HackerBox Workshops for basic tools and a wide array of introductory activities and experiments.
The most import thing you will need is a sense of adventure, hacker spirit, patience, and curiosity. Building and experimenting with electronics, while very rewarding, can be tricky, challenging, and even frustrating at times. The goal is progress, not perfection. When you persist and enjoy the adventure, a great deal of satisfaction can be derived from this hobby. Take each step slowly, mind the details, and don't be afraid to ask for help.
WEAR SAFETY GLASSES WHEN SOLDERING, WHEN TRIMMING WIRE LEADS, OR WHEN CUTTING, DRILLING, ETC.
ESP32-S3
The Espressif ESP32-S3 is a dual-core XTensa LX7 MCU, capable of running at 240MHz. Apart from its 512 KB of internal SRAM, it also comes with integrated 2.4 GHz, 802.11 b/g/n Wi-Fi and Bluetooth 5 (LE) connectivity that provides long-range support. It has 45 programmable GPIOs and supports a rich set of peripherals. ESP32-S3 supports larger, high-speed octal SPI flash, and PSRAM with configurable data and instruction cache.
T-Display ESP32-S3R8 Module
The T-Display-S3 Module
- ESP32-S3R8 Dual-core LX7 Microprocessor
- Wireless Connectivity: Wi-Fi 802.11, Bluetooth BLE 5.0, and Bluetooth Mesh
- Flash: 16MB
- PSRAM: 8MB
- Three Buttons: Boot, Reset, and IO14
- Display: 1.9 inch IPS TFT LCD 170 x 320 Resolution
- Display Chip: ST7789 (datasheet)
Test and Configure Before Soldering
It is always wise to test out a new module and configure the development tools prior to soldering anything.
Factory Power Up
Apply power to the module using a USB-C cable. The factory loaded program will display a LILYGO Animated Graphic and then scan for, and display, available Wi-Fi networks.
Configure the Arduino Integrated Development Environment (IDE)
Volos made a nice video showing these steps...
Install the Arduino IDE.
Open the Arduino IDE and go to File>Preferences.
Paste the following link into the “Additional Board Manager URLs” field:
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
Use Tools > Board Manager to get esp32 for ide (at least version 2.03).
Set Tools > Board to ESP32S3 Dev Module.
Set Tools > Flash Size to 16MB.
Set Tools > Partition Scheme to Huge App.
The library we'll use includes its own modified TFT_eSPI library, so remove (or move) any existing TFT_eSPI library you may have.
Grab the github repo for the T-Display-S3 module.
Copy the contents of the lib folder to C:\Users\YourName\Documents\Arduino\libraries
Open the sketch examples > tft > tft.ino downloaded from github.
Compile and upload tft.ino to see a demonstration that displays graphics and text on the T-Display Module.
Additional Examples
Volos has a number of interesting T-Display examples that can be found in his github and YouTube publications (e.g. this one is quick and fun).
Five Panel PCB Enclosure
The five PCB panels can be soldered together at their edges to form a rectangular enclosure. Openings designed into the enclosure panels support adding two arcade buttons, two circular LED modules (16 LEDs total), and an amplified speaker to the T-Display-S3 Module.
The inside surfaces of the panels have metal "traces" for assemble as well as black solder mask. There is no metal or solder mask on the outside surfaces. The outside is plain (brownish) PCB substrate. If you'd like a custom color or pattern, the five panels can be spray painted prior to assembly. Leaving the panels black-side-down while painting will help to keep paint off of the metal traces on the black side.
Assemble Top Panel
Start by inserting the speaker cavity from green/brown side of the PCB. Attach the speaker cavity with the four machine screws and nuts. It may be necessary to carefully clear some excess wire sealant to fit the speaker into its opening. Finally, snap in the two arcade buttons - also from the green/brown side of the PCB.
Assemble Front Panel
T-Display-S3 Module
Header pins are included in the plastic T-Display box. Solder one pin in each of the four corners of the module. As shown in the blue circles, the four pins can be bent down to meet the metal traces on the back (black) side of the front PCB. Adjusting the four pins prior to soldering them to the PCB can set the position and level of the T-Display module.
Note that the four corner pins of the T-Display are the power rails (GND, 3V3, and 5V), so once the four corner pins are soldered down to the long rectangular traces on the PCB, the traces can be used for connecting the power and ground pins of other components as needed.
The additional header pins in the image were an experiment for wiring up the peripheral components to be attached later. Using header pins and Dupont jumpers is certainly an option, but it turned out to be easier, and more robust, to just solder the wires directly to the module.
To leave clearance for inserting a USB-C connector, the T-Display should be mounted just behind it's rectangular opening. An easy trick is to place a sheet of paper between the back (black) side of the PCB and the front surface of the module while adjusting and soldering the four corner pins into the desired positions.
Two RGB 8-LED Circle Modules
Position each module on the outside of the PCB with the LEDs facing outward and the solder pads showing through the rectangular holes in the front PCB. Four header pins can be used to anchor each LED module to the inside of the PCB as shown in the orange circles.
Wiring the RGB LED Modules
There is quite a lot of excess wire on the speaker, so we simply opted to use it for wiring the other components inside the enclosure.
Each LED module has four terminals: Data In, 5V, GND, and Data Out.
Start wiring from the IO2 pin of the T-Display. Wire this to the Data In (DI) terminal on one LED module. In the image, the LED module to the left was used. Wire the Data Out (DO) terminal of that same LED module to the Data In (DI) terminal of the other module. Wire each LED module's 5V and GND to the corresponding long rectangular "power rail" traces.
Test LEDs from Arduino IDE
Use Tools > Manage Libraries to search for and install the FastLED library by Daniel Garcia.
Open sketch: File > Examples > FastLED > DemoReel100
Change DATA_PIN to 2, LED_TYPE to WS2812B, and NUM_LEDS to 16.
Compile and upload the sketch to the T-Display-S3.
Continue Assembly
98357A Class D Audio Amplifier
There are seven metal pads on the back of the front PCB that can be used to anchor the amplifier module. The pads are not connected to anything. They are just mechanical anchors. While all seven pads can be used on the header side of the module, it is solid enough to simply anchor the two speaker pins on the other end of the amplifier module, as shown. Two header pins bent to right angles can used for anchoring the module to the pads.
Wire up the terminals of the Amplifier like so:
LRC IO17
BLCK IO18
DIN IO16
GAIN GND
SD NC
GND GND
Vin 3V3
While the some of the connections in the image use header pins and Dupont jumpers, it turned out to be easier and more robust to just solder wires directly to the modules.
Arcade Buttons
Start with the button under the PCB marking "TOP INSIDE". Wire one pin to GND and the other pin to IO21.
For the other button, wire one pin to GND and the other pin to IO13.
Join Three Enclosure Panels
Bring the top panel and front panel together at a 90 degree angle. Painter's tape is useful for temporarily holding the correct position. One of the small side panels can be used for establishing the exact angle. Once the three panels are aligned, they can be soldered into place from the inside of the enclosure.
Example Code
Grab the example sketch HB0085_Clock.ino attached here.
Edit the SSID and password to match your 2.4GHz Wi-Fi network.
If you are not in Eastern Time Zone, edit the time zone offset.
Be sure to have the FastLED library as used in the LED test above.
And also the ESP32 Audio I2S Library.
Compile and upload the sketch.
The two buttons will start and stop the audio stream with a simple LED light show.
Downloads
Complete the Enclosure
Solder the back panel and the second side panel into position from inside the enclosure. Again, painter's tape can help.
Some programming ideas:
- generate an alarm using I2S audio
- use the buttons to set an alarm time
- display the date
- display the weather
- interface with home automation - turn lights on
- Wi-Fi network scanner
- games
Network Time Protocol
The Network Time Protocol (NTP) is a networking protocol for clock synchronization between computer systems over packet-switched, variable-latency data networks. In operation since before 1985, NTP is one of the oldest Internet protocols in current use. NTP was designed by David L. Mills of the University of Delaware.
NTP is intended to synchronize all participating computers to within a few milliseconds of Coordinated Universal Time (UTC). It uses the intersection algorithm, a modified version of Marzullo's algorithm, to select accurate time servers and is designed to mitigate the effects of variable network latency. NTP can usually maintain time to within tens of milliseconds over the public Internet, and can achieve better than one millisecond accuracy in local area networks under ideal conditions. Asymmetric routes and network congestion can cause errors of 100 ms or more.
The protocol is usually described in terms of a client–server model, but can as easily be used in peer-to-peer relationships where both peers consider the other to be a potential time source. Implementations send and receive timestamps using the User Datagram Protocol (UDP) on port number 123. They can also use broadcasting or multicasting, where clients passively listen to time updates after an initial round-trip calibrating exchange. NTP supplies a warning of any impending leap second adjustment, but no information about local time zones or daylight saving time is transmitted. (Wikipedia)
Kronos Quartet
No relation really, but beautiful nonetheless - The American string quartet based in San Francisco has been in existence with a rotating membership of musicians for almost 50 years. The quartet covers a very broad range of musical genres, including contemporary classical music. (Wikipedia)
Hack the Planet
We hope you are enjoying this month's HackerBox adventure into electronics, computer technology, and hacker culture. Reach out and share your success in the comments below or other social media. Also, remember that you can email support@hackerboxes.com anytime if you have a question or need some help.
What's Next? Join the party and live the HackLife. Get a cool box of hackable gear delivered right to your mailbox each month and enjoy a generous member discount. Surf over to HackerBoxes.com right now to sign up for your monthly HackerBox subscription.
Please consider sharing this free Instructable with others who may be interested in learning about these subjects. We really appreciate your support!