mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
Added examples for AM232X lib
This commit is contained in:
parent
858ab7ffaf
commit
10ea22c7ba
57
libraries/AM232X/examples/AM2320/AM2320.ino
Normal file
57
libraries/AM232X/examples/AM2320/AM2320.ino
Normal file
@ -0,0 +1,57 @@
|
||||
//
|
||||
// FILE: AM2320.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.0
|
||||
// PURPOSE: AM2320 demo sketch for AM2320 I2C humidity & temperature sensor
|
||||
//
|
||||
// HISTORY:
|
||||
// 0.1.0 - 2017-12-11 initial version
|
||||
//
|
||||
// Released to the public domain
|
||||
//
|
||||
|
||||
#include <AM232X.h>
|
||||
|
||||
AM232X AM2320;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Wire.begin();
|
||||
|
||||
Serial.begin(115200);
|
||||
Serial.println(__FILE__);
|
||||
Serial.print("LIBRARY VERSION: ");
|
||||
Serial.println(AM232X_LIB_VERSION);
|
||||
Serial.println();
|
||||
|
||||
Serial.println("Type,\tStatus,\tHumidity (%),\tTemperature (C)");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// READ DATA
|
||||
Serial.print("AM232X, \t");
|
||||
int status = AM2320.read();
|
||||
switch (status)
|
||||
{
|
||||
case AM232X_OK:
|
||||
Serial.print("OK,\t");
|
||||
break;
|
||||
case AM232X_MISSING_BYTES:
|
||||
Serial.print("Missing Bytes,\t");
|
||||
break;
|
||||
default:
|
||||
Serial.print("Unknown error,\t");
|
||||
break;
|
||||
}
|
||||
// DISPLAY DATA, sensor only returns one decimal.
|
||||
Serial.print(AM2320.humidity, 1);
|
||||
Serial.print(",\t");
|
||||
Serial.println(AM2320.temperature, 1);
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
//
|
||||
// END OF FILE
|
||||
//
|
58
libraries/AM232X/examples/AM2320_test/AM2320_test.ino
Normal file
58
libraries/AM232X/examples/AM2320_test/AM2320_test.ino
Normal file
@ -0,0 +1,58 @@
|
||||
//
|
||||
// FILE: AM2320_test.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.0
|
||||
// PURPOSE: demo sketch for AM2320 I2C humidity & temperature sensor
|
||||
//
|
||||
// HISTORY:
|
||||
// 0.1.0 - 2017-12-11 initial version
|
||||
//
|
||||
// Released to the public domain
|
||||
//
|
||||
|
||||
#include <AM232X.h>
|
||||
|
||||
AM232X AM2320;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Wire.begin();
|
||||
|
||||
Serial.begin(115200);
|
||||
Serial.println(__FILE__);
|
||||
Serial.print("LIBRARY VERSION: ");
|
||||
Serial.println(AM232X_LIB_VERSION);
|
||||
Serial.println();
|
||||
|
||||
AM2320.read();
|
||||
|
||||
// sensor only returns one decimal.
|
||||
Serial.print("Temp:\t");
|
||||
Serial.println(AM2320.temperature, 1);
|
||||
Serial.print("Hum:\t");
|
||||
Serial.println(AM2320.humidity, 1);
|
||||
|
||||
Serial.print("Model:\t");
|
||||
Serial.println(AM2320.getModel());
|
||||
Serial.print("Version:\t");
|
||||
Serial.println(AM2320.getVersion());
|
||||
Serial.print("DevId:\t");
|
||||
Serial.println(AM2320.getDeviceID());
|
||||
|
||||
Serial.print("Status:\t");
|
||||
Serial.println(AM2320.getStatus());
|
||||
Serial.print("UserA:\t");
|
||||
Serial.println(AM2320.getUserRegisterA());
|
||||
Serial.print("UserB:\t");
|
||||
Serial.println(AM2320.getUserRegisterB());
|
||||
|
||||
Serial.println("done...");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// END OF FILE
|
||||
//
|
57
libraries/AM232X/examples/AM2322/AM2322.ino
Normal file
57
libraries/AM232X/examples/AM2322/AM2322.ino
Normal file
@ -0,0 +1,57 @@
|
||||
//
|
||||
// FILE: AM2322.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.0
|
||||
// PURPOSE: demo sketch for AM2322 I2C humidity & temperature sensor
|
||||
//
|
||||
// HISTORY:
|
||||
// 0.1.0 - 2017-12-11 initial version
|
||||
//
|
||||
// Released to the public domain
|
||||
//
|
||||
|
||||
#include <AM232X.h>
|
||||
|
||||
AM232X AM2322;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Wire.begin();
|
||||
|
||||
Serial.begin(115200);
|
||||
Serial.println(__FILE__);
|
||||
Serial.print("LIBRARY VERSION: ");
|
||||
Serial.println(AM232X_LIB_VERSION);
|
||||
Serial.println();
|
||||
|
||||
Serial.println("Type,\tStatus,\tHumidity (%),\tTemperature (C)");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// READ DATA
|
||||
Serial.print("AM232X, \t");
|
||||
int status = AM2322.read();
|
||||
switch (status)
|
||||
{
|
||||
case AM232X_OK:
|
||||
Serial.print("OK,\t");
|
||||
break;
|
||||
case AM232X_MISSING_BYTES:
|
||||
Serial.print("Missing Bytes,\t");
|
||||
break;
|
||||
default:
|
||||
Serial.print("Unknown error,\t");
|
||||
break;
|
||||
}
|
||||
// DISPLAY DATA, sensor only returns one decimal.
|
||||
Serial.print(AM2322.humidity, 1);
|
||||
Serial.print(",\t");
|
||||
Serial.println(AM2322.temperature, 1);
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
//
|
||||
// END OF FILE
|
||||
//
|
Loading…
Reference in New Issue
Block a user