Created
November 11, 2015 15:35
-
-
Save lithiumhead/6d7b93819462319412bb to your computer and use it in GitHub Desktop.
Code for Particle Core/Photon to upload readings from SHT11 to Thingspeak.com
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
#define PARTICLE_PHOTON | |
#include "ThingSpeak/ThingSpeak.h" | |
#include "SHT1x/SHT1x.h" | |
//ThingSpeak.com configurations: | |
TCPClient client; | |
unsigned long myChannelNumber = REPLACE_WITH_YOUR_CHANNEL_NUMBER; | |
const char * myWriteAPIKey = "REPLACE_WITH_YOUR_API_KEY"; | |
// Channel 1 is Temperature (deg C) | |
// Channel 2 is Humidity (%) | |
//SHT11 Configuration: | |
#define dataPin D0 | |
#define clockPin D1 | |
SHT1x sht1x(dataPin, clockPin); | |
void setup() { | |
ThingSpeak.begin(client); | |
} | |
void loop() { | |
float temp_c; | |
float humidity; | |
temp_c = sht1x.readTemperatureC(); | |
humidity = sht1x.readHumidity(); | |
ThingSpeak.setField(1,temp_c); | |
ThingSpeak.setField(2,humidity); | |
ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey); | |
delay(20000); // ThingSpeak will only accept updates every 15 seconds. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment