3. Case 02: Temp.&Humidity Monitoring in the Greenhouse¶
Different plants require different temperture and humidity to grow, we can make a monitoring device for greenhouses to get the temperature and humidity.
Detect the temperature and humidity from the DHT11 sensor and display them on the OLED screen.
3.5. Hardware Connection¶
Connect the DHT11 sensor to P1 and the OLED display to IIC on IoT:bit.
3.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.
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.
The current temperature and humidity values display on the OLED screen.