GY-63_MS5611/libraries/Cozir/examples/Cozir_getVersion/Cozir_getVersion.ino

70 lines
1.2 KiB
Arduino
Raw Normal View History

2021-02-03 11:20:20 -05:00
//
// FILE: Cozir_getVersion.ino
// AUTHOR: Rob Tillaart
2022-02-21 13:40:59 -05:00
// PURPOSE: demo of Cozir lib
// URL: https://github.com/RobTillaart/Cozir
2021-02-03 11:20:20 -05:00
//
// Note: this sketch needs a MEGA or a Teensy that supports a second
// Serial port named Serial1
2022-03-04 09:07:12 -05:00
2022-02-21 13:40:59 -05:00
#include "Arduino.h"
2021-02-03 11:20:20 -05:00
#include "cozir.h"
2022-03-04 09:07:12 -05:00
2021-02-03 11:20:20 -05:00
COZIR czr(&Serial1);
2021-12-14 13:05:30 -05:00
2021-02-03 11:20:20 -05:00
void setup()
{
Serial1.begin(9600);
czr.init();
2022-02-21 13:40:59 -05:00
2021-02-03 11:20:20 -05:00
Serial.begin(115200);
2022-02-21 13:40:59 -05:00
Serial.print("COZIR_LIB_VERSION: ");
2021-02-03 11:20:20 -05:00
Serial.println(COZIR_LIB_VERSION);
Serial.println();
delay(100);
2021-08-15 13:38:45 -04:00
czr.getVersionSerial();
2021-02-03 11:20:20 -05:00
delay(5);
while (Serial1.available())
{
Serial.write(Serial1.read());
}
delay(100);
2021-08-15 13:38:45 -04:00
czr.getConfiguration();
2021-02-03 11:20:20 -05:00
delay(5);
while (Serial1.available())
{
Serial.write(Serial1.read());
}
delay(1000);
2022-02-21 13:40:59 -05:00
// set to polling explicitly.
2021-08-15 13:38:45 -04:00
czr.setOperatingMode(CZR_POLLING);
2022-02-21 13:40:59 -05:00
delay(1000);
2021-02-03 11:20:20 -05:00
}
2021-12-14 13:05:30 -05:00
2021-02-03 11:20:20 -05:00
void loop()
{
2021-08-15 13:38:45 -04:00
float t = czr.celsius();
float f = czr.fahrenheit();
float h = czr.humidity();
2021-02-03 11:20:20 -05:00
uint32_t c = czr.CO2();
2022-02-21 13:40:59 -05:00
Serial.print("Celsius =\t"); Serial.println(t);
2021-02-03 11:20:20 -05:00
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);
}
2021-12-14 13:05:30 -05:00
2021-02-03 11:20:20 -05:00
// -- END OF FILE --
2021-12-14 13:05:30 -05:00