IOT based temperature data logger using esp8266 and pic microcontroller


IOT based temperature data logger using esp8266 and pic microcontroller: Hi everyone I hope you are learning about embedded systems and working on embedded systems based projects. Internet of things is a very popular topic now a days among engineering students and professionals. Many Engineering students works on IOT based projects.In today’s project based on pic microcontroller, you will learn how to make IOT based temperature data logger using pic microcontroller and esp8266 wifi module. ThingSpeak will be used as a live monitoring server of data. You will learn how to send data to a server like In this project, we will measure temperature with LM35 temperature sensor using pic microcontroller and we will interface esp8266 wifi module with pic microcontroller. Wifi module is used to send data to server thingspeak. We will plot temperature in the form of graph on thingspeak.

Working OF IOT based temperature data logger using esp8266

In this project we will monitor temperature value using temperature sensor on ThingSpeak. We will display the temperature sensor data over internet using ThingSpeak  server. We can access this data from anywhere in the world.  So lets first start with how to make account with ThingSpeak.

  • First of all go to this website:  and signup for  ThingSpeak account. After you signup just login to your account and create your channel. When you login yo your account, you will see this window:

ThingSpeak server

  • Now click on New channel. When login to your ThingSpeak server account first time, you will need see  any thing like temperature and LM35 as these are the channels created by me. So you will create your first channel by clicking on new channel. When you click on new channel, you will find this window as shown below: ThingSpeak server new channel
  • Now you need to fill the information in this forum. For example we are creating this channel for IOT based temperature data logger, so we will write “temperature”  in name option and you can give any description to your project. In field you will select how many graphs you want to plot. So in our case we are using temperature sensor only so will select only one label and give it a name temperature.  There is also one option “Make pubic”. You can click this option also if you want to make your sever available to public. Now click on save your channel will be created. ThingSpeak server new channel temperature 2
  • Now we need to get API keys which we will be using in our code to send and receive data from thingSpeak server. But in this project we are only sending data to server using pic microcontroller and esp8266 wifi module, so we will need only write API key. Now click on API keys options as shown below and copy write API key we will use it later in our program to upload data to server. ThingSpeak server new channel write API keys
  • Now click on Data Import / Export option and you will need to copy the URL Update Channel Feed – GET. we will use this URL to upload data to ThingSpeak server. In my case URL is  GET but in your care it could be different.  In this URL you need to post temperature value at the end of field1. For example if you are more than one sensor, you should get more than one fields like field1 and field2.ThingSpeak server new channel data import and export
  • Further I will explain in video lecture how we will use this URL to upload temperature value to ThingSpeak. So lets check the circuit diagram and working of IOT based temperature data logger using esp8266 and pic microcontroller. I have upload temperature values of server check the diagram below: IOT based temperature data logger with thingspeak

IOT based temperature data logger circuit diagram

Circuit diagram of IOT based temperature data logger is given below:

IOT based temperature data logger using esp8266 and pic microcontroller

In above circuit diagram of IOT based temperature data logger using esp8266 and pic microcontroller, we are using PIC18F46K22 microcontroller. PIC18F46K22 measures temperature from LM35 temperature sensor using analog to digital converter. PIC1846K22 has built in 29 channels of analog to digital converters. Its mean we can connect 28 sensors with this pic microcontroller. But we are using only one sensor, so we will use only one channel of PIC18F46K22. LM35 temperature sensor is connect with analog channel zero of PIC16F46K22 microcontroller. Esp8266 wifi module communicate with microcontroller through serial communication and AT commands. you will send AT commands from pic microcontroller to wifi module and esp8266 wifi module will respond to these AT commands accordingly. I will explain these AT commands in later part of this article. you should know how to use serial communication of PIC18F46K22 to send AT commands to WI-FI module. Interfacing circuit is used between PIC18F46K22 and WI-FI module due in difference in operating voltages  of both. Operating voltage of PIC18F46K22 is 5 volt and operating voltage of ESP8266 module is 3.3V. WI-FI module will receive data from microcontroller with AT commands and send this data to ThingSpeak server using import URL which I specified earlier.

Video lecture on IOT based temperature data logger

Code explanation for IOT based temperature data logger

First of all ADC module of pic microcontroller is initialize to read value of temperature sensor. LM35 temperature sensor gives output in the form of voltage. This voltage is measured and converted back into voltage using following commands:

adc_val=adc_read(0)   // It will read digital value of voltage
adc_val=adc_val x 0.488  // It will convert the digital value into temperature

Following AT commands are you to configure ESP8266 module and used to send data to ThingSpeak server.

  • “AT” it is used to check response of module
  • “ATE0\r\n” It is used to stop Echo back from WI-FI module
  • AT+CWMODE=3 : it is used to configure WI-FI module both as a station and client
  • AT+CWQAP : It is used to disconnect WI-FI module from current network
  • AT+CWJAP=\”PTCL-BB\”,\”F4C0A9AB\””  : This command will connect with WI-FI module with internet connect name “PTCL-BB” and password “F4C0A9AB” . you should use your own WI-FI name and password.
  • “AT+CIPSTART=4,\”TCP\”,\”\”,80″: This command is used to set the port connection and address of port. Where is IP address of
  • AT+CIPSEND=4,46 : This commands tells the WI-FI module how many bytes we want to send to server
  • GET /update?key=8W4TM1V37CI3MZI5&field1=value : This command will send the value to server.


  1. lakshmi August 25, 2017
  2. Angel November 30, 2017

Add Comment

Subscribe to our blog to get updates in your email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,480 other subscribers