Working eCO2 and TVOC sensor

Dependencies:   CCS811

Files at this revision

API Documentation at this revision

Comitter:
andcor02
Date:
Wed Sep 13 15:32:30 2017 +0000
Child:
1:ea90319c0b28
Commit message:
Actually works!

Changed in this revision

.gitignore Show annotated file Show diff for this revision Revisions of this file
CCS811.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.gitignore	Wed Sep 13 15:32:30 2017 +0000
@@ -0,0 +1,4 @@
+.build
+.mbed
+projectfiles
+*.py*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CCS811.lib	Wed Sep 13 15:32:30 2017 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/andcor02/code/CCS811/#4acc5b63a984
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Sep 13 15:32:30 2017 +0000
@@ -0,0 +1,43 @@
+#include "mbed.h"
+#include "CCS811.h"
+
+
+
+Serial pc(USBTX, USBRX);
+
+#ifdef TARGET_K64F
+I2C i2c(I2C_SDA, I2C_SCL);
+#endif
+#ifdef TARGET_UBLOX_EVK_ODIN_W2
+I2C i2c(PF_0, PF_1);
+#endif
+
+
+
+CCS811 ccs811(&i2c);
+
+uint16_t eco2, tvoc;
+
+
+void CCS811Callback(void)
+{
+
+    ccs811.readData(&eco2, &tvoc);
+
+    pc.printf("eCO2 reading :%dppm, TVOC reading :%dppb\r\n", eco2, tvoc);
+
+}
+
+
+int main()
+{
+    ccs811.init();
+    wait(1);
+
+    while(1) {
+//        ccs811.readstatus(); //0x90 reports everything working, 0x98 measurement ready to be used
+        wait(1);
+        CCS811Callback();
+        wait(1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Wed Sep 13 15:32:30 2017 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#7b428916f5b35da28a1b18e2c149c1115bb89d92