alrm working version
Dependencies: DHT libmDot mbed-rtos mbed
Fork of mDot_Connect_IoTClub_one_wire_4ch_8_24 by
Diff: main.cpp
- Revision:
- 7:3a4df8dbbb2e
- Parent:
- 5:6c7d2f4d7377
- Child:
- 8:dfcee7a96019
diff -r f1e7916a9999 -r 3a4df8dbbb2e main.cpp --- a/main.cpp Fri Jul 29 04:48:44 2016 +0000 +++ b/main.cpp Fri Jul 29 09:13:29 2016 +0000 @@ -5,8 +5,10 @@ #include <vector> #include <algorithm> #include "DHT.h" +#include "LinearTemp.h" DHT sensor(PB_1, DHT11); +LinearTemp myPHSensor(PB_0, 0.005, -273.15); // these options must match the settings on your Conduit // uncomment the following lines and edit their values to match your configuration @@ -19,6 +21,8 @@ mDot* dot; std::vector<uint8_t> data; std::vector<uint8_t> send_data; + char * PhStrBuf; + float PhValue; std::string data_str = "T&H Sensors"; int error = 0; // float h = 0.0f, c = 0.0f, f = 0.0f, k = 0.0f, dp = 0.0f, dpf = 0.0f; @@ -106,6 +110,7 @@ } else { logInfo("successfully sent data to gateway"); } + // in the 868 (EU) frequency band, we need to wait until another channel is available before transmitting again osDelay(std::max((uint32_t)5000, (uint32_t)dot->getNextTxMs())); @@ -130,6 +135,13 @@ } data.clear(); + + // Read the PH value + PhValue = myPHSensor; + + sprintf(PhStrBuf, "PH:%5.4f", PhValue); + logInfo("PH: %5.4f", PhValue); + // probably not the most efficent way to do this for( int i=0; i< strlen(dataBuf); i++ ) data.push_back( dataBuf[i] );