This project allows you to use BBC micro:bit to read the Data from DHT22 and display it on the LED matrix. DHT22 is an low-cost digital temperature and humidity sensor. It uses a capacitive humidity sensor and a thermistor to measure the surrounding air, and spits out a digital signal on the data pin. Since this sensor comes without breakout board, it required user to add Pull-Up circuit on the Data line. User who choose to use DHT22(with breakout board) and may ignore this step.

Level of Difficultly:  Easy


List of Hardware


Install MakeCode Extension

2.Click the Setting Icon on top right à then choose Extension
3.On the search bar, type “dht22”.
4.Click on the extension to install.

You will notice the extension will show up here.    

Sample Code

  • Construct the code below. Or you may refer the link here for the sample code:


How DHT22 Works

The DHT22 has the temperature measuring range is from -40 to +125 degrees Celsius with +-0.5 degrees accuracy and also it has better humidity measuring range, from 0 to 100% with 2-5% accuracy. 


(1) On button A pressed, micro: bit will show the current temperature value and humanity on the LED matrix. 

(2) On Forever block, create a program that show HAPPY face when room temperature is around 25-29 celsius. and show SAD face when temperate is over or lower than that. 

Troubleshooting for DHT22

  • Scenario 1: micro:bit not showing any data/value from the sensor.
  • Solution: Check the wire connection, make sure wiring is connected firmly. Plus, the power is supply and not over limit. And also the pull-up circuit is connected for data pin of the sensor.