MagicCode Lesson 12
Temperature & Humidity Sensor
Measure humidity and moisture
A humidity sensor (or hygrometer) senses, measures and reports both moisture and air temperature. The ratio of moisture in the air to the highest amount of moisture at a particular air temperature is called relative humidity. Relative humidity becomes an important factor when looking for comfort.
The DHT11 detects water vapor by measuring the electrical resistance between two electrodes. The humidity-sensing component is a moisture holding substrate with electrodes applied to the surface. When water vapor is absorbed by the substrate, ions are released by the substrate, which increases the conductivity between the electrodes. The change in resistance between the two electrodes is proportional to the relative humidity. Higher relative humidity decreases the resistance between the electrodes, while lower relative humidity increases the resistance between the electrodes. The DHT11 measures temperature with a surface mounted NTC temperature sensor (thermistor) built into the unit.
Connect the Temperature & Humidity sensor to the Magicbit via left upper connector. In this Example we uses D32 pin on Magicbit to connect the sensor. Then Drag and Drop following blocks from the palatte and make the following Script.
In this example, your sprite going to tell you the temperature and humidity value that you are going to measure. After you click the green flag, the sprite tells you first the temperature and after that the humidity. The “Say for [time] seconds” block is used to set the text the sprite wants to say. The “Join” block is used here to join texts. You can read the temperature and humidity values with “Read Temperature” and “Read humidity” blocks.