Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Hardware
  3. AM2320 will this work as a replacement for AM2302 / DHT22

AM2320 will this work as a replacement for AM2302 / DHT22

Scheduled Pinned Locked Moved Hardware
4 Posts 4 Posters 11.4k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    brchevo
    wrote on last edited by brchevo
    #1

    I was looking for another humidity sensor and the AM2320 came up as a alternative to DHT22 / AM2302.
    Has anyone tried this unit already? Will this work as a direct replacement in the humidity sketch for a DHT22?

    Thanks in advance! :-)

    TheoLT 1 Reply Last reply
    0
    • B brchevo

      I was looking for another humidity sensor and the AM2320 came up as a alternative to DHT22 / AM2302.
      Has anyone tried this unit already? Will this work as a direct replacement in the humidity sketch for a DHT22?

      Thanks in advance! :-)

      TheoLT Offline
      TheoLT Offline
      TheoL
      Contest Winner
      wrote on last edited by
      #2

      @brchevo I just googled for AM2320 and came accross the AdaFruit site. They say that the AM2302 is just a wired version of the DHT22. So it should work perfect since it is a DHT22.

      1 Reply Last reply
      0
      • O Offline
        O Offline
        Omemanti
        wrote on last edited by
        #3

        I know, im responding to an old thread,

        AM2320 is not the same as AM2302, I might be wrong, the switcheroo between 20 an 02 is easily made,

        If Im correct;
        AM2320 = 1 = vcc / 2 = SDA / 3 = GND / 4 = SCL

        AM2302 = 1 = vcc / 2 = SDA / 3 = NC / 4 = GND

        Please correct me if im wrong, cuz I dont get the AM2320 properly working.

        1 Reply Last reply
        0
        • bgunnarbB Offline
          bgunnarbB Offline
          bgunnarb
          wrote on last edited by
          #4

          @Omemanti
          I think the AM2320 has got an "One-wire mode", at least if you look at the datasheet. I have not tried it though.

          I also had great difficulties in getting the AM2320 to work with I2C until I realised late last night that I had forgotten to include the pull-up resistors, 4k7 each from SDC and SDA to Vcc. All other I2C sensors I have used have had them included on the breakout board but this sensor does not have them built in the sensor body.
          Now it works like a charm, one measurement of temp and hum every 2 minutes.
          There are a few arduino-libraries for AM2320 floating around. I use this: (https://github.com/thakshak/AM2320)

          Here is my sketch:

          
          
          /**
           * The MySensors Arduino library handles the wireless radio link and protocol
           * between your home built sensors/actuators and HA controller of choice.
           * The sensors forms a self healing radio network with optional repeaters. Each
           * repeater and gateway builds a routing tables in EEPROM which keeps track of the
           * network topology allowing messages to be routed to nodes.
           *
           * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
           * Copyright (C) 2013-2015 Sensnology AB
           * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
           *
           * Documentation: http://www.mysensors.org
           * Support Forum: http://forum.mysensors.org
           *
           * This program is free software; you can redistribute it and/or
           * modify it under the terms of the GNU General Public License
           * version 2 as published by the Free Software Foundation.
           *
           *******************************
           *
           * DESCRIPTION
           *
           * Temperature and humidity measurement using the AM2320 with I2C interface
           * Battery voltage also monitored using internal reference
           * 
           */
          
          
          // Enable debug prints to serial monitor
          #define MY_DEBUG
          #define MY_NODE_ID 23
          #define BATTERY_SENSE_PIN A0  // Input pin for battery sense
          #define VMIN 1.0  // (Min input voltage to regulator according to datasheet or guessing. (?) )
          #define VMAX 3.22 // (Known or desired voltage of full batteries. If not, set to Vlim.)
          #define CHILD_ID_HUM 0
          #define CHILD_ID_TEMP 1
           
          
          // Enable and select radio type attached
          #define MY_RADIO_NRF24
          //#define MY_RADIO_RFM69
          
          #include <SPI.h>
          #include <AM2320.h>
          #include <Wire.h>
          #include <MySensors.h>  
          
          #define DEBUG_PRINT 0  // Print temperature and humidity measurements on serial i/f. 1 = Yes 0 = No
          
          unsigned long SLEEP_TIME = 120000; // Sleep time between reads (in milliseconds)
          bool receivedConfig = false;
          bool metric = true;
          float temp, hum;
          
          
          // Create an AM2320 instance
          AM2320 th;
          // Initialize AM temperature message
          MyMessage msgt(CHILD_ID_TEMP,V_TEMP);
          // Initialize AM humidity message
          MyMessage msgh(CHILD_ID_HUM,V_HUM);
          
          
          void before()
          {
            // use the 1.1 V internal reference
            #if defined(__AVR_ATmega2560__)
              analogReference(INTERNAL1V1);
            #else
              analogReference(INTERNAL);
            #endif
            
          }
          
          void setup()  
          { 
          Serial.begin(115200);
          Wire.begin();
          }
          
          void presentation() {
            // Send the sketch version information to the gateway and Controller
            sendSketchInfo("Temp. Hum Sensor", "1.4");
            
            // Present temp/humidity sensor to controller
            present(CHILD_ID_TEMP, S_TEMP);
            present(CHILD_ID_HUM, S_HUM);
          }
          
          void loop()     
          {
            //Get temperature and humidity from AM2320
            switch(th.Read()) {
              case 2:
                Serial.println("CRC failed");
                break;
              case 1:
                Serial.println("Sensor offline");
                break;
              case 0:
                temp = th.t;
                send(msgt.set(temp, 1));
                hum = th.h;
                send(msgh.set(hum, 0));
                if (DEBUG_PRINT == 1) {
                  Serial.print("humidity: "); 
                  Serial.print(th.h);
                  Serial.print("%, temperature: ");
                  Serial.print(th.t);
                  Serial.println("*C");
                }
                break;
            }
              
            sleep (200);
            // get the battery voltage
            int batValue = analogRead(BATTERY_SENSE_PIN);    // Battery monitoring reading
            float Vbat  = batValue * 0.003363;
            int batteryPcnt = static_cast<int>(((Vbat-VMIN)/(VMAX-VMIN))*100.);   
            sendBatteryLevel(batteryPcnt);
            
            sleep(SLEEP_TIME);
          }```

          I have never been so busy since I retired!

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          21

          Online

          11.7k

          Users

          11.2k

          Topics

          113.1k

          Posts


          Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • MySensors
          • OpenHardware.io
          • Categories
          • Recent
          • Tags
          • Popular