Condensation Monitor Measure the current environment condition at outside and inside and make caution or warnings related to condensation. Support UART over BLE. It works with nRF Toolbox. 結露モニタ 屋内外の環境情報を計測し、結露に関する警告あるいは注意を出力します。 nRF Toolboxと一緒に動作し、UART機能でBLE経由でメッセージを出力します。 ドキュメント https://developer.mbed.org/users/takafuminaka/notebook/information-about-my-condensation-monitor-for-mbed/
Dependencies: AQM0802 BME280 HDC1000 VaporCondition mbed BLE_API nRF51822 BLE_Condensation_Monitor
Dependents: BLE_Condensation_Monitor
Fork of Condensation_Monitor by
Revision 7:7cecec859fe1, committed 2015-06-14
- Comitter:
- takafuminaka
- Date:
- Sun Jun 14 09:13:40 2015 +0000
- Parent:
- 6:3c2404870d39
- Child:
- 8:f2b32f6b161c
- Commit message:
- Internal Sensor is selectable BME280 or HDC1000 by INSIDE_SENSOR defitinion.
;
;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sun May 31 11:11:48 2015 +0000 +++ b/main.cpp Sun Jun 14 09:13:40 2015 +0000 @@ -19,6 +19,12 @@ #define NEED_BLE_CONSOLE 1 #define NEED_LCD_OUTPUT 1 +#define TYPE_HDC1000 1 +#define TYPE_BME280 2 + +// #define INSIDE_SENSOR TYPE_HDC1000 +#define INSIDE_SENSOR TYPE_BME280 + #if NEED_CONSOLE_OUTPUT Serial pc(USBTX, USBRX); #define PC(...) { pc.printf(__VA_ARGS__); } @@ -42,8 +48,14 @@ // BME280 sensor(I2C_SDA0, I2C_SCL0, 0x76 << 1); #endif -BME280 bme280(I2C_SDA0, I2C_SCL0, 0x76 << 1); -HDC1000 hdc1000(i2c); +BME280 sensor_out(I2C_SDA0, I2C_SCL0, 0x76 << 1); + +#if INSIDE_SENSOR == TYPE_HDC1000 +HDC1000 sensor_in(i2c); +#elif INSIDE_SENSOR == TYPE_BME280 +BME280 sensor_in(I2C_SDA0, I2C_SCL0, 0x77 << 1); +#endif + #if NEED_LCD_OUTPUT AQM0802 lcd(i2c); #endif @@ -71,10 +83,10 @@ int cautions = 0; int warnings = 0; int warn_wid = 20; - char msg1[10],msg2[9]; + char msg1[10],msg2[10]; int mode=0; int skip=0; - char msg[4][2][9]; + char msg[4][2][10]; char bmsg[4][20]; int skipf[4]; @@ -100,7 +112,7 @@ led1 = 0; led2 = 0; - // i2c.frequency(100000); + i2c.frequency(100000); #if NEED_BLE_CONSOLE // Setup BLE // @@ -125,17 +137,25 @@ if ( skipped == 0 ) { // Get data - Outside.t = bme280.getTemperature(); - Outside.h = bme280.getHumidity(); + Outside.t = sensor_out.getTemperature(); + Outside.h = sensor_out.getHumidity(); - Outside.p = bme280.getPressure(); - Inside.p = bme280.getPressure(); // Usually Pressures are same between inside and outside. + Outside.p = sensor_out.getPressure(); - Inside.t = float(hdc1000.temperature())/0x10000*165-40; - Inside.h = float(hdc1000.humidity())/0x10000*100; +#if INSIDE_SENSOR == TYPE_HDC1000 + Inside.p = sensor_out.getPressure(); // Usually Pressures are same between inside and outside. + Inside.t = float(sensor_in.temperature())/0x10000*165-40; + Inside.h = float(sensor_in.humidity())/0x10000*100; + PC("In: %2.2f degC, %2.2f %%\r\n", Inside.t, Inside.h); +#elif INSIDE_SENSOR == TYPE_BME280 + Inside.t = sensor_in.getTemperature(); + Inside.h = sensor_in.getHumidity(); + Inside.p = sensor_in.getPressure(); + PC("In: %2.2f degC, %2.2f %%, %04.2f hPa\r\n", Inside.t, Inside.h, Inside.p); +#endif + PC("Out: %2.2f degC, %2.2f %%, %04.2f hPa\r\n", Outside.t, Outside.h, Outside.p); - PC("In: %2.2f degC, %2.2f %% Out: %2.2f degC, %2.2f %%, %04.2f hPa\r\n", Inside.t, Inside.h, Outside.t, Outside.h, Outside.p); PC("Humidity Ratio [g/kg] : In %2.2f Out %2.2f \r\n", Inside.Rh(), Outside.Rh()); Tdp_o = Outside.Tdp(); Tdp_i = Inside.Tdp(); @@ -177,7 +197,7 @@ if ( Tdp >= Tcur - warn_wid ) { skipf[ii] = 0; if ( Tdp >= Tcur ) { - PC("Condensation at %s\r\n",sTcur); + PC("Condensation at %s %s\r\n",sTcur,sWin); sprintf(msg[ii][0],"Condns!!"); sprintf(msg[ii][1],"%s%s",ssTcur,ssWin); sprintf(bmsg[ii],"Cond. at %s",bsWin); @@ -230,20 +250,30 @@ case (3): sprintf(msg1,"Po%6.2f",Outside.p); sprintf(msg2," [hPa]"); - BLEC("Press. %6.2fhPa\n",Outside.p); + BLEC("Prs.Out%6.2fhPa\n",Outside.p); break; case (4): +#if INSIDE_SENSOR == TYPE_BME280 + sprintf(msg1,"Pi%6.2f",Inside.p); + sprintf(msg2," [hPa]"); + BLEC("Prs.In %6.2fhPa\n",Inside.p); +#elif INSIDE_SENSOR == TYPE_HDC1000 + skip = 1; +#endif + break; + + case (5): sprintf(msg1,"Dpi%4.1fC",Tdp_i); sprintf(msg2,"Dpo%4.1fC",Tdp_o); BLEC("DP. In%4.1f Out%4.1f\n",Tdp_i, Tdp_o); break; - case (5): case (6): case (7): case (8): - int ii = mode - 5; + case (9): + int ii = mode - 6; skip = skipf[ii]; sprintf(msg1,"%8s",msg[ii][0]); sprintf(msg2,"%8s",msg[ii][1]); @@ -251,7 +281,7 @@ break; } mode++; - if ( mode > 8 ) { + if ( mode > 9 ) { mode = 0; }