Code example using the Sensirion SCD30 CO2 sensor module

Dependencies:   mbed scd30

Files at this revision

API Documentation at this revision

Comitter:
loopsva
Date:
Thu Sep 13 17:43:17 2018 +0000
Parent:
0:e4e96ef907b2
Commit message:
Changed the way the data structure was handled in the SCD30

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
scd30.lib Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Mon Sep 10 18:13:03 2018 +0000
+++ b/main.cpp	Thu Sep 13 17:43:17 2018 +0000
@@ -13,7 +13,6 @@
 RawSerial pc(USBTX, USBRX);
 
 scd30 scd(SDA0, SCL0, 400000);                 //Microchip real time clock
-scd30::SCD30_str scdSTR = {}; 
 
 //-----------------------------------------------------------------------------
 // initial splash display
@@ -30,9 +29,9 @@
     pc.printf("Initializing SCD30...\r\n");
     scd.softReset();
     wait_ms(2000);
-    scd.getSerialNumber(scdSTR);
+    scd.getSerialNumber();
     pc.printf(" - SCD30 s/n: ");
-    for(int i = 0; i < sizeof(scdSTR.sn); i++) pc.printf("%c", scdSTR.sn[i]);
+    for(int i = 0; i < sizeof(scd.scdSTR.sn); i++) pc.printf("%c", scd.scdSTR.sn[i]);
     pc.printf("\r\n");
         
     scd.setMeasInterval(5);
@@ -56,15 +55,15 @@
     while(1) {
         gled = !gled;
         wait_ms(250);
-        scd.getReadyStatus(scdSTR);
-        uint16_t redy = scdSTR.ready;
+        scd.getReadyStatus();
+        uint16_t redy = scd.scdSTR.ready;
         if(redy == scd30::SCDisReady) {
-            uint8_t crcc = scd.readMeasurement(scdSTR);
+            uint8_t crcc = scd.readMeasurement();
             count++;
             if(crcc != scd30::SCDnoERROR) pc.printf("ERROR: %d\r\n", crcc);
             else pc.printf("%5d  -> CO2: %9.3f   Temp: %7.3f   Hum: %5.2f\r\n", 
-                            count, scdSTR.co2f, scdSTR.tempf, scdSTR.humf);
-            if((int)scdSTR.co2f > 10000) initSCD30();
+                            count, scd.scdSTR.co2f, scd.scdSTR.tempf, scd.scdSTR.humf);
+            if((int)scd.scdSTR.co2f > 10000) initSCD30();
         }
     }
 }
\ No newline at end of file
--- a/scd30.lib	Mon Sep 10 18:13:03 2018 +0000
+++ b/scd30.lib	Thu Sep 13 17:43:17 2018 +0000
@@ -1,1 +1,1 @@
-https://os.mbed.com/users/loopsva/code/scd30/#2a16832400d0
+https://os.mbed.com/users/loopsva/code/scd30/#24bb922e179c