AOSong AM2315 topic

Classes for the AOSong AM2315 encased I2C capacitive humidity and temperature sensor.

Quick Notes

  • Applies to both the AOSong AM2315 and CM2311 capacitive relative humidity and temperature sensors
  • Depends on the Adafruit AM2315 Library.
  • Communicates via I2C
    • only one address possible, 0xB8
  • Only 1 can be connected to a single I2C bus at a time
  • Requires a 3.3 - 5.5V power source

Sensor Datasheet

Datasheet

Sensor Constructors

AOSongAM2315::AOSongAM2315(int8_t powerPin, uint8_t measurementsToAverage = 1) explicit

Construct a new AOSongAM2315 object using the primary hardware I2C instance.

Parameters
powerPin

The pin on the mcu controlling power to the AOSong AM2315. Use -1 if it is continuously powered.

  • The AM2315 requires a 3.3 - 5.5V power source
measurementsToAverage The number of measurements to take and average before giving a "final" result from the sensor; optional with a default value of 1.

Because this is I2C and has only 1 possible address (0xB8), we only need the power pin.


Example Code

The AM2315 is used in the double logger and menu a la carte example

1#include <sensors/AOSongAM2315.h>
2
3// NOTE: Use -1 for any pins that don't apply or aren't being used.
4const int8_t AM2315Power = sensorPowerPin; // Power pin
5
6// Create an AOSong AM2315 sensor object
7AOSongAM2315 am2315(AM2315Power);
8
9// Create humidity and temperature variable pointers for the AM2315
10Variable* am2315Humid =
11 new AOSongAM2315_Humidity(&am2315, "12345678-abcd-1234-ef00-1234567890ab");
12Variable* am2315Temp =
13 new AOSongAM2315_Temp(&am2315, "12345678-abcd-1234-ef00-1234567890ab");

Classes

class AOSongAM2315
The Sensor sub-class for the AOSong AM2315.
class AOSongAM2315_Humidity
The Variable sub-class used for the relative humidity output from an AOSong AM2315.
class AOSongAM2315_Temp
The Variable sub-class used for the temperature output from an AOSong AM2315.

Sensor Variable Counts

The number of variables that can be returned by an AOSong AM2315

#define AM2315_NUM_VARIABLES = 2
Sensor::_numReturnedValues; the AM2315 can report 2 values.
#define AM2315_INC_CALC_VARIABLES = 0
Sensor::_incCalcValues; we don't calculate any additional values.

Sensor Timing

The sensor timing for an AOSong AM2315

#define AM2315_WARM_UP_TIME_MS = 500
Sensor::_warmUpTime_ms; the AM2315 warms up in 500ms (estimated).
#define AM2315_STABILIZATION_TIME_MS = 500
Sensor::_stabilizationTime_ms; the AM2315 is stable after 500ms (estimated).
#define AM2315_MEASUREMENT_TIME_MS = 2000
Sensor::_measurementTime_ms; the AM2315 takes 2000ms (2s) to complete a measurement.

Humidity

The humidity variable from an AOSong AM2315

  • Range is 0 to 100% RH
  • Accuracy is ± 2 % RH at 25°C

AOSongAM2315_Humidity::AOSongAM2315_Humidity(AOSongAM2315* parentSense, const char* uuid = "", const char* varCode = "AM2315Humidity") explicit

Construct a new AOSongAM2315_Humidity object.

Parameters
parentSense The parent AOSongAM2315 providing the result values.
uuid A universally unique identifier (UUID or GUID) for the variable; optional with the default value of an empty string.
varCode A short code to help identify the variable in files; optional with a default value of "AM2315Humidity".

#define AM2315_HUMIDITY_RESOLUTION = 1
Decimals places in string representation; humidity should have 1 (0.1 % RH for the 16 bit sensor).
#define AM2315_HUMIDITY_VAR_NUM = 0
Sensor variable number; humidity is stored in sensorValues[0].
#define AM2315_HUMIDITY_VAR_NAME = "relativeHumidity"
Variable name in ODM2 controlled vocabulary; "relativeHumidity".
#define AM2315_HUMIDITY_UNIT_NAME = "percent"
Variable unit name in ODM2 controlled vocabulary; "percent" (percent relative humidity)
#define AM2315_HUMIDITY_DEFAULT_CODE = "AM2315Humidity"
Default variable short code; "AM2315Humidity".

Temperature

The temperature variable from an AOSong AM2315

  • Range is -40°C to +125°C
  • Accuracy is ±0.1°C

AOSongAM2315_Temp::AOSongAM2315_Temp(AOSongAM2315* parentSense, const char* uuid = "", const char* varCode = "AM2315Temp") explicit

Construct a new AOSongAM2315_Temp object.

Parameters
parentSense The parent AOSongAM2315 providing the result values.
uuid A universally unique identifier (UUID or GUID) for the variable; optional with the default value of an empty string.
varCode A short code to help identify the variable in files; optional with a default value of "AM2315Temp".

#define AM2315_TEMP_RESOLUTION = 1
Decimals places in string representation; temperature should have 1. (0.1°C for the 16 bit sensor)
#define AM2315_TEMP_VAR_NUM = 1
Sensor variable number; temperature is stored in sensorValues[1].
#define AM2315_TEMP_VAR_NAME = "temperature"
Variable name in ODM2 controlled vocabulary; "temperature".
#define AM2315_TEMP_UNIT_NAME = "degreeCelsius"
Variable unit name in ODM2 controlled vocabulary; "degreeCelsius" (°C)
#define AM2315_TEMP_DEFAULT_CODE = "AM2315Temp"
Default variable short code; "AM2315Temp".

Define documentation

#define AM2315_NUM_VARIABLES = 2

Sensor::_numReturnedValues; the AM2315 can report 2 values.


#define AM2315_INC_CALC_VARIABLES = 0

Sensor::_incCalcValues; we don't calculate any additional values.


#define AM2315_WARM_UP_TIME_MS = 500

Sensor::_warmUpTime_ms; the AM2315 warms up in 500ms (estimated).


#define AM2315_STABILIZATION_TIME_MS = 500

Sensor::_stabilizationTime_ms; the AM2315 is stable after 500ms (estimated).


#define AM2315_MEASUREMENT_TIME_MS = 2000

Sensor::_measurementTime_ms; the AM2315 takes 2000ms (2s) to complete a measurement.


#define AM2315_HUMIDITY_RESOLUTION = 1

Decimals places in string representation; humidity should have 1 (0.1 % RH for the 16 bit sensor).


#define AM2315_HUMIDITY_VAR_NUM = 0

Sensor variable number; humidity is stored in sensorValues[0].


#define AM2315_HUMIDITY_VAR_NAME = "relativeHumidity"

Variable name in ODM2 controlled vocabulary; "relativeHumidity".


#define AM2315_HUMIDITY_UNIT_NAME = "percent"

Variable unit name in ODM2 controlled vocabulary; "percent" (percent relative humidity)


#define AM2315_HUMIDITY_DEFAULT_CODE = "AM2315Humidity"

Default variable short code; "AM2315Humidity".


#define AM2315_TEMP_RESOLUTION = 1

Decimals places in string representation; temperature should have 1. (0.1°C for the 16 bit sensor)


#define AM2315_TEMP_VAR_NUM = 1

Sensor variable number; temperature is stored in sensorValues[1].


#define AM2315_TEMP_VAR_NAME = "temperature"

Variable name in ODM2 controlled vocabulary; "temperature".


#define AM2315_TEMP_UNIT_NAME = "degreeCelsius"

Variable unit name in ODM2 controlled vocabulary; "degreeCelsius" (°C)


#define AM2315_TEMP_DEFAULT_CODE = "AM2315Temp"

Default variable short code; "AM2315Temp".