Home Temperature Projects AM2320 readings on an LCD4884 shield example

AM2320 readings on an LCD4884 shield example

by shedboy71

In this example we connect an AM2320 sensor to an LCD4884 shield which in turn is fitted to an Arduino Uno, we will then display the temperature and humidity readings on the LCD from the sensor. Lets look at some information about the sensor.

Temperature and humidity combined sensor AM2320 digital temperature and humidity sensor is a digital signal output has been calibrated. Using special temperature and humidity acquisition technology, ensure that the product has a very high reliability and excellent long-term stability. Sensor consists of a capacitive moisture element and an integrated high-precision temperature measurement devices, and connected with a high-performance microprocessor .

AM2320 communication using a single bus, two communication modes standard I2C. Standard single-bus interface, the system integration becomes easy and quick. Ultra-small size, low power consumption, signal transmission distance up to 20 meters, making all kinds of applications and even the most demanding applications the best choice. I2C communication using standard communication sequence, the user can directly linked to the I2C communication bus without additional wiring, simple to use. Two communication modes are used as humidity, temperature, and other digital information directly CRC checksum temperature-compensated output, users do not need to calculate the secondary digital output, and no need for temperature compensation of the humidity, temperature and humidity can be accurately information. Two communication modes are free to switch, the user can freely choose, easy to use, wide range of applications.

 

Specifications

• Operating Voltage: 3.1 VDC to 5.5 VDC
• Operating Temperature Range: -40 ° C to + 80 ° C
• Humidity Range: 0 to 99.9% RH
• Accuracy ( 25 ° C environment)
Temperature: ± 0.5 ° C
Humidity: ± 3%
• RH (10 … 90% RH)
Resolution: Temperature: 0.1 ° C
Resolution: Humidity: 0.1% RH
• Attenuation values
Temperature: <0.1 ℃ / Year
Humidity: <1% RH / Year
• Response time: Temperature: 5s
• Response Time: Humidity: 5s 1 / e (63%)
• Output signal: single bus / IIC signal
• Housing material: PC plastic

 

Parts List

Description Link
Arduino Uno 1pcs UNO R3 CH340G+MEGA328P for Arduino UNO R3 (NO USB CABLE)
LCD4884 Shield LCD4884 LCD Joystick Shield v2.0 4884 LCD Expansion Board
AM2320 Sensor 1PCS AM2320 Digital Temperature and Humidity Sensor I2C communication
Connecting cable 40pcs Dupont jumper wire cable 30cm male to male,female to female,male to female Dupont jump wire line 2.54mm breadboard cable

 

Connection

 

 

Code

You will need to install the Adafruit GXX and PCD8544 libraries and https://github.com/EngDial/AM2320 for the sensor

[codesyntax lang=”cpp”]

#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>
#include <Wire.h>
#include <AM2320.h>


// Software SPI (slower updates, more flexible pin options):
// pin 7 - Serial clock out (SCLK)
// pin 6 - Serial data out (DIN)
// pin 5 - Data/Command select (D/C)
// pin 4 - LCD chip select (CS)
// pin 3 - LCD reset (RST)
Adafruit_PCD8544 display = Adafruit_PCD8544(2, 3, 4, 5, 6); //dfrobot lcd4884 shield

#define XPOS 0
#define YPOS 1
#define DELTAY 2

AM2320 th;

void setup()   
{
  Serial.begin(9600);
  Wire.begin();             // join i2c bus (address optional for master) 
  display.begin();
  // init done

  // you can change the contrast around to adapt the display
  // for the best viewing!
  display.setContrast(50);
  display.clearDisplay();   // clears the screen and buffer
  // text display tests
  display.setTextSize(1);
  display.setTextColor(BLACK);
  display.setCursor(0,0);
  display.setTextColor(WHITE, BLACK); // 'inverted' text
  display.println("AM2302 TEST");
  display.display();
  delay(1000);

}

 
void loop() 
{

    // Display temperature
    display.setTextColor(BLACK, WHITE); // 'inverted' text
    Serial.println("Chip = AM2320");
    display.setCursor(0,0);
    switch(th.Read()) 
    {
      case 2:
        display.println(" CRC failed");
        break;
      case 1:
        display.println(" Sensor offline");
        break;
      case 0:
        display.setCursor(0,15);
        display.print("Humi = ");
        display.print(th.Humidity);
        display.println("%");
        display.setCursor(0,30);
        display.print("Temp = ");
        display.print(th.cTemp);
        display.println("C");
        display.println();
        break;
    }
    display.display();
    delay(1000);
}

[/codesyntax]

 

Links

You can download the code here – AM2320onPCD8544

You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More