supermooi

Deadline timer

LCD with wireless to show remaining time.



Created by: J. de Waal, 2022-12-09


This project describes the process of connecting a character liquid-crystal display to an esp-01. The display can show short messages, limited graphics or other information. It can display various kinds of information, for example project deadlines of public transport information.
By connecting the system to the internet, the network time protocol can be used to obtain the current time. The current time can be used to modify the message on the display, for example to show a countdown. The network connection can also be used to send new messages to display.

Hardware

An esp-01 module provides the brain of this project. This module has limited IO pins, but it can provide wireless network communication. Female headers connect the esp-01 to a piece of protoboard. Connections to other components are made using wires soldered to the protoboard with connector to the other end.

Voltage Regulator

The esp-01 needs to be powered with 3.3V, but can accepts an input voltage range from 3.0 to 3.6 V. The project is powered from 5V via a micro USB breakout board. The USB data signals are not connected. It was tried to use a small low dropout voltage regulator. Because the only suitable regulator available came as a surface mount package, it could not be directly soldered to the board. It was mounted by soldering wires to the regulator, and connecting them to the board. This left the regulator hanging in the air surrounded by wires.
This solution did work, but was not practical. During handling, one of the leads from the regulator snapped off. Because a spare regulator was not available, a new solution had to be improvised. The base of an NPN transistor is controlled by a resistive voltage divider. This transistor drops the voltage to power the esp-01. An additional load resistor is added to ensure a minimal current draw needed for this circuit to regulate the output voltage. The output voltage of this circuit is dependent on the input voltage and load, but as long as it is powered from 5V this should not be a problem. This is not the most efficient way to regulate voltage, but it was possible without complicated circuitry or waiting for new components to arrive. A capacitor is added to stabilize the voltage during current spikes caused by the wireless transmissions.

In the next iteration of the circuit, the 550 Ohm resistor was replaced by a 4.1 volt Zener diode. This should help to eliminate the dependency on in input voltage. All components are placed as close together as possible to fit the electronics in the case. All additional components are placed in the board area below the microcontroller. Wires are soldered to the board to connect to power and the display.

Display

The display is a 16 by 2 character LCD module. To interface with the display over the limited IO pins of the esp-01, an I2C adapter handles the communication with the display. This adapter board is soldered to the back of the display module. The adapter contains a PCF8574 I2C IO expander from Philips. This adapter adds software complexity, but reduces the number of IO pins needed. The IO0 and IO2 pins from the esp-01 are connected to the SLC and SDA pins on the I2C adapter. The other two data pins are used as serial interface to help during development. Apart from power, no other connections are necessary. The connections to the display module is made using one half of a DIP-8 IC socket. Colored wires are used to connect the module with the main controller board.

color signal
white vcc
brown gnd
yellow-brown sda
yellow-white scl

This adapter handles 4 of the lcd-driver data lines, the control signals and can turn on or off power to the backlight. More information about the control is given in the software section.

While the adapter is powered from 5V, it also accepts 3.3V data signals.

Enclosure

A 3d-printed case was designed and fabricated. 3D model files are available for download below will be made available ASAP. Blue filament was chosen to match the color of the display module. The enclosure consist of two parts. The first part is the main body that holds the power connector and all other components. The power connector is glued to the body in the opening that was created for this purpose. The second part of the enclosure is the front panel that holds the actual display. The display is mounted to this part. Next, the front part is mounted to the main body. Recesses for M3 nuts are included in the main body to secure the screws that hold the front panel. The final version has countersunk holes in the front panel. Because short countersunk screws where not available, four longer screws where shortened to a length of 8mm to fit in the available space.

All other electronics are placed in the remaining space behind the display. It is a tight fit, but by strategically positioning the components is possible.

Software

I2C

The I2C protocol is implemented by bit banging 2 pins of the esp-01. Both wires of the bus should be connected to open-drain outputs. The pull-up is provided by setting the internal pull-up on the esp-01 whenever any of the wires is not outputting as low. One of the lines is used to provide an clock signal. This signal is normally provided from the controller side, but other devices may temporarily halt the communication by keeping this line low. The controller checks for this condition and pauses until the line is released. The other line is used to transfer data. The controller sends data and checks for the acknowledgment. If no acknowledgment is received it can be assumed that an error has occurred and appropriate actions can be taken. When this happens the state of the display is unknown, so it has to be reset and reinitialized after communication is restored.

The display has to be interfaced via the I2C bus. However, it is not possible to send data directly to the display controller because this uses an parallel bus. The I2C IO expander has 8 lines, but some lines are used for control signals. Data communication to the is handled over an 4 bit parallel bus. To write to the parallel bus, first the data has to be set on the output of the IO expander. Next, one of the control lines has to be set. Both operations require writing all outputs of the IO expander. This process is repeated twice to send one byte.

One of the bits from the IO expander directly controls the backlight. This bit must be set to the correct value during every write to the expander to have the backlight turned either on or off.

Display

The first step is to put the display in 8 bit mode. This command has to be send twice to ensure it is received as intended if the display was still in 4 bit mode and waiting for the second nibble. Next, the display is put in 4 bit mode to allow for other communication to take place. Now some commands can be send to turn the display on and prepare it for writing data. Now data can be send to the display.

The display has a build in character set containing letter, numbers, punctuation ,some symbols and special characters. It also allows 8 user configurable glyphs. Most standard characters are mapped according to standard ASCII symbols. The custom glyphs can be used to display 5 by 8 bitmap images. The bitmap option is used to create building blocks to display large numbers over two rows. A digit can be formed by combining 6 glyphs in a 3 by 2 array. By reusing the same set of building blocks and including the space character, large numbers can be formed. The used custom glyphs and the digits that can be formed are shown below.

For a basic clock application, the time and day of the week is displayed. The hours and minutes are displayed by using the big digits as described above. Two characters on the bottom right are used to show seconds. The day of the week is indicated on the left by a two letter abbreviation. Two characters on the right of the top row are unused in the 24h format, but can provide AM/PM indication if the time is displayed in 12h format. As bonus, a flashing colon is added by using one of the dot symbols. This provides an indication when the module is stuck and does now longer send updates to the LCD.

Web Interface

To make use of the network capabilities, a web interface is implemented. Using the web interface it is possible to send a short message to be displayed on the LCD. The content and display duration can be set via this interface. Some processing is required to correctly display the message. The received string is treated URL-encoded information, while the display expects ASCII characters. Basic characters can simply be passed to the display. Encoded characters contain there ASCII value in hexadecimal, so decoding is straightforward. The space character may also be encoded as ‘+’, while the ‘+’ character is always encoded using its hexadecimal ASCII format. This is processed by substituting the characters. The system does not handle newline commands. The first 16 characters are displayed on the top row. The next 16 characters are displayed on the bottom row. Additional spaces can be inserted in the message to control the position of the text.

Additional features of the web interface include options to send reset commands to the LCD driver, change the time zone, and to turn the backlight on or off.

Deadline mode

When working on assignments, it may be useful to keep track of the remaining time. For this purpose, the deadline mode can be activated. It shows the remaining time and the title for the assignment. It calculates the remaining time based on the difference between the current time and the timestamp set for the deadline.

Conclusion

With an estimated total component cost of less than € 10, this project packs a lot of functionality. At the moment of writing the display serves as clock placed at my desk. The backlight provides good readability, especially in low light conditions. Without the backlight the large numbers are still readable with sufficient ambient lighting.

Recommendations

At night, the backlight can be very obnoxious. Some automation to automatically turn off the backlight in the evening if it left on would be handy. This can be achieved with a change to the software or by writing a home automation script.

To reprogram the microcontroller it is now necessary to disassemble the enclosure. It may be useful to find a way to access the programing interface from the outside. The best option would be to use the USB interface, but this does require an additional adapter. Maybe over-the-air programming can be used without placing additional components. This is currently not implemented.