We often need to log data to different platforms. Due to the wide popularity of the NodeMCU, it is now possible to Log data to a secure and easy to access data sources like Google Sheet. Today, we are going to log temperature sensor data to google sheet using nodemcu esp8266. The reason for choosing the Google Sheet is because it is already widely used spread sheet platform among different applications. The NodeMCU is our every time favorite due to its huge functionality in a very low price which will help us log temperature sensor data to google sheet. So let’s get started.
Required Components
We are going to reuse our previous ds18b20 interfacing circuit with NodeMCU, so all we need is a
- ESP8266 NodeMCU board
- DS18b20 Temperature Sensor
- Breadboard
- Male to Male Jumper Wires
- Valid Internet Connection
Circuit Diagram
We are going to reuse our previous circuit, so the diagram is also pretty similar to our previous one.
Create Google Sheet and Find Sheet ID
Now you need to prepare your google sheet to receive the data. I created a new google Spread sheet and named it with Temperature Logger. I need to find the SpreadSheetID which is embedded into the url. Here is the url of my spread sheet
https://docs.google.com/spreadsheets/d/1RaJn7Rwd88t0w3VjhnbPg0bZ1A5sX5QbUpU_AMBJ_bQ/edit#gid=0
Code language: JavaScript (javascript)
According to above url This will be my sheet ID
1RaJn7Rwd88t0w3VjhnbPg0bZ1A5sX5QbUpU_AMBJ_bQ
(Note: If you tried to open the sheet and it did not open, this could be because I had deleted the sheet or it is protected)
API Credentials
Next we need to find the credentials for the Google Sheet API. For this, you need to go to the developer console. Once you are in, all you need to do is to first create a new project if there is no project in your developer console. After that enable the Sheet API . There is also Google oAuth Playground if you wish to play around. You must check that as well.