กลับไปหน้ารวมไฟล์
log-temperature-data-to-google-sheets-0f9e99-en.md

A new way of logging temperature

By this time, you'd probably want a temperature sensor in the house - one less than $25. If you have one, you are probably wanting a better one. Here is an easy solution around this problem.

Creating And Deploying The Script

Create a new spreadsheet as shown below:
Once you have got that down go to Tools > Script Editor.
Create a new spreadsheet as shown below:
Name the sheet below TempSheet
Once you have got that down go to Tools > Script Editor. Then copy and paste the code given here. Edit the script ID in the code. The script ID is found in the place where "vbn" is in the given URL:
https://docs.google.com/spreadsheets/d/vbn/edit#gid=0
Now go to Publish > Deploy as web app. The "Project version" will be "New". Select "your email id" in the "Execute the app as" field. Choose "Anyone, even anonymous" in the "Who has access to the app" field. And then click on "Deploy". Note that When republishing please select the latest version and then Deploy again. Type "New Script Created" in the "Project Version" field.
You will have to give Google permission to deploy it as a web app. Just click on "Review Permissions". Then choose your Email ID here using which you have created spreadsheet.
Click on "Advanced".
And then click on "Go to 'your_script_name'(unsafe)". Here in my case, it is "TempLog_Script".
Click on "Allow" and this will give permission to deploy it as a web app.
Now you can see the new screen with a given link and named "Current web app URL”. This URL contains Google Script ID. Just copy the URL and save it somewhere.

Cloud-Based Big Data Telemetry

This project provides a professional-grade solution for logging environmental data directly into a **Google Sheets** spreadsheet for long-term analysis. - **Google Apps Script Webhook**: The Arduino (WiFi-enabled) sends an HTTP POST request to a specialized **Google Apps Script** URL. This script acts as a bridge, authenticated via a unique "Macro" key. - **Automated Row Insertion**: The Apps Script captures the Arduino's temperature and humidity data and automatically appends it as a new row in the spreadsheet, complete with a server-side timestamp.

Interaction

- **Live Spreadsheet Graphing**: By using Google Sheets' native charting tools, users can visualize the Arduino's data in real-time on any device with a web browser.

Testing The DHT22

Use the given circuit diagram and code:
Diagram:
Code:

#include "DHT.h"

#define dht_apin A0

DHT dht;

#define DHTTYPE DHT22 //Change this to any type of DHT Sensor you're Using!

DHT(dht_apin, DHTTYPE);

void setup() {

// put your setup code here, to run once:

Serial.begin(9600); //Starts serial

delay(5000); //Waits before reading from sensor

Serial.println("DHT22 Temp. And Humi. Test"); //Prints the intro

}

void loop() {

// put your main code here, to run repeatedly:

dht.read11(dht_apin); //Reads from the sensor

Serial.println("Humi. ---------- "); //Prints humidity

Serial.print(DHT.humidity); //Prints humidity

Serial.print("% "); //Marks the humidity as %

Serial.print("Temp. ------------ "); //Prints temperature

Serial.print(DHT.temperature); //Prints temperature

Serial.print("℃") //Marks the temperature unit

delay(2000); //Waits 2 seconds before doing the loop again fastest is once evrey 2 seconds

} //end loop

It should be printing the temperature and humidity. If it is not, try running this code at rate 9600 that will print "Hello!" evrey second to see if you are getting any serial communication at all:

#define one_second 1000

#define the_word_hello "Hello!"

void setup() {

// put your setup code here, to run once:

Serial.begin(9600);

delay(5000);

}

void loop() {

// put your main code here, to run repeatedly:

Serial.print(the_word_hello);

delay(one_second);

}

Now, let's move on.

ข้อมูล Frontmatter ดั้งเดิม

apps:
  - "1x Arduino IDE"
  - "1x Google Sheets"
author: "24Ishan"
category: ""
components:
  - "1x Micro-USB to USB Cable (Generic)"
  - "1x Breadboard (generic)"
  - "1x NodeMCU ESP8266 Breakout Board"
  - "1x DHT22 Temperature and Humidity Sensor"
description: "Temperature logger using ESP8266"
difficulty: "Intermediate"
documentationLinks: []
downloadableFiles: []
encryptedPayload: "U2FsdGVkX19MU5zo7Z6qh5PUkCA+4WKDLmA4qKvr4yuxqares7ezxYGEYR0URZq2ww6sqeJbxJXbQ8wAe3mfeYQ23E9/K1aGNm/LKH73R4RQ6NASzRLRCLqI/u0KuNem"
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/log-temperature-data-to-google-sheets-0f9e99_cover.jpg"
lang: "en"
likes: 14
passwordHash: "3838061c69d69d0f6650435813148fb454e3aff00757c32b3346f8ade71e07ff"
price: 1499
seoDescription: "Learn how to log Temperature data to Google Sheets using ESP8266 for simple IoT projects."
tags:
  - "environmental sensing"
  - "home automation"
  - "smart appliances"
  - "communication"
  - "data collection"
  - "internet of things"
  - "monitoring"
title: "Log temperature data to Google Sheets"
tools: []
videoLinks: []
views: 28850