Case 07: Humidity&Temp. Monitor
Contents
8. Case 07: Humidity&Temp. Monitor#
8.1. Introduction#
The most comfortable indoors temperature for us is 15-18℃. If the indoor air is not circulating or the relative humidity is less than 35%, and the indoor temperature exceeds 25℃, we will begin to absorb heat from the outside which would make us feel hot. If the temperature exceeds 35°C, the sweat glands will start to activate, and the body temperature accumulates through sweating slightly, which could increase the heartbeat and accelerate blood circulation, we might feel dizzy and fatigue at the same time.
A healthy humidity environment is 45%-65%. Such humidity conditions are the best to us, and various germs are not easy to spread. Humidity higher than 65% will cause discomfort to the human respiratory system and mucous membranes and reduce immunity.
8.2. Function#
Detect the humidity and temperature from the DHT11 sensor and display them on the OLED screen.
8.3. Products Link#
8.4. Picture#
8.5. Hardware Connection#
Connect the DHT11 sensor to P1 and the OLED to IIC on sensor:bit.
8.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 “smarthome” 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.
8.7. Program#
Initialize the OLED screen.
Save the returned value of the humidity from the DHT11 sensor connecting to P1 as the variable “RH” and the temperature as the variable “Temp”, note a 2000ms pause is required in this operation due to the characteristics of the hardware.
Clear the OLED screen and display the humidity and temperature value on the OLED screen.
8.8. Result#
Display the humidity and temperature value on the OLED screen.