Adafruit AM2315 Library
Public Member Functions | List of all members
Adafruit_AM2315 Class Reference

#include <Adafruit_AM2315.h>

Public Member Functions

 Adafruit_AM2315 (TwoWire *theI2C=&Wire)
 Instantiates a new AM2320 class. More...
 
boolean begin (void)
 Setups the hardware. More...
 
float readTemperature (void)
 Read and return the temperature, note you can only read once every 2 seconds. More...
 
float readHumidity (void)
 Read and return the humidity, note you can only read once every 2 seconds. More...
 
bool readTemperatureAndHumidity (float *, float *)
 This method returns both temperature and humidity in a single call and using a single I2C request. If you want to obtain both temperature and humidity when you sample the sensor, be aware that calling readTemperature() and readHumidity() in rapid succession may swamp the sensor and result in invalid readingings (the AM2315 manual advisess that continuous samples must be at least 2 seconds apart). Calling this method avoids the double I2C request. More...
 

Detailed Description

The object for interfacing with the AM2315 sensor

Constructor & Destructor Documentation

◆ Adafruit_AM2315()

Adafruit_AM2315::Adafruit_AM2315 ( TwoWire *  theI2C = &Wire)

Instantiates a new AM2320 class.

Parameters
theI2COptional pointer to a TwoWire object that should be used for I2C communication. Defaults to &Wire.

Member Function Documentation

◆ begin()

boolean Adafruit_AM2315::begin ( void  )

Setups the hardware.

Returns
True on a successful read, false if first read failed

◆ readTemperature()

float Adafruit_AM2315::readTemperature ( void  )

Read and return the temperature, note you can only read once every 2 seconds.

Returns
Floating point Celsius temperature on success, NAN on failure

◆ readHumidity()

float Adafruit_AM2315::readHumidity ( void  )

Read and return the humidity, note you can only read once every 2 seconds.

Returns
Floating point percentace humidity on success, NAN on failure

◆ readTemperatureAndHumidity()

bool Adafruit_AM2315::readTemperatureAndHumidity ( float *  t,
float *  h 
)

This method returns both temperature and humidity in a single call and using a single I2C request. If you want to obtain both temperature and humidity when you sample the sensor, be aware that calling readTemperature() and readHumidity() in rapid succession may swamp the sensor and result in invalid readingings (the AM2315 manual advisess that continuous samples must be at least 2 seconds apart). Calling this method avoids the double I2C request.

Parameters
tPointer to float to store temperature data in
hPointer to float to store humidity data in
Returns
True if successful data read, note you can only read once every 2 seconds

The documentation for this class was generated from the following files: