An Adafruit Si7021, Raspberry Pi and Pimoroni Display-o-Tron HAT Humidity and Temperature Measurement Device




Introduction: An Adafruit Si7021, Raspberry Pi and Pimoroni Display-o-Tron HAT Humidity and Temperature Measurement Device

The simple and easy to assemble device described in the following uses

-an Adafruit Si7021 ic2 sensor breakout to measure humidity and temperature,

- a Raspberry Pi (Zero) to read and interpret the data, and

- a Pimoroni Display-O-Tron HAT to display the results as text, and in colors, and on a LED bar graph.

It allows to measure temperature and humidity using the relatively precise Si7021 sensor. In combination with a Pi Zero and a power bank you can build a small mobile device.

With some minor adaptions this example may also be helpful to construct other measuring devices using ic2 sensors. E.g. a cheap mobile photometer for field research, or a device to measure colors precisely. And, as it is i2c, you may use multiple different sensors in parallel.

Step 1: Setting Up the Device

The device consists on the following parts:

- a Raspberry Pi, presumably any version may do. Its been evaluated on on RPi Zero, see below, RPi 2 and 3
- an Adafruit Si7021 Temperature & Humidity Sensor Breakout Board Si7021 (Adafruit, 6.95$)
- a Pimoroni Display-O-Tron HAT (22 GBP at Pimoroni). It comes with a breakout for ic2 and some other ports. I had added a single row header to simplify the connection of the cables.
- four extension jumper wires

- Get your Pi up and running. Make sure to activate i2c and SPI.

- Attach the the Display-O-Tron HAT and install the recommend software, as described on the Pimoroni web site ( ).

- Assemble the Si7021 breakout as described on the Adafruit website ( ). Your may either solder a header to the breakout (recommended) or attach the cables directly.

- Attach the jumper cables to the Vin, gnd, scl and sda ports on the sensor breakout and connect them with the respective ports on the Display-O-Tron, as shown in the images.

Install and run the attached Python script.

That's it.

I case you may want to have some kind of housing, a breadbox may do for the start.

The computing power of a PiZero is sufficient for the program. This allows to build, in conjunction with a power pack, a mobile device to measure temperature and humidity practicably anywhere.

Step 2: The Python Script

The attached Python script allows to perform temperature and humidity measurements, and to display the results of the measured values and a timestamp as text on the Display-O-Tron HAT and on the computer screen.

In addition, the temperature is indicated by the color of the display. It will become blue indicating the temperature of a room being "too cold", green for "moderate" and red for "too hot". The humidity is indicated by the six LED-bar graph on the Display-O-Tron, from 0 - 100% in 16.6% steps. So you may see if the conditions in your green house (bath, fridge, humidor, ...) are within the reference range, without the need to actually read the numbers.

The current layout of the script was designed to measure a kinetic process, taking a defined number of measurements over a given, limited time. You may easily adapt the number of measurements as well as the length of pauses between measurements. Now it is set to perform one measurement per minute. For permanent measurements a bit of programming might be required. With some minor additions you may also write the measurements to a CSV log file.

The code to read the data from the SI7021 sensor has been taken from, was minimally adjusted and then extended with the code for the Display-O-Tron. The attached code may be freely distributed, but only in concordance with the rules defined by ControlEverything. It comes at it is, to be used on your own risk and no liabilities are taken for any harm or damage.

Have fun,


P.S.: I turned out that the part of the script reading the data from the sensor is not optimal, as it is reading the higher bit twice instead of the higher and lower data bit. This might not be real problem for humidity, but this reduces the resolution of temperatur measurements to 0,7 °C steps. I am trying to find a solution, but any help will be appreciated.

Sensors Contest 2017

Participated in the
Sensors Contest 2017

Be the First to Share


    • Audio Challenge 2020

      Audio Challenge 2020
    • Maps Challenge

      Maps Challenge
    • Backyard Contest

      Backyard Contest