Temperature & Humidity Sensor

From Microduino Wiki
Revision as of 02:29, 5 November 2015 by 1304410487@qq.com (talk) (Experiment: Detect Temp&Hum Values)
Jump to: navigation, search

Outline

This tutorial adopts AM2321 digital temperature and humidity sensor. Microudino-Temp&Hum consists of a capacitive humidity sensor and a high precision integrated temperature measuring component, connecting with a high performance microprocessor. Therefore, the product has the advantages of excellent quality, fast response, high anti-interference and high comparability in price and etc.

Specification

  • Electrical specification
    • Operation voltage: 2.6~5V;
    • Input device
  • Tech parameters
    • Accuracy: 0.1°C in temperature and 0.1%RH in relative humidity;
  • Size
    • Size of the Sensor: 8mm*11mm,
    • Size of the Board: 20mm*10mm
    • 1.27mm-pitch 4Pin interface;
  • Connection method
    • Interface: I2C。
    • Pin description: GND, VCC, Signal 1 and Signal 2. This output signal is IIC and needs IIC interface to receive signal, which can connect Sensorhub's IIC pin.

Development

Equipment

Module Number Function
mCookie-CoreUSB 1 Core board
mCookie-Hub 1 Sensor pin board
Microduino-Temp&Hum 1 Sound detection sensor
  • Other Hardware Equipment
    • One USB cable
Temp-Hum.jpg

Preparation

  • Setup 1:Connect Microduino-Temp&Hum to the IIC port of the Hub.
MCookie-Temp&Hum-sensor.JPG
  • Setup 2:Stack the CoreUSB, Hub and Sound together and then connect them to the computer with a USB cable.
MCookie-Sound-pc.JPG

Experiment: Detect Temp&Hum Values

  • Open Arduino IDE and copy the following code into IDE.
#include <Wire.h>
#include <AM2321.h>

void setup() {
  Serial.begin(9600);
}

void loop() {
  readByAM2321();
  delay(500);
}

void readByAM2321()
{
  AM2321 am2321;
  am2321.read();

  Serial.print("(");
  Serial.print(am2321.temperature/10.0);
  Serial.print(", ");
  Serial.print(am2321.humidity/10.0);
  Serial.println(')');
}
  • Select the right board from Tools→Serial Port in Arduino IDE and download the program.
Uploadhum.JPG
  • Open the serial monitor after download; The value displayed reflects the current temperature and humidity.
MCookie-Temp-Hum-reshum.JPG

Program Debugging

  • The program uses AM2321 temperature and humidity collection library and defines "#include <Wire.h>" and "#include <AM2321.h>" as driving files.
  • “am2321.temperature/10.0”represents the calculated temperature value and " am2321.humidity/10.0" represents the calculated humidity value.

Application

Microudino-Temp&Hum can be widely applied in HVAC system, dehumidifier, testing and detection equipment, consumer goods, automobile, automatic control, data recorder, weather station, appliances, humidity control, medical care, and other relative humidity detection control.

Video