Temperature Sensor and ThingSpeak Server

Kunal Sharma
5 min readFeb 1, 2021

In this experiment, I have used a temperature sensor and sent data to the ThingSpeak server. The pre-requisite for this project in the coding domain is C programming. I would highly recommend you to go through C programming basics, plenty of material is available on the internet.

Hardware, Sensors, and Modules I used:

  1. Arduino Uno
  2. Temperature sensor ( TMP36)
  3. ESP8266 Wifi Module
  4. BreadBoard
  5. Jumper Wires
  6. Arduino Cable

Arduino Uno

We all know that Arduino Uno is a basic board to learn embedded systems, it has a microcontroller called ATMEGA328P. We use Arduino not only because it is cheaper than other controllers but also it is a user-friendly board. It has the IDE where different libraries can be installed according to the requirement. In this project, we are going to embed the esp8266 module with Arduino. We can use different Arduino boards that have built-in wifi and Bluetooth module such as NODE MCU, Portenta, etc.

Temperature Sensor (TMP36)

The TMP36 is a low voltage, precision centigrade temperature sensor. It provides a voltage output that is linearly proportional to the Celsius (Centigrade) temperature. The TMP36 does not require any external calibration to provide typical accuracies of ±1°C at +25°C and ±2°C over the −40°C to +125°C temperature range. Different variants are present in the market like; TMP35, TMP37. It has 3 pins, I will discuss the connections later. The datasheet of this sensor is available on the electronics stuff online stores.

ESP8266 Wifi Module

This module is the key feature of this project. ESP8266 module helped send data to the cloud. There are so many alternatives for this module but I chose this because it is cost-effective. The cost of this module is only 149 INR. It has 8 pins and has an antenna within the module PCB. This module provides us two General Purpose Input Output pins.

Pin Connections

ESP8266 connections with Arduino:

RX(ESP)-RX(ARDUINO)

TX(ESP)-TX(ARDUINO)

Chip_En(ESP)-5v(ARDUINO)

3.3V(ESP)-5V9ARDUINO)

GPI01(ESP)-GRN(ARDUINO)

GND(ESP)-GND(ARDUINO)

No need to connect Reset Pin and GPIO2 Pin anywhere, you can leave them unconnected.

TMP36 connections with Arduino:

Vs(TMP)-5V(ARDUINO)

VOUT9TMP)-A0(ARDUINO)

GND(TMP)-GND(ARDUINO)

You can use a resistor of 220 ohms while connecting Vs pin of TMP to the Arduino 5V source pin.

Installing Libraries

Till now, we are done with connections of our hardware components, now it's time for the software part which seems to be less time-consuming but if we get stuck to some error, it can ruin our day. Don't worry I will not let it happen to you.

The first step is to download the ESP8266 library from the link below:

https://arduino.esp8266.com/stable/package_esp8266com_index.json

Go to the FILE in the Arduino IDE and select preference there, a box will appear, you have to paste this link there and then click OK.

Once you have pasted the link and clicked OK, then go to the sketch>include library> manage the library, type esp8266 in the search box and scroll down, you will get the required library there, click install.

Click on the TOOLS>BOARDS, all the ESP8266 module boards will be there, and select Generic ESP8266 Module.

Sign Up/Log In to ThingSpeak Server

Log In to the ThingSpeak server, create a new channel, select the required fields and go to the API keys, Copy the Write API key.

Code

Monitor Your Data at ThingSpeak!

Some Useful hacks that might help you troubleshoot the errors while compiling and uploading code on Arduino IDE

When you upload code on IDE, remember that you have disconnected the TX and RX wires of the Arduino board because while uploading the code these two pins are used by the Arduino board.

Connect the RESET pin of Arduino to the GND, the reason is, we are not using the Arduino controller as the prime controller, we have the ESP module which is the main controlling unit here.

Always first connect the GND pin of the ESP866 module then give it a 5V supply.

Also, in some places, you may see that the ESP8266 module is connected to an external 3.3V power supply and not with 3.3v of Arduino. The purpose of doing that is, the 3.3v pin of Arduino does not supply enough current to the ESP8266, but in my case, I have used a 5v Arduino supply which is sufficient for the ESP8266. It will not harm your module, as I have been using this module for more than a year and my devices are working well.

--

--

Kunal Sharma

Zakir Hussain College of Engineering and Technology, Aligarh Muslim University