ThingSpeak Integration
ThingSpeak
ThingSpeak (https://thingspeak.com)
- ThingSpeak is a web platform the IoT
- It allows you to send data from Photon 2 to be stored at ThingSpeak
- You can create basic graphs and dashboard with the values from your Photon 2
- ThingSpeak also integrates with MATLAB for powerful data analytics
Configuring Photon 2 and ThingSpeak
- The following examples are provided as a quick reference
- More detailed steps were described in the lecture
General Steps to Connect Photon 2 and ThingSpeak
-
Create an integration -> webhook on Particle console
-
Create channel at ThingSpeak
-
Write firmware sketch and flash Photon 2
Example 1: Send Single Data Point from Photon 2 to ThingSpeak
Particle integration settings
Example 1: Send Single Data Point from Photon 2 to ThingSpeak
ThingSpeak Channel Setttings
Example 1: Send Single Data Point from Photon 2 to ThingSpeak
Photon 2 code
double temp;
void loop() {
temp = 89; //just example; temp should come from sensor
// Trigger the integration
Particle.publish("Environment", String(temp), PRIVATE);
delay(60000); //use delay or millis to avoid publishing too frequently
}
Example 2: Send Multiple Data Points Photon 2 to Thingspeak
Particle integration settings
Example 2: Send Multiple Data Points from Photon 2 to Thingspeak
ThingSpeak channel settings
Example 2: Send Multiple Data Points Photon 2 to Thingspeak
Photon 2 Code
double temp;
double humidity;
int rainfall;
String weather;
void loop() {
//variables should read sensor data
String data = "{ \"weather\": \"" + weather + "\"" +
", \"temp\": " + temp +
", \"humidity\": " + humidity +
",\"rainfall\": " + rainfall +
"}";
// Trigger the integration
Particle.publish("Environment", String(data), PRIVATE);
delay(60000); //use delay or millis to avoid publishing too frequently
}
##
String data
variable will be in the following format
{
"weather":"sunny"
"temp":76
"humidity":42
"rainfall":19
}