Test firmware for the Supermote hardware.
Dependencies: K30_I2C libxDot-mbed5
Fork of K30_I2C_Program by
Diff: main.cpp
- Revision:
- 3:2ab969b31f6b
- Parent:
- 2:680fc2690d10
--- a/main.cpp Fri Sep 07 02:54:05 2018 +0000 +++ b/main.cpp Fri Sep 14 03:17:31 2018 +0000 @@ -2,9 +2,9 @@ #include "mDot.h" #include "ChannelPlans.h" -//#define TEST_HPM // particle +//#define TEST_HPM // PM2.5 / PM10 //#define TEST_MICS_VZ_89TE // voc -#define TEST_SPEC_3SP_CO // CO +//#define TEST_SPEC_3SP_CO // CO #define TEST_K30 // CO2 sensor #ifdef TEST_HPM @@ -27,7 +27,6 @@ mDot* dot = NULL; Serial pc (USBTX, USBRX); // xDot USB interface Serial device (UART_TX, UART_RX); // xDot UART to sensors -bool need5v = false; #ifdef TEST_HPM HPM hpm = HPM::HPM(&device, &pc); @@ -47,7 +46,7 @@ #endif #ifdef TEST_K30 - K30_I2C k30(I2C_SDA, I2C_SCL, 0x68<<1); // xDot dev board + K30_I2C k30(I2C_SDA, I2C_SCL, 0x68<<1); int co2 = 0; #endif @@ -75,15 +74,11 @@ pc.printf("done\r\n"); } -int main (){ - +int main () +{ // Initialising blueLED = true; orangeLED = false; - - //lora::ChannelPlan * plan = new lora::ChannelPlan_AS923(); - //dot = mDot::getInstance(plan); - //dot->setAdr(true); pc.baud(57600); // start debug port pc.printf("************************\r\n"); @@ -93,7 +88,16 @@ #ifdef TEST_HPM turnOn5v(); - b_response = hpm.init(); + do { + b_response = hpm.init(); + if (!b_response) + { + pc.printf("Initialisation of PM sensor failed\r\n"); + wait(1.0); + } + } while (!b_response); + pc.printf("Initialisation of PM sensor success\r\n"); + #endif #ifdef TEST_MICS_VZ_89TE @@ -126,7 +130,7 @@ b_response = hpm.read_measurement(PM25, PM10); if (b_response) { - pc.printf ("PM2.5 = %d ug/m3, PM10 = %d ug/m3\r\n", PM25, PM10); + pc.printf ("PM2.5 = %d ug/m3, PM10 = %d ug/m3\r", PM25, PM10); } else { @@ -149,8 +153,7 @@ #endif #ifdef TEST_K30 - int rc_check; - rc_check = k30.readCO2(co2); + int rc_check = k30.readCO2(co2); if (rc_check) pc.printf("K30 CO2:%d ppm\r\n",co2); else