Test program for SPS30

Dependencies:   SPS30-sensor

main.cpp

Committer:
ziqiyap
Date:
2019-01-25
Revision:
1:6a9693f310f7
Parent:
0:732c556ef648
Child:
2:225c3f2a2a8a

File content as of revision 1:6a9693f310f7:

#include <string>
#include "mbed.h"
#include "src/sensor_driver.h"

using namespace std;

Serial pc(SERIAL_TX, SERIAL_RX);

int main()
{
    pc.printf("Hello World\r\n");
    int count = 0;
    while(1)
    {
        #ifdef SCD30
        string co2val = "-------";
        string tempval = "-----";
        string humval = "-----";
        
        int rdy = readySCD30();
        int setchk = setSCDparam();
        int datchk = readSCDmeas();
        
        pc.printf(" = %d  \r", datchk);
        
        if (datchk == 2)
        {
            co2val = getSCDco2();
            tempval = getSCDtemp();
            humval = getSCDhum();
        }
        
        if (rdy != 0) pc.printf("SCD30 not connected\r\n");
        if (setchk != 5) pc.printf(" Problem setting parameters..     Settings unchanged\r\n");
        pc.printf("count: %4d  |  CO2: %s ppm  |  Temp: %s C  |  Hum: %s % \r\n", count, co2val, tempval, humval);
        #endif
        wait(2);
        count++;
    }
}