GY-63_MS5611/libraries/AM232X/examples/AM2322/AM2322.ino

69 lines
1.3 KiB
Arduino
Raw Normal View History

2017-12-12 07:23:41 -05:00
//
// FILE: AM2322.ino
// AUTHOR: Rob Tillaart
// PURPOSE: demo sketch for AM2322 I2C humidity & temperature sensor
//
2022-01-06 08:05:38 -05:00
// AM232X PIN layout AM2315 COLOR
// ============================================
// bottom view DESCRIPTION COLOR
2021-01-29 06:31:58 -05:00
// +---+
2022-01-06 08:05:38 -05:00
// |o | VDD RED
// |o | SDA YELLOW
// |o | GND BLACK
// |o | SCL GREY
2021-01-29 06:31:58 -05:00
// +---+
//
// do not forget pull up resistors between SDA, SCL and VDD.
2021-02-03 11:20:20 -05:00
2022-01-06 08:05:38 -05:00
#include "AM232X.h"
2017-12-12 07:23:41 -05:00
AM232X AM2322;
2021-02-03 11:20:20 -05:00
2017-12-12 07:23:41 -05:00
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("LIBRARY VERSION: ");
Serial.println(AM232X_LIB_VERSION);
Serial.println();
2021-02-03 11:20:20 -05:00
if (! AM2322.begin() )
{
Serial.println("Sensor not found");
while (1);
}
2022-01-06 08:05:38 -05:00
AM2322.wakeUp();
delay(2000);
2021-02-03 11:20:20 -05:00
2017-12-12 07:23:41 -05:00
Serial.println("Type,\tStatus,\tHumidity (%),\tTemperature (C)");
}
2021-02-03 11:20:20 -05:00
2017-12-12 07:23:41 -05:00
void loop()
{
// READ DATA
2017-12-12 10:43:02 -05:00
Serial.print("AM2322, \t");
2017-12-12 07:23:41 -05:00
int status = AM2322.read();
switch (status)
{
case AM232X_OK:
Serial.print("OK,\t");
break;
default:
Serial.print(status);
Serial.print("\t");
2017-12-12 07:23:41 -05:00
break;
}
// DISPLAY DATA, sensor only returns one decimal.
Serial.print(AM2322.getHumidity(), 1);
2017-12-12 07:23:41 -05:00
Serial.print(",\t");
Serial.println(AM2322.getTemperature(), 1);
2017-12-12 07:23:41 -05:00
delay(2000);
}
2021-12-11 13:15:19 -05:00
// -- END OF FILE --