Lecture3 1 Hands-On-Activity-1-Sensor To ThingSpeak Cloud
Lecture3 1 Hands-On-Activity-1-Sensor To ThingSpeak Cloud
UEC715
Topics covered:
DHT11 Sensor
ThingSpeak
Example: Lets assume that the website is a restaurant and our program/application is
customer and the food is data. So to get the food, customer needs to give the dish name to the
waiter from the menu card, along with that the waiter also notes the table number and gives that
information to the kitchen staff.
In similar way our program also requests data from website by posting the information like API
key, topic parameter in the form of Uniform Resource Locator (URL). This URL is API. If the
API key matches the API key given to us by the website then the response is given by the website
and the program gets the data.
9/10/2024 IoT based System (UEC715) 4
ThingSpeak
ThingSpeak is a IoT cloud platform service that allows us to visualize live data streams in the
cloud. We can send data to ThingSpeak from our devices and create instant visualization of live
data.
NOTE: In our project we are just posting the temperature data to Thingspeak server and not
requesting any data. So first lets see how to get API from Thingspeak , publish data using API and
then make the hardware connections.
9/10/2024 IoT based System (UEC715) 5
Components required
Now we are done with all setup. Before uploading the code, modify it according to your
WiFi ssid and password. Also assign your “write API key” to the apiKey parameter
which you will get from your Thingspeak channel under API keys.
Upload the given code. Open the serial monitor to see the status. Set baud rate to
"115200". As soon as it will connect to WiFi, It will start publishing room temperature
after interval of 10 seconds. You can change this interval by changing the delay in the
“void loop()”.
// ThingSpeak Credentials
void initDHT(){
unsigned long Channel_ID = 2637682; if (isnan(temperature) || isnan(humidity)) {
const char * API_Key = "L4PMUSMH1ZJQ1D00 "; Serial.println("Failed to read from DHT sensor!");
while (1);
}
// Delay }