mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
70 lines
1.2 KiB
C++
70 lines
1.2 KiB
C++
//
|
|
// FILE: Cozir_getVersion.ino
|
|
// AUTHOR: Rob Tillaart
|
|
// VERSION: 0.1.0
|
|
// PURPOSE: demo of Cozir lib (>= 0.1.06)
|
|
// DATE: 2021-01-31
|
|
// URL: http://forum.arduino.cc/index.php?topic=91467.0
|
|
//
|
|
|
|
// Note: this sketch needs a MEGA or a Teensy that supports a second
|
|
// Serial port named Serial1
|
|
|
|
|
|
#include "cozir.h"
|
|
|
|
COZIR czr(&Serial1);
|
|
|
|
|
|
void setup()
|
|
{
|
|
Serial1.begin(9600);
|
|
czr.init();
|
|
|
|
Serial.begin(115200);
|
|
Serial.print("Cozir HardwareSerial: ");
|
|
Serial.println(COZIR_LIB_VERSION);
|
|
Serial.println();
|
|
|
|
delay(100);
|
|
czr.getVersionSerial();
|
|
delay(5);
|
|
while (Serial1.available())
|
|
{
|
|
Serial.write(Serial1.read());
|
|
}
|
|
delay(100);
|
|
|
|
czr.getConfiguration();
|
|
delay(5);
|
|
while (Serial1.available())
|
|
{
|
|
Serial.write(Serial1.read());
|
|
}
|
|
delay(1000);
|
|
|
|
// reset to polling again.
|
|
czr.setOperatingMode(CZR_POLLING);
|
|
}
|
|
|
|
|
|
void loop()
|
|
{
|
|
float t = czr.celsius();
|
|
float f = czr.fahrenheit();
|
|
float h = czr.humidity();
|
|
uint32_t c = czr.CO2();
|
|
|
|
Serial.print("Celcius =\t"); Serial.println(t);
|
|
Serial.print("Fahrenheit =\t"); Serial.println(f);
|
|
Serial.print("Humidity =\t"); Serial.println(h);
|
|
Serial.print("CO2 =\t"); Serial.println(c);
|
|
Serial.println();
|
|
|
|
delay(3000);
|
|
}
|
|
|
|
|
|
// -- END OF FILE --
|
|
|