Electronic Hygrometer

From Microduino Wiki
Jump to: navigation, search

Outline

Anywhere Hum.jpg

Make a humidity indicator, which can light red when the humidity is lower, and green when the humidity is moderate, and blue when the humidity is higher.
Suitable kits: mCookie302, IBC


Module Bill

Module

Module Number Function
mCookie-Core 1 Core board
Battery box 1 Program download and power supply
mCookie-Hub 1 Sensor adapter plate
Humidity sensor 1 Detect the humidity
ColorLED 1 Color LED

Other Equipment

  • USB cable*1
  • Sensor cable*2
  • Sensor shell*1
  • Lego or other fixation structure
Anywhere Hum-module.jpg

Module Setup

Setup

Anywhere Hum-step.jpg
  • Assemble the modules and sensors:
    • Stick the red core module, battery base and green extension module together;
    • Connect the color LED to pin 6/7 of Hub;
    • Connect the Tem&Hum sensor to pin IIC of Hub;
    • Insert one end of USB cable into the battery base, and connect the other to computer;

Programming

Required Program Block

Programming Thought

If the humidity is lower than 45%, the color LED will change into red, representing that the air is dry; if the humidity is larger than 65%, the color LED will change into blue, representing the air is wet; if the humidity is between 45-65%, the color LED will change into green, representing the air is gentle.

Mixly-ctrl-Hum.jpg

Start to Program

Declare a variable named "h" to save the humidity value read.
ColorLED prepare: connect one color LED to pin 6. Declare a variable named h, which can save a float number. Write the value of the humidity sensor into the variable h.

Mixly-ctrl-Hum-code.jpg

Change the color of the color LED according to the humidity value.
If h is smaller than 45(the humidity is lower than 45%, too dry), the color LED will light red.
If h is larger than 65(the humidity is higher 65%, too wet), the color LED will light blue.
If the above two judgments are not matched (the humidity is between 45-65%, comfortable), it will light green.

Mixly-ctrl-Hum-code1.jpg



Test the result
After upload, observe the color of the color LED. Breathe toward the Tem&Hum sensor (change the humidity of the air), and observe the color change of the color LED.

Anywhere Hum.jpg



Q: Now we can judge whether the indoor humidity is moderate by the color of the color LED, how to see specific humidity value?
A: We can display the real-time humidity (temperature) value on the computer screen through a new program block "Println" program block.
Print the current humidity value.
Send the variable h(humidity value) to computer through USB cable.

Mixly-ctrl-Hum-code2.jpg

Check the real-time humidity value on the serial port.
Open the serial monitor, and you can see the real-time value of humidity on screen.

Mixly-ctrl-Hum-res.jpg

Technical Specification

  • The product number of the Tem&Hum sensor: MSDT11
  • For detail about Tem&Hum sensor, please refer to Sensor-Tem&Hum-S2

Related Cases


FAQ

  • Q: Why don't assign the humidity value to "h" directly when it is declared?
    • A: Because "declare a variable" is executed during program initialization, which means it can only be executed once. "Variable assignment" is executed in the process of program running in cycle. If only we need to real-timely detect the humidity, we must use the "variable assignment" program block, otherwise we will not get the real-time humidity value.


  • Q: What does the baud rate mean on the serial monitor?
    • A: Baud rate refers to the transmission speed between computer and the core module, which is 9600 by default. If the baud rate is not same with the set one, data transmission will come across garbed words.