Microbit Lesson-19: Displaying temperature and humidity in LCD display

Introduction

In this lesson, we will show you how to use the DHT11 sensor module to work with a micro bit and display the real-time value on the I2C 1602 LCD screen.

Parts Needed

  • 1x micro:bit
  • 1x Micro B USB Cable
  • 1x micro:bit Breakout (with Headers)
  • 1x Breadboard
  • 5x Jumper Wires
  • 1x  DHT11 Sensor Module
  • 1x  I2C 1602 LCD

Wiring Diagram for the project

Connect the DHT11 to the micro bit breakout as below:

Micro bit Breakout DHT11 sensor
3.3v VCC
P8 DATA
GND Ground

Connect the I2C 1602 LCD to the breakout board as below:

Micro bit Breakout LCD1602
5V VCC
GND GND
P19/SCL SCL
P20/SDA SDA

Run Your Script

Either copy and paste, or re-create the following code into your own MakeCode editor by clicking the open icon in the upper right-hand corner of the editor window. You can also just download this example by clicking the download button in the lower right-hand corner of the code window.

 

https://makecode.microbit.org/_XUPeKDPxfJ4y

Overhere, the device  I2C address is “0x3F”, please enter “63” to the address bar.

If your the I2C address of this device is “0x27”, so we type “39” in the address bar.

Result

After downloaded this code to your micro bit, pull out the USB line and insert the USB line to the expansion board, you will see “QUAD STORE DHT 11” on the LCD screen, then you will see the real-time humidity and temperature data displayed on the LCD.

Note:

If the screen is not bright, please check the wires. If the screen is bright, but you do not see the above results, please check you I2C address.

Leave a Reply

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