GY-63_MS5611/libraries/MTP40C/examples/MTP40C_getCO2/MTP40C_getCO2.ino

64 lines
1.1 KiB
Arduino
Raw Normal View History

2021-08-23 13:33:25 -04:00
//
// FILE: MTP40C_getCO2.ino
// AUTHOR: Rob Tillaart
// PURPOSE: demo of MTP40C library
// DATE: 2021-08-21
// URL: https://github.com/RobTillaart/MTP40C
//
2021-12-22 05:36:50 -05:00
// any board that support two or more hardware serial ports
2021-08-23 13:33:25 -04:00
// Serial and Serial1, e.g. for MEGA, LEONARDO, MICRO, ESP32,ESP8266
// Uno, Nano or Mini will fail to compile.
#include "MTP40C.h"
2021-09-02 01:40:38 -04:00
#include "SoftwareSerial.h"
2021-08-23 13:33:25 -04:00
2021-09-02 01:40:38 -04:00
SoftwareSerial sws(6, 7);
MTP40C mtp(&sws);
// MTP40C mtp(&Serial1);
2021-08-23 13:33:25 -04:00
int lines = 10;
void setup()
{
2021-09-02 01:40:38 -04:00
Serial.begin(115200);
2021-08-23 13:33:25 -04:00
// Serial.println(__FILE__);
2021-09-02 01:40:38 -04:00
// Serial.print("MTP40_LIB_VERSION:\t");
// Serial.println(MTP40_LIB_VERSION);
2021-08-23 13:33:25 -04:00
2021-09-02 01:40:38 -04:00
sws.begin(19200);
2021-08-23 13:33:25 -04:00
mtp.begin(); // default 0x64
// if (mtp.begin() == false)
// {
// Serial.println("could not connect!");
// while(1);
// }
}
void loop()
{
if (lines == 10)
{
lines = 0;
Serial.println("\nTIME\tCO2 LEVEL");
}
if (millis() - mtp.lastRead() >= 5000)
{
Serial.print(millis());
Serial.print("\t");
Serial.print(mtp.getGasConcentration());
Serial.println();
lines++;
}
}
// -- END OF FILE --
2021-12-22 05:36:50 -05:00