Nucleo and AM2302 sensor example

25

AM2302 capacitive humidity sensing digital temperature and humidity module is one that contains the compound has been calibrated digital signal output of the temperature and humidity sensors. Application of a dedicated digital modules collection technology and the temperature and humidity sensing technology, to ensure that the product has high reliability and excellent long-term stability. The sensor includes a capacitive sensor wet components and a high-precision temperature measurement devices, and connected with a high-performance 8-bit microcontroller.

The best way to use this is to use a module/breakout like the following one
DHT22 AM2302 Digital Temperature Humidity Sensor Chip For Arduino

 

Schematic

In this example we connect the AM2302 to D12.

am2302 micro
am2302 micro

The code example requires you to import the AM2303 library –¬†Shigenori Inoue craeted the one I used.

Code

#include "mbed.h"
#include "AM2303.h"
 
 
 
/* Humidity sensor */
AM2303 h(D12);
 
/* The main function */
int main()
{
    /* Variables */
    int state;
 
    /* Show splash screen */
    printf("AM2303 Humidity");
    /* Infinate loop */
    while(true) 
    {
        /* Wait for measurement */
        wait(2.0);
 
        /* Read the measured results */
        state = h.readData();
 
        /* Show the data, otherwise error */
        if (state != AM2303::OK) {
            printf("<Error: %d>\n", state);
        } else {
            printf("T:%2.1fC, H:%2.1f%%\n", h.readTemperature(), h.readHumidity());
        }
 
 
    }
}

 

Result

Using a terminal such as TeraTerm you should see something like the following

nucleo am2302 output
nucleo am2302 output

Link

 

DHT22 AM2302 Digital Temperature Humidity Sensor Chip Electronic Brick

Share