Learn ThingSpeak in an easy and optimized way with examples!!

by Nov 20, 2020IoT Cloud

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 Local Area Network. ThingSpeak enables the creation of sensor logging applications, location tracking applications, and a social network of things with status updates.

1. Introduction

This tutorial explains how to set up accounts with ThingSpeak and the basics. ThingSpeak is an open cloud data platform where you can store and retrieve data.

2. ThingSpeak basics and account setup

URL : https://thingspeak.com/

Create a ThingSpeak account by visitng the url provided above. Click on the “Get Started For Free” button and sign up as new user.

>>Now, create a new channel by clicking on the button as shown in the below image – A channel is a source for your data. Where you can store and retrieve data. A channel can have a maximum of 8 fields. It means you can store 8 different data to a channel.

>>Create channel(s) to store data from sensor(s).

>>Scroll down and save the channel.

>>Channel Id is the identity of your channel. Note down this.

>>API ( Application Programming Interface ) keys are the keys to access your channel. In simple language, you can understand that these are passwords to access your channel. You can access your channel in two ways-

1. To update channel / data logging : API Write Key will be used to access in this mode.

2. To retrieve data : API Read Key will be used to access  in this mode.

Click on the API tab to know your API keys.

Key has been blurred due to security reasons.

3. Project using ThingSpeak

>> Description

This is a simple project that uses an ESP8266 module to send the sensor data to the ThingSpeak channel.

>>Demonatration

ThingSpeak Channel
Temperature Data
Light intensity Data

>>Hardware required

  • Arduino Uno
  • ESP8266 Wifi module
  • Breadboard
  • LDR
  • LM35
  • 220 ohms resistor
  • Jumper cables

>>Circuit connections

ESP8266 connections

>>Connect TX pin of the module to pin 2 of the Arduino Uno and connect RX pin of the module to pin 3 on Uno.

>>Connect the Vcc and CH_EN pin of module to 3.3V on Arduino and GND pin of the module to the ground.

LDR connections

>>Connect the 220 ohms resistor and LDR in series and connect the 5v supply to the resistor and the other end of the LDR to the ground.

>>Connect the resistor-LDR junction to A0 pin on the Arduino.

LM35 connections

>>Connect the Vcc pin and the GND pin to the 5V and ground respectively.

>>Connect the Vout pin to A1 pin on the Arduino.

>>Code

#include <SoftwareSerial.h>
#define RX 2
#define TX 3
String AP = "Wifi_Name";       // AP NAME
String PASS = "Wifi_Pwd"; // AP PASSWORD
String API = "API key";   // Write API KEY
String HOST = "api.thingspeak.com";
String PORT = "80";
int countTrueCommand;
int countTimeCommand; 
boolean found = false; 
int valSensor = 1;
  
SoftwareSerial esp8266(RX,TX); 
  
void setup() {
  Serial.begin(9600);
  esp8266.begin(115200);
  sendCommand("AT",5,"OK");
  sendCommand("AT+CWMODE=1",5,"OK");
  sendCommand("AT+CWJAP=\""+ AP +"\",\""+ PASS +"\"",20,"OK");
}

void loop() {
  
 String getData = "GET /update?api_key="+ API +"&field1="+getTemperatureValue()+"&field2="+getLDRValue();
 sendCommand("AT+CIPMUX=1",5,"OK");
 sendCommand("AT+CIPSTART=0,\"TCP\",\""+ HOST +"\","+ PORT,15,"OK");
 sendCommand("AT+CIPSEND=0," +String(getData.length()+4),4,">");
 esp8266.println(getData);delay(1500);countTrueCommand++;
 sendCommand("AT+CIPCLOSE=0",5,"OK");
}


String getTemperatureValue()
{
  int temp;
  temp=analogRead(A1)/10.24;    
  return String(temp);   
}


String getLDRValue()
{
 int ldr=analogRead(A0); 
 return String(ldr);  
}

void sendCommand(String command, int maxTime, char readReplay[]) {
  Serial.print(countTrueCommand);
  Serial.print(". at command => ");
  Serial.print(command);
  Serial.print(" ");
  while(countTimeCommand < (maxTime*1))
  {
    esp8266.println(command);//at+cipsend
    if(esp8266.find(readReplay))//ok
    {
      found = true;
      break;
    }
  
    countTimeCommand++;
  }
  
  if(found == true)
  {
    Serial.println("OYI");
    countTrueCommand++;
    countTimeCommand = 0;
  }
  
  if(found == false)
  {
    Serial.println("Fail");
    countTrueCommand = 0;
    countTimeCommand = 0;
  }
  
  found = false;
 }

Creating a multiplication Skill in Alexa using python

Written By Monisha Macharla

Hi, I'm Monisha. I am a tech blogger and a hobbyist. I am eager to learn and explore tech related stuff! also, I wanted to deliver you the same as much as the simpler way with more informative content. I generally appreciate learning by doing, rather than only learning. Thank you for reading my blog! Happy learning!

RELATED POSTS

Creating REST API CRUD with Node.js, Express and MongoDB

Creating REST API CRUD with Node.js, Express and MongoDB

In our previous blog, we explored the fundamentals of creating a REST API with in-memory CRUD operations using Node.js and Express. Now, we're taking a significant step forward by integrating our product data with a database. This transition is pivotal for achieving...

How to create REST API using Node.js and Express?

How to create REST API using Node.js and Express?

In the vast landscape of web development, creating a robust API is a fundamental skill. APIs, or Application Programming Interfaces, serve as the communication bridge between different software applications. Today, we'll embark on a journey to build a simple blog API...

APIs Vs. Microservices: What is the difference?

APIs Vs. Microservices: What is the difference?

You've probably heard two extravagant terms thrown around when discussing software design and integrations: APIs and microservices. Both topics are important in web application development and design nowadays, and their applications overlap. In this article, we will...

Understanding Salesforce IoT and Its Importance

Understanding Salesforce IoT and Its Importance

In this post, we are going to discuss Salesforce IoT. All across the globe, people are connecting to the Internet to access information, communicate with other people, and do business. But it's not just people that are using the Internet: objects use it too....

Best IoT IDEs For Successful IoT Products

Best IoT IDEs For Successful IoT Products

IoT IDEs are the essential tools that we need in developing our IoT projects. They give us the pathway to connect our Hardware and Software and do magical things using IoT. Consequently, they are useful. IoT is the next big thing in the world. It has taken the whole...

Top 5 Databases to store data of IoT applications

Top 5 Databases to store data of IoT applications

Databases for IoT applications The Internet of Things (IoT) produces massive quantities of data, such as streaming data, time-series data, RFID data, and sensory data, among other things. The use of a database is needed for efficient data management. The existence of...

An overview of Google Cloud Platform for IoT

An overview of Google Cloud Platform for IoT

The cloud technologies have revolutionised the niche of Internet of Things. The cloud technologies for Internet of Things offer a one stop solution for securely connecting devices and securely communicating between the devices. It also offers the tools to process the...

VIDEOS – FOLLOW US ON YOUTUBE

EXPLORE OUR IOT PROJECTS

IoT Smart Gardening System – ESP8266, MQTT, Adafruit IO

Gardening is always a very calming pastime. However, our gardens' plants may not always receive the care they require due to our active lifestyles. What if we could remotely keep an eye on their health and provide them with the attention they require? In this article,...

How to Simulate IoT projects using Cisco Packet Tracer

In this tutorial, let's learn how to simulate the IoT project using the Cisco packet tracer. As an example, we shall build a simple Home Automation project to control and monitor devices. Introduction Firstly, let's quickly look at the overview of the software. Packet...

All you need to know about integrating NodeMCU with Ubidots over MQTT

In this tutorial, let's discuss Integrating NodeMCU and Ubidots IoT platform. As an illustration, we shall interface the DHT11 sensor to monitor temperature and Humidity. Additionally, an led bulb is controlled using the dashboard. Besides, the implementation will be...

All you need to know about integrating NodeMCU with Ubidots over Https

In this tutorial, let's discuss Integrating NodeMCU and Ubidots IoT platform. As an illustration, we shall interface the DHT11 sensor to monitor temperature and Humidity. Additionally, an led bulb is controlled using the dashboard. Besides, the implementation will be...

How to design a Wireless Blind Stick using nRF24L01 Module?

Introduction Let's learn to design a low-cost wireless blind stick using the nRF24L01 transceiver module. So the complete project is divided into the transmitter part and receiver part. Thus, the Transmitter part consists of an Arduino Nano microcontroller, ultrasonic...

Sending Temperature data to ThingSpeak Cloud and Visualize

In this article, we are going to learn “How to send temperature data to ThingSpeak Cloud?”. We can then visualize the temperature data uploaded to ThingSpeak Cloud anywhere in the world. But "What is ThingSpeak?” ThingSpeak is an open-source IoT platform that allows...

Amaze your friend with latest tricks of Raspberry Pi and Firebase

Introduction to our Raspberry Pi and Firebase trick Let me introduce you to the latest trick of Raspberry Pi and Firebase we'll be using to fool them. It begins with a small circuit to connect a temperature sensor and an Infrared sensor with Raspberry Pi. The circuit...

How to implement Machine Learning on IoT based Data?

Introduction The industrial scope for the convergence of the Internet of Things(IoT) and Machine learning(ML) is wide and informative. IoT renders an enormous amount of data from various sensors. On the other hand, ML opens up insight hidden in the acquired data....

Smart Display Board based on IoT and Google Firebase

Introduction In this tutorial, we are going to build a Smart Display Board based on IoT and Google Firebase by using NodeMCU8266 (or you can even use NodeMCU32) and LCD. Generally, in shops, hotels, offices, railway stations, notice/ display boards are used. They are...

Smart Gardening System – GO GREEN Project

Automation of farm activities can transform agricultural domain from being manual into a dynamic field to yield higher production with less human intervention. The project Green is developed to manage farms using modern information and communication technologies....