A Window of Data

Reading sensor data from an Arduino connecting OLED screen

JINGXI GUO
2 min readFeb 23, 2021

Reading the short pieces of sensor data sending from Arduino on a giant computer screen is never a satisfying choice. Imagine, if I just want to know the current temperature of the house, which needs me to connect the board to the computer, open the serial reading application and choose the port to listen to the data. These operations are overkill.

OLED Screen

Adding a small OLED screen into the system solves the problem easily. There are two resolutions of the screen that usually be used 128*32 and 128*64, and they also have two types of communication protocol to the microcontroller, I2C, and SPI. I2C type only has 4 pins, which is the easiest to use and transmit data from the microcontroller. SPI screen has 7 pins, which makes it not so easy to use. All these displays are driven by SSD1306.

128*32 I2C OLED Display
128*64 I2C(Left)/ SPI(Right) OLED Display

Schematic

Three components are used in this example.

  1. Arduino Nano 33 IoT
  2. DHT22 Humidity Temperature Sensor
  3. 128*32 I2C OLED Display

Code

Some libraries are needed to read the DHT sensor data and drive the OLED display. Another library I use SimpleRTC, which allows a real-time clock to run in the Arduino and show the time on screen. The Code of the program is here.

The only problem with the clock is once the power is down, the time will restore to the setting time in the Arduino script.

--

--