2021-01-29 06:31:58 -05:00
|
|
|
//
|
|
|
|
// FILE: AM2322_plotter.ino
|
|
|
|
// AUTHOR: Rob Tillaart
|
2021-02-03 11:20:20 -05:00
|
|
|
// VERSION: 0.1.1
|
2021-01-29 06:31:58 -05:00
|
|
|
// PURPOSE: demo sketch for AM2322 I2C humidity & temperature sensor
|
|
|
|
//
|
|
|
|
// HISTORY:
|
2021-10-19 05:51:07 -04:00
|
|
|
// 0.1.0 2020-09-01 simple program to dump for plotter.
|
2021-02-03 11:20:20 -05:00
|
|
|
// 0.1.1 2021-01-28 added begin() ++
|
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
//
|
|
|
|
// Bottom view
|
|
|
|
// +---+
|
|
|
|
// VDD |o |
|
|
|
|
// SDA |o |
|
|
|
|
// GND |o |
|
|
|
|
// SCL |o |
|
|
|
|
// +---+
|
|
|
|
//
|
|
|
|
// do not forget pull up resistors between SDA, SCL and VDD.
|
|
|
|
|
2021-02-03 11:20:20 -05:00
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
#include <AM232X.h>
|
|
|
|
|
|
|
|
AM232X AM2322;
|
|
|
|
|
2021-02-03 11:20:20 -05:00
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
void setup()
|
|
|
|
{
|
|
|
|
Serial.begin(115200);
|
2021-02-03 11:20:20 -05:00
|
|
|
|
|
|
|
if (! AM2322.begin() )
|
|
|
|
{
|
|
|
|
Serial.println("Sensor not found");
|
|
|
|
while (1);
|
|
|
|
}
|
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
Serial.println("Humidity(%),\tTemperature(C)");
|
|
|
|
}
|
|
|
|
|
2021-02-03 11:20:20 -05:00
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
void loop()
|
|
|
|
{
|
|
|
|
AM2322.read();
|
|
|
|
Serial.print(AM2322.getHumidity(), 1);
|
|
|
|
Serial.print(",\t");
|
|
|
|
Serial.println(AM2322.getTemperature(), 1);
|
|
|
|
|
|
|
|
delay(100);
|
|
|
|
}
|
|
|
|
|
2021-12-11 13:15:19 -05:00
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
// -- END OF FILE --
|