Last active
April 11, 2016 08:43
-
-
Save LarsBergqvist/70a21035a7ca8b56cd3f4c2a342404f0 to your computer and use it in GitHub Desktop.
Adafruit_IO_MQTT_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..."); | |
MQTT_connect(); | |
if (temperaturePub.publish(temperature)) | |
{ | |
Serial.println(temperature); | |
Serial.println("Sent temperature ok"); | |
} | |
else | |
{ | |
Serial.println("Failed sending temperature"); | |
} | |
if (humidityPub.publish(humidity)) | |
{ | |
Serial.println(humidity); | |
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