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 4:3075954b341c, committed 2015-05-31
- Comitter:
- takafuminaka
- Date:
- Sun May 31 06:39:09 2015 +0000
- Parent:
- 3:8f886f74f9bb
- Child:
- 5:06d988a47721
- Commit message:
- Added Local Display Support for AQM0802 (8x2 LCD); https://www.switch-science.com/catalog/1405/ etc.; ; ;
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/AQM0802.lib Sun May 31 06:39:09 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/yasuyuki/code/AQM0802/#6fa303916aa8
--- a/main.cpp Mon May 18 23:07:11 2015 +0000 +++ b/main.cpp Sun May 31 06:39:09 2015 +0000 @@ -11,9 +11,12 @@ #include "mbed.h" #include "HDC1000.h" #include "BME280.h" +#include "AQM0802.h" + #include "VaporCondition.h" #define NEED_CONSOLE_OUTPUT 1 +#define NEED_LCD_OUTPUT 1 #if NEED_CONSOLE_OUTPUT Serial pc(USBTX, USBRX); @@ -33,24 +36,40 @@ BME280 bme280(I2C_SDA0, I2C_SCL0, 0x76 << 1); HDC1000 hdc1000(i2c); +#if NEED_LCD_OUTPUT + AQM0802 lcd(i2c); +#endif DigitalOut led1(LED1); DigitalOut led2(LED2); + int main() { - float Tdp_o; - float Tdp_i; - int cautions; - int warnings; + float Tdp_o =0.; + float Tdp_i =0.; + int cautions = 0; + int warnings = 0; int warn_wid = 20; + char msg1[10],msg2[9]; + int mode=0; + int skip=0; + char msg[4][2][9]; + int skipf[4]; + float Tcur; + float Tdp; + char *sTcur; + char *sWin; + char *ssTcur; + char *ssWin; + VaporCondition Inside; VaporCondition Outside; // LED Check led1 = 1; led2 = 1; - wait(10); + wait(3); led1 = 0; led2 = 0; @@ -58,6 +77,7 @@ // i2c.frequency(100000); while(1) { + // Get data Outside.t = bme280.getTemperature(); Outside.h = bme280.getHumidity(); @@ -68,86 +88,128 @@ Inside.t = float(hdc1000.temperature())/0x10000*165-40; Inside.h = float(hdc1000.humidity())/0x10000*100; -// PC("%2.2f degC, %2.2f %%\r\n", t, h); - +// PC("%2.2f degC, %2.2f %%\r\n", t, h); + 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(); - PC("Due Point Temperature [degC] : In %2.2f Out %2.2f \r\n", Tdp_o, Tdp_i); - - // print catuions // + PC("Due Point Temperature [degC] : In %2.2f Out %2.2f \r\n", Tdp_o, Tdp_i); + + // print catuions and warnings // cautions = 0; - if ( Tdp_o >= Outside.t ) - { - PC("Condensation at Outside\r\n"); - cautions ++; - } - - if ( Tdp_i >= Inside.t ) - { - PC("Condensation at Inside\r\n"); - cautions ++; - } - - if ( Tdp_i >= Outside.t ) - { - PC("Condensation at Window Inside\r\n"); - cautions ++; - } - - if ( Tdp_o >= Inside.t ) - { - PC("Condensation at Window Outside\r\n"); - cautions ++; - } - - // print warnings // warnings = 0; - if ( Tdp_o >= Outside.t - warn_wid) - { - PC("%2.2f degC to Condensation at Outside\r\n", Outside.t - Tdp_o); - warnings ++; - } - - if ( Tdp_i >= Inside.t - warn_wid) - { - PC("%2.2f degC to Condensation at Inside\r\n", Inside.t - Tdp_i); - warnings ++; + + for(int ii=0; ii<4; ii++) { + if ( (ii % 2) == 1 ) { + Tcur = Outside.t; // 1 and 3 + sTcur = "Outside"; + ssTcur = "Out"; + } else { + Tcur = Inside.t; // 0 and 2 + sTcur = "Inside"; + ssTcur = "In"; + } + + if ( ii / 2 ) { + sWin = " Window"; // 2 and 3 + ssWin = "@Win"; + } else { + sWin = ""; // 0 and 1 + ssWin = ""; + } + + if ( ii / 2 == ii %2 ) { + Tdp = Tdp_i; // 0 and 3 + } else { + Tdp = Tdp_o; // 1 and 1 + } + + if ( Tdp >= Tcur - warn_wid ) { + skipf[ii] = 0; + if ( Tdp >= Tcur ) { + PC("Condensation at %s\r\n",sTcur); + sprintf(msg[ii][0],"Condns!!"); + sprintf(msg[ii][1],"%s%s",ssTcur,ssWin); + cautions ++; + } else { + PC("%2.2f degC to Condensation at %s%s\r\n", Tcur - Tdp, sTcur, sWin); + sprintf(msg[ii][0],"Cto%4.1fC",Tcur-Tdp); + sprintf(msg[ii][1],"%s%s\0",ssTcur,ssWin); + warnings ++; + } + } else { + skipf[ii] = 1; + } } - - if ( Tdp_i >= Outside.t - warn_wid) - { - PC("%2.2f degC to Condensation at Window Inside\r\n", Outside.t - Tdp_i); - warnings ++; - } - - if ( Tdp_o >= Inside.t - warn_wid) - { - PC("%2.2f degC to Condensation at Window Outside\r\n", Inside.t - Tdp_o); - warnings ++; - } - - if ( cautions > 0 ) - { + + PC("\r\n"); + + if ( cautions > 0 ) { led2 = 1; - } - else - { + } else { led2 = 0; } - - if ( warnings > 0 ) - { + + if ( warnings > 0 ) { led1 = 1; - } - else - { + } else { led1 = 0; } + + // LCD print + switch(mode) { + case (0): + skip = 1; + break; + + case (1): + sprintf(msg1,"Ti %4.1fC",Inside.t); + sprintf(msg2,"To %4.1fC",Outside.t); + break; + + case (2): + sprintf(msg1,"Hi %4.1f%%",Inside.h); + sprintf(msg2,"Ho %4.1f%%",Outside.h); + break; + + case (3): + sprintf(msg1,"Po%6.2f",Outside.p); + sprintf(msg2," [hPa]"); + break; + + case (4): + sprintf(msg1,"Dpi%4.1fC",Tdp_i); + sprintf(msg2,"Dpo%4.1fC",Tdp_o); + break; + + case (5): + case (6): + case (7): + case (8): + int ii = mode - 5; + skip = skipf[ii]; + sprintf(msg1,"%8s",msg[ii][0]); + sprintf(msg2,"%8s",msg[ii][1]); + break; + } + mode++; + if ( mode > 8 ) { + mode = 0; + } - PC("\r\n"); - wait(3); + if ( skip == 0 ) { +#if NEED_LCD_OUTPUT + lcd.locate(0,0); + lcd.print(msg1); + lcd.locate(0,1); + lcd.print(msg2); +#endif + + wait(3); + } else { + skip = 0; + } } -} +} \ No newline at end of file
--- a/mbed.bld Mon May 18 23:07:11 2015 +0000 +++ b/mbed.bld Sun May 31 06:39:09 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/cbbeb26dbd92 \ No newline at end of file