There is a nice and simple seven segment display controlled by a TM1637 controller, which can be used e.g. as a clock display. It provides 4 digits and a colon dividing digits 1 and 2 from digits 3 and 4, such that the first two digits can be used to display hours, the last two digits to display minutes and the colon can be set blinking at a 1 Hz rate. Of course you can also use it for other purposes like displaying the voltage values of a voltmeter.
![]() |
![]() |
As can be seen from the back view of the module, interfacing to the ESP32 is pretty simple. Here are the connections I use:
Pins on display module | Pins on ESP32 |
---|---|
CLK | D1: GPIO 22 |
DIO | D2: GPIO 21 |
VCC | 3.3V |
GND | GND |
The TM1637 uses a proprietary 2-wire serial protocol with a data line (dio) and a clock line.
Carefully read the data sheet.
Write a driver implementing the serial protocol. Implement the driver as class TM1637 with the following methods:
A --- F | | B dp,g,f,e, d,c,b,a: the data byte -G- E | | C --- D
Read the current time from the ntp and implement a clock displaying hours and minutes. Make the colon blink at a 1 Hz rate.
The keypad has a total of 16 switches. These are connected to 8 pins organized as 4 rows and 4 columns.
![]() |
![]() |
Set the first row pin to low and check on each column pin if you read a zero. If you do, you have found the switch closed. If not, continue the same procedure on the other row pins.
I made the connections as follows:
Row 1 | D7: GPIO 23 |
Row 2 | D6: GPIO 19 |
Row 3 | D5: GPIO 18 |
Row 4 | D0: GPIO 26 |
Col 1 | D4: GPIO 16 on WROVER: GPIO 25 with patch to D4 on CPU board |
Col 2 | D3: GPIO 17 on WROVER: GPIO 4 with patch to D3 on CPU board |
Col 3 | D2: GPIO 21 |
Col 4 | D1: GPIO 22 |
Scan the keyboard in intervals of 100 ms and print the key that is pressed. This will result in printing the key as long as it is pressed.
Wait until the key is released and only then print the key. This will result in a single key value for each button press.
Write a CircularBuffer class in which you can keep key presses. This will allow to read the keypad completely asynchronously (see exercise 4).
The CircularBuffer class should implement a buffer of 32 elements with the following methods:
Read the keypad in an interrupt driven routine. Keep the pressed keys in the circular buffer written in exercise 3.
Write a test program that starts the interrupt driven keypad driver and reads data from the circular buffer in rather large intervals (e.g. every 5s or 10s)
I | Attachment | History![]() |
Action | Size | Date | Who | Comment |
---|---|---|---|---|---|---|---|
![]() |
4X4-Keypad-Schematic.png | r1 | manage | 14.6 K | 2021-01-20 - 21:58 | UliRaich | |
![]() |
keypad.png | r1 | manage | 115.6 K | 2021-01-20 - 21:41 | UliRaich | |
![]() |
seven_seg_back.png | r1 | manage | 117.4 K | 2021-01-20 - 21:40 | UliRaich | |
![]() |
seven_seg_front.png | r1 | manage | 115.2 K | 2021-01-20 - 21:40 | UliRaich |