Created
July 30, 2016 13:18
-
-
Save Kazu-zamasu/2d413167873b016911a389d3f50685dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "mbed.h" | |
#include "HDC1000.h" | |
HDC1000 hmtp(dp5,dp27); | |
AnalogIn analog_value(dp13); | |
AnalogIn analog_value2(dp4); | |
char Head[] = "{\"module\": \"hogehogehoge\",\"type\": \"channels\",\"datetime\":\"2016-06-01T12:21:11.628907163Z\",\"payload\": {\"channels\": ["; | |
char Ch1Head[] = "{\"channel\":1,\"type\": \"i\",\"value\":"; | |
char Ch2Head[] = "{\"channel\":2,\"type\": \"i\",\"value\":"; | |
char Ch3Head[] = "{\"channel\":3,\"type\": \"f\",\"value\":"; | |
char Ch4Head[] = "{\"channel\":4,\"type\": \"f\",\"value\":"; | |
char JSONCHEND [] = "},"; | |
char JSONSTREND [] = "]}}"; | |
float Soil,Lux,Temp,RH; | |
int main() { | |
while(true){ | |
hmtp.get(); | |
float meas; | |
meas = analog_value.read(); // Converts and read the analog input value (value from 0.0 to 1.0) | |
meas = meas * 3300; // Change the value to be in the 0 to 3300 range | |
float meas2; | |
meas2 = analog_value2.read(); | |
meas2 = meas2 * 3300; | |
//printf("Temp: %.2fc, Humid: %.2f, Light: %.0f mV, Soil: %.0f\r\n", hmtp.temperature(), hmtp.humidity(), meas, meas2); | |
//wait(2.0); | |
Soil = analog_value.read() * 3300;// Soil sennsor Analog object | |
Lux = analog_value2.read() * 3300;// Lux Sensor Analog object | |
Temp = hmtp.temperature();// Temperature sensor Analog object | |
RH = hmtp.humidity();// Humidity sensor Anlog object | |
// UART output | |
printf("%s%s%.2f%s%s%.2f%s%s%.2f%s%s%.2f%s%s\r\n",Head,Ch1Head,Soil,JSONCHEND,Ch2Head,Lux,JSONCHEND,Ch3Head,Temp,JSONCHEND,Ch4Head,RH,JSONCHEND,JSONSTREND); | |
wait(3.0); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment