Thingspeak: ThingSpeak is an open-source Internet of Things (IoT) application and API to store and retrieve data from things using the HTTP and MQTT protocol over the Internet or via a LocalArea Network. ThingSpeak enables the creation of sensor logging applications, location tracking applications, and a social network of things with status updates.
Program 5.1: Upload data on Thingspeak cloud manually.
Step 1: Open Thingspeak in browser by using the url www.thingspeak.com And sign in.
Step 2: Fill all the details if you are a new user.
Step 3: After login Create Channel on Thingspeak
Step 4: Click on API Keys
Step 5: Calling the API by passing values in URL
Step 6: Click on Private View to view the graph for passed values
Program 5.2: To update readings to Thingspeak from Arduino using Tinkercad.
Component:
Theory:
void setup(){
Serial.begin(115200);pinMode(A0, INPUT);delay(1000);
Serial.println(“AT+CWJAP=\”Simulator Wifi\ “,\”\ “\r\n”);
delay(3000);
}
void loop(){
int senseValue = analogRead(A0);
float volt = (senseValue/1020.0) * 4.9; //Volts floatfloat tempC = (volt -0.5) * 100; //CelciusSerial.println(tempC);
Serial.println(“AT+CIPSTART=\”TCP\ “,\”api.thingspeak.com\ “,80\r\n”);
delay(5000);int len = 65;
Serial.print(“AT+CIPSEND=”);Serial.println(len);
delay(10);
Serial.print(“GET /update?api_key=QIJ30DA6H5OI2DWV&field1=120 HTTP/1.1\r\n”);delay(100);
Serial.println(“AT+CIPCLOSE=0\r\n”);delay(6000);
}
Program 5.3: To interface Temperature sensor and ESP8266 with Arduino and update temperaturereading to Thingspeak.
Component:
void setup(){
Serial.begin(115200);pinMode(A0, INPUT);delay(1000);
Serial.println(“AT+CWJAP=\”Simulator Wifi\ “,\”\ “\r\n”);
delay(3000);
}
void loop(){
int senseValue = analogRead(A0);
float volt = (senseValue/1020.0) * 4.9; //Volts floatfloat tempC = (volt -0.5) * 100; //CelciusSerial.println(tempC);
Serial.println(“AT+CIPSTART=\”TCP\ “,\”api.thingspeak.com\ “,80\r\n”);
Serial.print(“AT+CIPSEND= ”);Serial.println(len);
delay(10);
Serial.print(“GET /update?api_key=AT0I0YF0H855GT2U&field1= ” + String(tempC) + “HTTP/1.1\r\n”);
delay(100);Serial.println(“AT+CIPCLOSE=0\r\n”);delay(6000);
}
Program 5.4: To interface Temperature sensor and ESP8266 with Arduino and update temperature values to Thingspeak and tweet “High Temp” message on tweeter when temperature value isgreater than 40C.
void setup(){
Serial.begin(115200);pinMode(A0, INPUT);delay(1000);
Serial.println(“AT+CWJAP=\”Simulator Wifi\ “,\”\ “\r\n”);
delay(3000);
}
void loop(){
int senseValue = analogRead(A0);
float volt = (senseValue/1020.0) * 4.9; //Volts floatfloat tempC = (volt -0.5) * 100; //CelciusSerial.println(tempC);
Serial.println(“AT+CIPSTART=\”TCP\ “,\”api.thingspeak.com\ “,80\r\n”);
delay(5000);int len = 65;
Serial.print(“AT+CIPSEND=”); Serial.println(len);
delay(10);
Serial.print(“GET /update?api_key=AT0I0YF0H855GT2U&field1=” + String(tempC) + “HTTP/1.1\r\n”);
delay(100);Serial.println(“AT+CIPCLOSE=0\r\n”);delay(6000);
}
1. Create new channel on ThingSpeak
2. Go to apps => react app => create new
4. Start the simulator and increase temperature above 40
5. Channel Stats graph
6. See the Tweet
Program 5.5: To interface LDR sensor, LED and ESP8266 with Arduino and update light intensity values to Thingspeak and tweet “LIGHT ON” message on tweeter when light intensity value is less than 300.
Component:
int sense_value;void setup(){
Serial.begin(115200);pinMode(10, OUTPUT);pinMode(12, OUTPUT);pinMode(A1, INPUT);delay(1000);
Serial.println(“AT+CWJAP=\”Simulator Wifi\ “,\”\ “\r\n”);
delay(3000);
}
void loop(){
int sense_value = analogRead(A1);Serial.println();
if (sense_value <= 300){digitalWrite(12, HIGH);digitalWrite(10, LOW);
}
else {
digitalWrite(10, HIGH);digitalWrite(12, LOW);
}
Serial.println(“AT+CIPSTART=\”TCP\ “,\”api.thingspeak.com\ “,80\r\n”);delay(500);
int len = 65;Serial.print(“AT+CIPSEND=”);Serial.println(len);
delay(10);
Serial.print(“GET /update?api_key=T1HHE4KTNLIKELVC&field1=” + String(sense_value)+ “HTTP/1.1\r\n”);
delay(100);Serial.println(“AT+CIPCLOSE=0\r\n”);delay(600);
}
1. Create channel for Tweet with LDR
2. Channel view
4. React App
6. Channel stats