Last active
April 11, 2016 08:43
-
-
Save LarsBergqvist/19e6d698b8cabcf511a9bdf50afa2605 to your computer and use it in GitHub Desktop.
Adafruit_IO_REST_send_data
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
void sendDataToAdafruitIO(float temperature, float humidity) | |
{ | |
unsigned long startTime = millis(); | |
if (isnan(temperature) || isnan(humidity)) | |
{ | |
Serial.println("Failed to read from DHT sensor!"); | |
return; | |
} | |
Serial.println("Start sending data to Adafruit IO..."); | |
char temperature_str[20]; | |
ftoa(temperature_str,temperature); | |
if (temperatureFeed.send(temperature_str)) | |
{ | |
Serial.println(temperature_str); | |
Serial.println("Sent temperature ok"); | |
} | |
else | |
{ | |
Serial.println("Failed sending temperature"); | |
} | |
char humidity_str[20]; | |
ftoa(humidity_str,humidity); | |
if (humidityFeed.send(humidity_str)) | |
{ | |
Serial.println(humidity_str); | |
Serial.println("Sent humidity ok"); | |
} | |
else | |
{ | |
Serial.println("Failed sending humidity"); | |
} | |
unsigned long endTime = millis(); | |
Serial.print("Sending data took "); | |
Serial.print((endTime-startTime)/1000.0); | |
Serial.println(" second(s)"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment