4. Case 02: Temp.&Humidity Monitoring in the Greenhouse#

4.1. Introduction#

  • Different plants require different temperture and humidity to grow, we can make a monitoring device for greenhouses to get the temperature and humidity.

4.2. Function#

  • Detect the temperature and humidity from the DHT11 sensor and display them on the OLED screen.

4.4. Picture#


4.5. Hardware Connection#

Connect the DHT11 sensor to P1 and the OLED display to IIC on IoT:bit.


4.6. Software Programming#

Click “Advanced” in the MakeCode to see more choices.


For programming, we need to add a package: click “Extensions” at the bottom of the MakeCode drawer and search with “iot-environment-kit” in the dialogue box to download it.


Notice: If you met a tip indicating that some codebases would be deleted due to incompatibility, you may continue as the tips say or create a new project in the menu.

4.7. Program#

Drag the on start block from drawer and show an icon, save the returned value of the temperature as the variable “Temp” and the humidity as the variable “RH”, as there is a 3-sec interval between getting the value of temperature and humidity, we need to add a 5-sec pause here.


Initialize the OLED screen and display the returned value on it.


Link: https://makecode.microbit.org/_hT5JjX0JDWqV

4.8. Result#

  • The current temperature and humidity values display on the OLED screen.