LM35 data to Thingspeak with Node MCU


Let’s learn how to plot LM35 temperature data to Thingspeak using Node MCU developer board which is Arduino compatible with ESP8266 in-built to access the internet. With the use of the internet, we can upload the data to free cloud database and analytic’s platform like Thingspeak. For this, you need to create a Thingspeak ID. After creating an account you need get our API key to push the data into Thingspeak server. To upload the data to this IoT analytics platform you need to create a channel for each device. Go to channels and create a new channel for your NodeMCU and LM35. While you are creating a channel you need to give the details of the channel for example Name, Description Fields, Metadata, tags, and link to external site.  After filling up the details click on the save channel which will give you channel ID and other settings for the channel. By default, the channel will be private if you wish to share the data to the public you can do that as well. After creating the channel thingspeak allows you to create visualizations of your data in different forms using MATLAB.

Learn How to Blink Using NodeMCU

Also, earn How to Blink Led Using NodeMCU/ESP8266 WebServer


The NodeMCU have 10 GPIO pins connect the LM35 the data pin to Node MCU.  Node MCU has a micro USB for connecting to system use this MicroUSB to dump or programming and power supply for the board, Insert the NodeMCU board into the breadboard and connect the LM35 sensor to Node MCU board using male to male jumper wires the output pin of LM35 is connected to Node MCU of A0 pin. The pin is used to analyze the data the Esp8266 Wifi shield is used for connecting to internet used to upload the data to the cloud.

The temperature Sensor LM35 is now connected to the Node MCU via the breadboard. LM35 has three pins. They are supplied, ground (GND) and output pin. The supply pin of LM35 is connected to +5V of Node MCU The output pin of LM35 is connected to the A0 pin of Node MCU. The GND pin of LM35 is connected to the GND of Node MCU.

Next Step:

Go to Tools -> Board (where you’d select your version of Arduino) -> Boards Manager, find the ESP8266 and click Install. You now should be able to use the ESP8266 as an Arduino. Simply select the NODEMCU 1.0 as your board with Port and you should be ready to code.

Now, with the ESP8266 board installed to Arduino IDE, we can program NodeMCU using Arduino IDE directly.

Setup for installing Node MCU software and ThingSpeak libraries:

GoTo Sketch > Include Library > Manage Libraries

> Search for Thingspeak> Click on it > Click Install 


#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ThingSpeak.h>
const char* ssid = "My ASUS";
const char* password = "123456780";
int val;
int tempPin = A0;

WiFiClient client;
unsigned long myChannelNumber = 345148;
const char * myWriteAPIKey = "FBOED9JHDAJNZ3SQ";
void setup() {

WiFi.begin(ssid, password);
// Connect to WiFi network

void loop() {
val = analogRead(tempPin);
float mv = ( val/1024.0)*5000;
float cel = mv/10;
Serial.print("TEMPRATURE = ");
ThingSpeak.writeField(myChannelNumber, 1,cel, myWriteAPIKey);

delay(100); }

Upload Code to Node MCU

After applying the code you need to change the board to  NodeMCU 1.0(ESP-12Emodule) and port also select the com port where your ESP8266 is connected to that com port.


ThingSpeak is a platform providing various services exclusively targeted for building IoT applications. It offers the capabilities of real-time data collection, visualizing the collected data in the form of charts, ability to create plugins and apps for collaborating with web services, social network and other APIs

The data will store into ThingSpeak so you need to log into  ThingSpeak account after logging in the account automatically the API keys and channel number will come. You need to change your channel number and API keys into the program , In the ThingSpeak, you can store and retrieve the data from ThingSpeak in ThingSpeak 8 fields you can select the fields.

ThingSpeak channel :

Selecting the Fields:


Output in ThingSpeak:

The figure shows the live temperature that is sensed by the sensor in a graphical presentation. Out of the eight channels present in the cloud, the said system uses only one channel for monitoring. 

Conclusion and future scope:

The article presented here is based on the project work carried by us. This project is an implementation of Internet of Things. The said project is able to sense the temperature and monitor it remotely. The proposed use of Internet of Things will help the researchers in the field to come up with solutions that are inexpensive and more reliable. The project can be further expanded to control things. The sensed temperature can be used for various projects such as home automation, lab monitoring, etc.


About Us

TechGeekBytes is a free Technology resource site for Beginners. TechGeekBytes was founded in 2016 by Open Hardware Days Pvt Ltd. The main goal of this site is to provide quality tips, tricks, hacks, and other Technology resources that allows beginners to improve their skill(s).