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 1:1cf4309871b7, committed 2015-04-30
- Comitter:
- takafuminaka
- Date:
- Thu Apr 30 16:53:14 2015 +0000
- Parent:
- 0:6434ef883399
- Child:
- 2:362deefab67e
- Commit message:
- Initial Release
;
Changed in this revision
--- a/AQM0802.lib Wed Jan 28 08:56:47 2015 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/yasuyuki/code/AQM0802/#6fa303916aa8
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BME280.lib Thu Apr 30 16:53:14 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/MACRUM/code/BME280/#c35f637c28ef
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/VaporCondition.lib Thu Apr 30 16:53:14 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/takafuminaka/code/VaporCondition/#11570780a596
--- a/main.cpp Wed Jan 28 08:56:47 2015 +0000 +++ b/main.cpp Thu Apr 30 16:53:14 2015 +0000 @@ -9,45 +9,144 @@ // http://einstlab.web.fc2.com //********************** #include "mbed.h" -#include "AQM0802.h" #include "HDC1000.h" +#include "BME280.h" +#include "VaporCondition.h" + +#define NEED_CONSOLE_OUTPUT 1 + +#if NEED_CONSOLE_OUTPUT +Serial pc(USBTX, USBRX); +#define PC(...) { pc.printf(__VA_ARGS__); } +#else +#define PC(...) /* nothing */ +#endif /* #if NEED_CONSOLE_OUTPUT */ + #if defined(TARGET_LPC1768) -I2C i2c(p28,p27); -#endif -// for TG-LPC11U35-501 -#if defined(TARGET_LPC11U35_501) -I2C i2c(P0_5,P0_4); -#endif -// for Nucleo -#if defined(TARGET_NUCLEO_F401RE) -I2C i2c(D14,D15); + I2C i2c(p28, p27); + // BME280 sensor(p28, p27, 0x76 << 1); +#else + I2C i2c(I2C_SDA0, I2C_SCL0); + // BME280 sensor(I2C_SDA0, I2C_SCL0, 0x76 << 1); #endif -AQM0802 lcd(i2c); +BME280 bme280(I2C_SDA0, I2C_SCL0, 0x76 << 1); HDC1000 hdc1000(i2c); +DigitalOut led1(LED1); +DigitalOut led2(LED2); + int main() { + float Tdp_o; + float Tdp_i; + int cautions; + int warnings; + int warn_wid = 20; - char msg[10]; - float h; - float t; + VaporCondition Inside; + VaporCondition Outside; + + // LED Check + led1 = 1; + led2 = 1; + wait(10); + + led1 = 0; + led2 = 0; while(1) { - h = hdc1000.humidity(); - h = h/0x10000*100; - sprintf(msg,"%4.1f%% ",h); - lcd.locate(0,0); - lcd.print(msg); + Inside.h = float(hdc1000.humidity())/0x10000*100; + + Inside.t = float(hdc1000.temperature())/0x10000*165-40; + + Outside.h = bme280.getHumidity(); + Outside.t = bme280.getTemperature(); + + Outside.p = bme280.getPressure(); + Inside.p = bme280.getPressure(); // Usually Pressures are same between inside and outside. - t = hdc1000.temperature(); - t = t/0x10000*165-40; - sprintf(msg,"%4.1fC ",t); - lcd.locate(0,1); - lcd.print(msg); - - wait(1); +// 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 // + 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 ++; + } + + 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 ) + { + led2 = 1; + } + else + { + led2 = 0; + } + + if ( warnings > 0 ) + { + led1 = 1; + } + else + { + led1 = 0; + } + + PC("\r\n"); + wait(10); } }