uses BBC micro:bit to measure and display indoor air quality using Bosch BME680 and/or Sensirion SGP30

Dependencies:   microbit

uses Bosch BME680 and/or Sensirion SGP30 sensors to measure indor air quality

sensors should be connected to BBC micro:bit using i2c

commands are received and data is being sent using uBit / nordic radio protocol

display ---

last line always indicates: - first dot: bme680 detected - second dot: sgp30 detected - third dot: sgp 30 setting humidity/temperature - fourth dor: sgp30 measuring - fith dot: bme680 measuring

the detect dots should be in a stable state (not blinking) the measuring dots should be blinking (constant light means: measurement failed)

if only one bme680 is present: - first 3 lines indicate gas resistence (air quality / more dots == worse quality) - fourth line indicates humidity level

if only sgp30 is present: - first two lines indicate SGP30 VOC level - third and fourth line indicate sgp30 CO2 level

if both sensors are present: - first line indicates SGP30 VOC level - second line line indicates sgp30 CO2 level - third line indicates bme680 gas resistence (air quality) - fourth line indicates bme 680 humidity level

buttons - B display state, switches betweeen - full bright - low light - display off

AB reset sgp30 baseline in non volatile storage

data logging -- during measurements the minimum and mximum values for each measured value (temperature, air pressure, humidity,gas resistance, VOC, CO2) are being stored in non volatile storage those (and the last measurement results) are being shown when btn A has been pressed

Revision:
15:8bb5c580d453
Parent:
6:fc6f2f08724b
Child:
42:ce269f988ac8
--- a/SGP30/sgp30.cpp	Wed Dec 05 10:50:53 2018 +0000
+++ b/SGP30/sgp30.cpp	Wed Dec 05 10:58:19 2018 +0000
@@ -42,7 +42,7 @@
   return true;
 }
 
-bool Sgp30::IAQmeasure(void) {
+bool Sgp30::IAQmeasure() {
     uint8_t command[2];
     command[0] = 0x20;
     command[1] = 0x08;
@@ -55,7 +55,7 @@
     return true;
 }
 
-bool Sgp30::test(void) {
+bool Sgp30::test() {
     uint8_t command[2];
     command[0] = 0x20;
     command[1] = 0x32;
@@ -66,18 +66,18 @@
     
     return reply==0xD400;
 }
-bool Sgp30::setHumidity(uint32_t rel_humidity, uint32_t temperature) {
+bool Sgp30::setHumidity(const uint32_t rel_humidity, const uint32_t temperature) {
     return setHumidity(Physics::absHumidity(rel_humidity, temperature));
 }
 
-bool Sgp30::IAQinit(void) {
+bool Sgp30::IAQinit() {
   uint8_t command[2];
   command[0] = 0x20;
   command[1] = 0x03;
   return readWordFromCommand(command, 2, 10);
 }
 
-bool Sgp30::setHumidity(uint32_t absolute_humidity) {
+bool Sgp30::setHumidity(const uint32_t absolute_humidity) {
   if (absolute_humidity > 256000) {
     return false;
   }
@@ -102,7 +102,7 @@
   }
 }
 
-bool Sgp30::readWordFromCommand(uint8_t command[], uint8_t commandLength, uint16_t delayms, uint16_t *readdata, uint8_t readlen)
+bool Sgp30::readWordFromCommand(const uint8_t command[], const uint8_t commandLength, const uint16_t delayms, uint16_t *readdata, const uint8_t readlen)
 {
     if (_callbacks->write(_i2caddr, command, commandLength) != MICROBIT_OK) {
         return false;
@@ -132,7 +132,7 @@
     return true;
 }
 
-uint8_t Sgp30::generateCRC(uint8_t *data, uint8_t datalen) {
+uint8_t Sgp30::generateCRC(const uint8_t *data, const uint8_t datalen) {
   // calculates 8-Bit checksum with given polynomial
   uint8_t crc = SGP30_CRC8_INIT;