In this project, you are going to build an IoT Environment Logger using Myduino AIoT Education Kit. Your ESP32 will read temperature, humidity and light levels, then automatically send the data to a Google Sheets in real-time.
This exercise teach you:
- How to use DHT11 and LDR sensor
- How to connect ESP32 with WiFi
- How to send the sensor data/ESP32 data to Google Sheets using HTTP Requests
- How to log IoT data with timestamps

Checklist Before Start
- ESP32 Dev Module Board
- USB Cable
- Jumper Wires
- Arduino IDE
- Google Account (for Google Sheets access)
Google Sheets Setup
Before we do the wiring or programming, let’s prepare Google Sheets to receive data.
Step 1 : Create a Google Sheets
- Go to Google Sheets and log in to your Google account

- Create a new sheets > name it IoT Data Logger

- In the first row, enter headers : Timestamp | Temperature | Humidity | Light

Step 2 : Open Google Apps Script
- Click Extentions > Apps Script

- Delete any existing code, paste this scripts:
function doGet(e) {
var sheet = SpreadsheetApp.getActiveSheet();
var params = e.parameter;
var newRow = [
new Date(),
params.temp,
params.hum,
params.light
];
sheet.appendRow(newRow);
return ContentService.createTextOutput("Data Saved");
}

Step 3 : Deploy as Web App
- Click Deploy > New Deployment

- Select type : Web App
- Execute as : Me
- Who has access : Anyone
- Click Deploy

- Click Authorise access

- Choose your account

- Click Advanced

Step 4 : Copy the Web App URL


Circuit Connections

| Components | ESP32 Dev Module |
| DHT11 | IO04 |
| LDR / Light sensor | IO34 |
Logic Flow

Code Lab
Step 1: Install Library
Before uploading your code into the ESP32, you need to install some library that you need for this project.
- Open the Library Manager at the sidebar
- Type the library name in the search bar
- If you dont see at the top of the results, you might need to scroll down until you found it
- WiFi.h (already include in ESP32)
- HTTPClient.h (already included in ESP32)
- DHT.h (DHT sensor library by Adafruit)

Step 2 : Code
Copy and paste the code in Arduino IDE
#include <WiFi.h>
#include <HTTPClient.h>
#include "DHT.h"
#define DHTPIN 4 // DHT11 connected to GPIO4
#define DHTTYPE DHT11
#define LDR_PIN 34 // LDR connected to GPIO34 (Analog input)
DHT dht(DHTPIN, DHTTYPE);
const char* ssid = "YOUR_WIFI_NAME";
const char* password = "YOUR_WIFI_PASSWORD";
// Replace with your Google Apps Script Web App URL
String GOOGLE_SCRIPT_URL = "https://script.google.com/macros/s/XXXXXXX/exec";
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
Serial.print("Connecting to WiFi");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println(" ✅ Connected to WiFi");
dht.begin();
}
void loop() {
if(WiFi.status() == WL_CONNECTED) {
float h = dht.readHumidity();
float t = dht.readTemperature();
int ldrValue = analogRead(LDR_PIN);
if (isnan(h) || isnan(t)) {
Serial.println("❌ Failed to read from DHT11 sensor!");
return;
}
// Print sensor readings nicely
Serial.println("📊 Sensor Readings:");
Serial.print("🌡 Temperature: "); Serial.print(t); Serial.println(" °C");
Serial.print("💧 Humidity: "); Serial.print(h); Serial.println(" %");
Serial.print("💡 Light Level: "); Serial.print(ldrValue); Serial.println(" (ADC Value)");
// Construct URL with sensor values (with units)
String url = GOOGLE_SCRIPT_URL + "?temp=" + String(t) +
"&hum=" + String(h) +
"&light=" + String(ldrValue);
HTTPClient http;
http.begin(url);
int httpCode = http.GET();
if (httpCode > 0) {
String payload = http.getString();
Serial.println("✅ Data sent successfully!");
} else {
Serial.println("❌ Error sending data");
}
http.end();
} else {
Serial.println("⚠️ WiFi Disconnected!");
}
Serial.println("-------------------------------");
delay(10000); // upload every 10s
}
Before you upload the code, make sure to insert your WiFi Name, WiFi Password and Google Script URL correctly or it will not connect. When you sure it’s correct, then just upload the code.

Step 3 : Check the result
After upload, you can open your Serial Monitor and check if it’s appear like this. If it’s appear like that, you can check your Google Sheets.


If it’s succesfully insert the sensor data into the Google Sheets table, then your tutorial is already completely successful. Congrats!
System Check
Here’s how if it’s working properly:
- Sheets fill with new row every 10s
- Serial Monitor shows “Data sent successfully!”
- LDR values change when you cover/uncover the sensor
- The temperature and humidity data appear realistic
If nothing happens/fails:
- Check WiFi SSID and Password
- Verify your Google Apps Scripts deployed as Web App
- Make sure you copy the correct URL(Web App URL)
Troubleshooting Guide
| Problems | Solutions |
| No data in sheets | Check Apps Scripts permissions & URL |
| ESP32 upload error | Reconnect USB, select ESP32 Dev Module in Arduino IDE |
| Always 0 readings | Check sensor wiring |
| WiFi not connecting | Double check WiFi SSID & Password |
Buy from :
Myduino AIoT Education Kit from Myduino.com






