Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: libmDot mbed-rtos mbed
Fork of mDot_Connect_IoTClub_one_wire by
Diff: main.cpp
- Revision:
- 8:dfcee7a96019
- Parent:
- 7:3a4df8dbbb2e
- Child:
- 9:cf45820af9b9
--- a/main.cpp Fri Jul 29 09:13:29 2016 +0000
+++ b/main.cpp Fri Aug 12 03:33:55 2016 +0000
@@ -4,10 +4,10 @@
#include <string>
#include <vector>
#include <algorithm>
-#include "DHT.h"
+//#include "DHT.h"
#include "LinearTemp.h"
-DHT sensor(PB_1, DHT11);
+//DHT sensor(PB_1, DHT11);
LinearTemp myPHSensor(PB_0, 0.005, -273.15);
// these options must match the settings on your Conduit
@@ -21,12 +21,12 @@
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;
+ char dataBuf[11];
+// int error = 0;
// float h = 0.0f, c = 0.0f, f = 0.0f, k = 0.0f, dp = 0.0f, dpf = 0.0f;
- float h = 0.0f, c = 0.0f;
+// float h = 0.0f, c = 0.0f;
// get a mDot handle
@@ -99,9 +99,6 @@
// format data for sending to the gateway
for (std::string::iterator it = data_str.begin(); it != data_str.end(); it++)
data.push_back((uint8_t) *it);
-
- char dataBuf[11];
- int thflag=0;
while (true) {
// send the data to the gateway
@@ -111,46 +108,21 @@
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()));
- wait(2.0f);
- error = sensor.readData();
- if (0 == error) {
- c = sensor.ReadTemperature(CELCIUS);
-// f = sensor.ReadTemperature(FARENHEIT);
-// k = sensor.ReadTemperature(KELVIN);
- h = sensor.ReadHumidity();
-// dp = sensor.CalcdewPoint(c, h);
-// dpf = sensor.CalcdewPointFast(c, h);
- printf("Temperature: %4.2f Humidity: %4.2f\n\n", c, h);
-
- if (thflag==0) {
- sprintf(dataBuf, "T:%4.2f", c);
- thflag=1;
- } else {
- sprintf(dataBuf, "H:%4.2f", h);
- thflag=0;
- }
-
data.clear();
// Read the PH value
PhValue = myPHSensor;
- sprintf(PhStrBuf, "PH:%5.4f", PhValue);
- logInfo("PH: %5.4f", PhValue);
+ sprintf(dataBuf, "CH0:%5.4f", PhValue);
+ logInfo("%s", dataBuf);
// probably not the most efficent way to do this
for( int i=0; i< strlen(dataBuf); i++ )
data.push_back( dataBuf[i] );
- } else {
- printf("Error: %d\n", error);
- }
-
}
-// return 0;
}
