HTTP Client on NodeMCU with Arduino IDE
Introduction
HTTP (Hypertext Transfer Protocol) is a standard Application protocol which functions as request-response protocol between client and server.
HTTP client helps sending HTTP requests and receiving HTTP responses from HTTP server.
It is widely used in IoT based embedded applications like Home Automation, vehicle engine parameter monitoring remotely for analysis, etc.
NodeMCU is an open source IoT platform. It is a firmware which runs on ESP8266 Wi-Fi SoC from Espressif Systems. It has on board wi-fi available through which IoT applications becomes easy to build.
Example
Let’s write a C/C++ based Arduino sketch for NodeMCU as an HTTP Client and GET/POST the data from/to the thingspeak server.
Here, we are using Thingspeak server for HTTP Client demo purpose.
Thingspeak is an open IOT platform where anyone can visualize and analyze live data from their sensor devices. Also, we can perform data analysis on data posted by remote devices with Matlab code in Thingspeak. To learn more about Thingspeak refer link
https://thingspeak.com/pages/learn_more
Just sign up and create channel.We have below channel and write key on Thingspeak for data send and receive.
- Channel ID is = 309236
- Write Key is = 1EYZIS5OCRJSKZHG
Note: Do not forget to tick the Make Public field in channel setting option on your thingspeak channel.
ArduinoSketch for HTTP Client Get
Output Window for HTTP Get
Below is the Arduino serial monitor window which shows last updated data received from thingspeak server.
Arduino Sketch for HTTP Client Post
Output Window for HTTP Post
Below is the output window of counts at thingspeak server.