Showing temperature in a OLED display using Espruino and an ESP8266 board

In this short article I will show you how to read the temperature and the relative humidity from a DHT22 sensor and display it in a 128×64 OLED display using an ESP8266 board with Espruino and JavaScript running on it.

Wiring

The DHT22 has 4 pins, only three used: two for the power and one for the data. We will connect the power pins to the corresponding pins on the ESP8266 board and the data pin to one of the GPIO pin, D7 in our schema.

The display is a SSD1306 with a resolution of 128×64 pixels and I2C communication. The display has four pins, two for the power and two for the I2C. We connect the I2C pin to the corresponding D1 e D2 pins in the ESP8266 board.

Code

Espruino provides a module for reading the temperature and the relative humidity from a DHT22 sensor. We will use it to read both the values from the connected sensor.

Then we will use the I2C module combined to the SSD1306 module to show the collected information in the display.

We will poll the sensor every 2 seconds and update the display consequently.

The final result:

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.