Skip to content

Xinjian-Zhang/AM2320_XINJIAN

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AM2320_XINJIAN

AM2320_XINJIAN is an Arduino library designed to interface with the AM2320 temperature and humidity sensor using the SoftwareWire library, allowing I2C communication on custom pins.

Features

  • Read temperature and humidity data from the AM2320 sensor.
  • Support for SoftwareWire to enable I2C communication on user-defined pins.

Installation

  1. Download the latest version of the AM2320_XINJIAN library.
  2. Extract the downloaded archive and rename the folder to AM2320_XINJIAN.
  3. Move the AM2320_XINJIAN folder to your Arduino libraries directory, typically located at ~/Documents/Arduino/libraries/.
  4. In the Arduino IDE, navigate to Tools > Manage Libraries, search for and install the SoftwareWire library.

Usage

Here's an example of how to use the AM2320_XINJIAN library:

#include <SoftwareWire.h>
#include <AM2320_XINJIAN.h>

// Define software I2C pins
SoftwareWire myWire(10, 11); // SDA = 10, SCL = 11

// Initialize the AM2320_XINJIAN sensor
AM2320_XINJIAN am2320;

void setup() {
  Serial.begin(9600);
  myWire.begin();
  am2320.setWire(&myWire);
}

void loop() {
  int status = am2320.update();
  if (status == AM2320_XINJIAN_SUCCESS) {
    Serial.print("Temperature: ");
    Serial.print(am2320.temperatureC);
    Serial.print(" °C, Humidity: ");
    Serial.print(am2320.humidity);
    Serial.println(" %");
  } else {
    Serial.print("Failed to read sensor data, error code: ");
    Serial.println(status);
  }
  delay(2000); // Read every 2 seconds
}

Acknowledgments

This library is based on the AM2320_asukiaaa library by Asuki Kono, with modifications to support SoftwareWire. A huge appreciate the original author's contributions.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages