ESP32 numitron clock

Following the rich learning experience of designing a switching power supply, I was ready to tackle a bigger project.

Clocks are everywhere. Why not make a nice one?

A clock combines many aspects of embedded design into one device: a display, accurate timekeeping, and as many useful inputs and peripherals as you can think of.

Before designing anything, it is important to establish concrete requirements early in the process. This will help avoid “feature-creep”; a term which haunts many career engineers.

For my first clock, I wanted:

  • WiFi and Bluetooth capability
  • Programmable in Arudino framework (C++), since this is most familiar to me
  • 6 digit display: hours, minutes, seconds
  • Single board design, 2 layer PCB
  • USB connection for developing and flashing firmware
  • Rotary encoder for manual time/date setting
  • Light sensor for automatically dimming tubes based on ambient light
  • PIR motion sensor to turn display on/off

While my first though was to use nixies, a friend picked up several DR2000 “numitron” tubes at a hamfest and offered them to me. I decided this was the perfect display device for my first design. Numitrons are incandescent displays; they run at 5 volts which is safe and does not require the additional complexity of high voltage generation.

Without further adieu, I drew up a schematic for my clock.

schematic_rev1

Major components include:

  • ESP32-WROOM-32 (128 MB) module as the main controller. The ESP32 features WiFi and Bluetooth capability, generous amounts of memory, and two cores in addition to extensive documentation and programming references.
  • 3 x CAT4016 16-bit constant current LED drivers, 1 per set of 2 tubes (7 segments per tube + 4 colon bulbs).
  • DS3232 extremely accurate I²C temperature compensated real time clock with integrated crystal and SRAM. ±2 ppm accuracy from 0°C to +40°C.
  • CP2102 USB to UART for serial communication and programming

Now that we have the right components for the job, it is time to design the board:

board_front

Looking good so far! Now it was time to get the tubes and sockets cleaned up while the all the hardware was on order.

Yikes! These things sure were crusty. After getting the sockets desoldered, everything took an overnight bath in some POR-15 rust remover.

Much better. A few days later, and my PCBs and parts have all arrived. Time to assemble!

Now the long and tedious process of programming the clock begins. As per a friend’s recommendation, I downloaded the PlatformIO plugin in Visual Studio and got to programming the ESP32 in the Arduino framework. Thanks to the extensive amount of resources online, lots of the low level programming is taken care of in readily available libraries. You can see the ones I’m using so far:

pio_screenshot

I have already gotten the clock to display time, date, and temperature from the DS3232 in a specific routine. Additionally, the little Panasonic PIR sensor does well to turn the clock off when no one is present, and the light dimmer keeps tube brightness down in low ambient light conditions. The rotary encoder needs some more work; it was nearly impossible to debounce with regular push-button techniques and took many hours to get a robust increment/decrement reading. Building the UI in software for setting time and date will require a lot more effort!

20191128_223703.jpg

I’m very pleased with how quickly I was able to bring the ESP32 up and program it. Practice makes perfect and adding future functionality should become easier as I gain experience in the PIO environment. The ESP32 itself is also extremely impressive with the feature-set it offers at $4.50 per unit for the 128MB WROOM module.

Of course, some thermal images order to keep and eye on heat. The CAT4016 drivers are rated up to 150 milliamps of current on all channels. Since I’m driving 2 seven segment numitron tubes with one (1) CAT4016 at 20 milliamps per segment, this totals to about 140 milliamps worst case with all segments ON. However, with the light dimmer and PIR sensor reducing duty cycle, temperatures should be well below operating limits. The highest recorded temperature was 128°F (53°C) on the CAT4016s, which is acceptably below the 85°C operating limit specified in the datasheet.

I am already concocting a few nixie designs based off of a very similar architecture to the numitron clock. Be sure to follow if you’re interested!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s