Postlad/Guides/Sensor data in Google Sheets
Log ESP32 / Arduino sensor data to Google Sheets — without Apps Script
The usual way to get ESP32 or Arduino readings into Google Sheets is a Google Apps Script web app that the board calls over HTTPS. It works, but it is fiddly. This guide takes a shorter route: the board sends one plain HTTP GET to Postlad, and the sheet pulls the readings in with a single IMPORTDATA formula.
Why not the usual Apps Script route
The common tutorial publishes a Google Apps Script as a web app and has the board call its /exec address with the readings in the query string. It is a reasonable design, and several things about it trip people up:
- It is HTTPS only. The board needs a TLS client and either a root certificate or
setInsecure(), which encrypts without checking who answered. - It answers with a redirect. A web app's reply is a 302 to a different Google host. The ESP32
HTTPClientdoes not follow redirects unless you callsetFollowRedirects(), so a sketch that looks right prints 302 and nothing reaches the sheet, or the row is written and the board never sees a reply. - Deployments are versioned. Editing the script does not change what the
/execaddress runs until you deploy a new version, which is the usual reason a fix “did nothing”. - Access settings and quotas. The web app has to be deployed so that anyone can run it, and Apps Script has daily quotas that a fast logger can meet.
None of this is a reason Apps Script cannot work. It is a reason it takes an afternoon. If you need every reading written into the sheet as a permanent row, it is still the right tool; see the trade-off below.
How this route works
- The board sends each reading to Postlad with one plain HTTP GET, for example
http://api.postlad.com/u?k=WRITE_KEY&f1=23.5&f2=61. Postlad repliesokand a number. - Postlad stores the readings and draws a live chart.
- The sheet contains one formula that asks Postlad for the readings as CSV. Google fetches it from its own servers and refreshes it on its own schedule.
No Apps Script, no Google credentials on the board, and no HTTPS requirement on the board.
1. Send readings from the ESP32
This is the sketch Postlad's setup page generates for an ESP32 with a DHT22 on GPIO 4, sending every 60 seconds. It uses the Adafruit DHT sensor library and Adafruit Unified Sensor. Make a new sketch with two tabs, paste both files, and fill in secrets.h.
// ESP32 -> Postlad
//
// Made by app.postlad.com/setup. Two things to change, both in secrets.h:
// your Wi-Fi name and your Wi-Fi password. Nothing in THIS file needs editing.
//
// Readings appear at https://app.postlad.com/streams
// DHT22 temperature and humidity -> f1 air temperature, f2 humidity
//
// Plain http:// is deliberate and supported. A board with no room for a
// certificate store still works, which is the whole point of this service.
#include <WiFi.h>
#include <HTTPClient.h>
#include <DHT.h>
#include "secrets.h"
const char* POSTLAD_URL = "http://api.postlad.com/u";
const char* STREAM_PAGE = "https://app.postlad.com/streams";
const unsigned long SEND_INTERVAL_MS = 60000UL;
WiFiClient client;
DHT dhtA(4, DHT22);
void connectWiFi() {
if (WiFi.status() == WL_CONNECTED) return;
Serial.print("Joining ");
Serial.println(WIFI_SSID);
WiFi.mode(WIFI_STA);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.print("\nJoined. This board is ");
Serial.println(WiFi.localIP());
}
// One attempt. Returns true only when Postlad stored the reading.
bool sendOnce(const String& url) {
HTTPClient http;
if (!http.begin(client, url)) {
Serial.println("Could not start the request.");
return false;
}
int status = http.GET();
String reply = http.getString();
http.end();
reply.trim();
if (status == 200) {
Serial.print("stored -> ");
Serial.println(reply);
return true;
}
Serial.print("not stored (HTTP ");
Serial.print(status);
Serial.print("): ");
Serial.println(reply);
return false;
}
void setup() {
Serial.begin(115200);
delay(300);
Serial.println();
Serial.print("Your readings will appear at ");
Serial.println(STREAM_PAGE);
dhtA.begin();
connectWiFi();
}
void loop() {
connectWiFi();
float dhtATemp = dhtA.readTemperature();
float dhtAHum = dhtA.readHumidity();
if (isnan(dhtATemp) || isnan(dhtAHum)) {
Serial.println("The DHT22 did not answer. Check the three wires, then try again.");
delay(2000);
return;
}
String url = String(POSTLAD_URL) + "?k=" + POSTLAD_KEY
+ "&f1=" + String(dhtATemp, 1)
+ "&f2=" + String(dhtAHum, 0)
;
// Three tries, waiting longer each time. A router that is rebooting takes
// a few seconds; giving up after one attempt loses a reading for nothing.
unsigned long backoff = 2000;
for (int attempt = 1; attempt <= 3; attempt++) {
if (sendOnce(url)) {
break;
}
if (attempt < 3) {
delay(backoff);
backoff = backoff * 2;
}
}
delay(SEND_INTERVAL_MS);
}#pragma once
// secrets.h — the only file with anything private in it.
//
// Keep this file off forums, out of screenshots and out of shared folders.
// The program file beside it can be pasted anywhere safely.
// Type your own Wi-Fi name and password between the quotes. 2.4 GHz only.
const char* WIFI_SSID = "YOUR_WIFI_NAME";
const char* WIFI_PASSWORD = "YOUR_WIFI_PASSWORD";
// Your Postlad write key. It can only add readings to one stream — it cannot
// read anything, change anything, or reach your account.
const char* POSTLAD_KEY = "YOUR_KEY";Upload, open Serial Monitor at 115200 baud, and look for stored -> ok followed by a number. For other boards and sensors, including a version with no sensor at all, see Send ESP32 data to the cloud, Arduino data logger online and Send sensor data with one HTTP request. The sheet side below is the same whatever sends the readings.
2. Choose the address the sheet will read
Google fetches IMPORTDATA from its own servers, without your Postlad sign-in, so the address has to carry its own permission. There are three forms, all ending in /export.csv:
| Address form | Looks like | Works for |
|---|---|---|
| Public address | /api/v1/streams/greenhouse/export.csv | Streams set to Public |
| Secret link token | /api/v1/streams/7q3m…/export.csv | Streams set to Secret link |
| Read key | /api/v1/streams/rk_live_…/export.csv | One stream you own, including a Private one |
A read key is made on the stream's page, under Read keys in the settings, and you give it a name such as “Greenhouse sheet”. Free includes one read key per stream. It can read that one stream and do nothing else: it cannot add readings, change settings or reach your account.
Treat a read-key URL in a sheet as a password. Anyone who can see the formula, including anyone you share the sheet with as a viewer or editor, can read that stream with it. If the sheet is shared more widely than you meant, revoke the key on the stream page; revoking is immediate, and the formula stops returning data.
3. Add the IMPORTDATA formula
In a new sheet, click cell A1 of an empty tab, which you could name Data, and enter:
=IMPORTDATA("https://app.postlad.com/api/v1/streams/greenhouse/export.csv?range=7d&header=bare")Replace greenhouse with your public address, secret token or read key. The parameters:
| Parameter | What it does |
|---|---|
range | A named window ending now: 1h, 6h, 24h, 7d, 30d, 1y or all. Give either this or from; the export refuses a request with neither. |
from / to | A fixed window instead: unix milliseconds, an ISO instant such as 2026-11-01T00:00:00Z, or a relative offset such as -24h. to defaults to now. The window includes from and excludes to. |
fields | Only these fields, for example fields=f1 or fields=f1,f3. Leave it out for all of them. |
header=bare | Drops the three # comment lines at the top of the file, which Sheets would otherwise import as rows. Use it for Sheets. |
flavor=excel | A version of the file written for Excel; see Excel below. Not needed for Sheets. |
The export contains full-detail readings only. On the Free plan every reading is kept at full detail for 30 days, then an hourly minimum, maximum and average for 12 months, so range=30d is the widest window that returns everything on Free. One request returns at most 200,000 rows; a larger one is refused with an export_too_large error rather than quietly cut short. A week at one reading a minute is about 10,000 rows.
4. What arrives in the sheet
With header=bare the first row is the header and every row after it is one reading, oldest first:
timestamp,epoch_ms,f1,f2
2026-11-05T09:30:00Z,1793871000000,22.8,58
2026-11-05T09:31:00Z,1793871060000,22.9,58
2026-11-05T09:32:00Z,1793871120000,22.9,| Column | Header | Contents |
|---|---|---|
| A | timestamp | The reading's time in UTC as ISO 8601 text, such as 2026-11-05T09:30:00Z. Milliseconds appear only when the reading has them. |
| B | epoch_ms | The same instant as unix milliseconds. This is the easiest column to turn into a date. |
| C onwards | f1, f2, … | One column per field, at full precision. A reading the device did not send is an empty cell, never a zero. |
The column headers are the field keys, not the names you gave the fields. The names are in the comment lines that header=bare removes, so label your chart by hand.
If your spreadsheet's locale uses a comma as the decimal separator and the numbers arrive as text, give IMPORTDATA the source locale as its third argument: =IMPORTDATA("…", ",", "en_US").
5. Turn the timestamp into a date
Sheets does not treat column A's ISO text as a date reliably, so build the date from column B. In a second tab, named Chart, put headers in row 1 and these two formulas in row 2:
A1: Time (UTC)
B1: Temperature
A2: =ARRAYFORMULA(IF(Data!B2:B="", "", Data!B2:B/86400000 + DATE(1970,1,1)))
B2: =ARRAYFORMULA(IF(Data!B2:B="", "", Data!C2:C))Select column A and choose Format → Number → Date time. For a single cell, =B2/86400000+DATE(1970,1,1) does the same job. The result is UTC; to show local time, add your offset in days, for example +1/24 for UTC+1. A fixed offset does not follow daylight saving changes.
If you prefer to work from the text column, =DATEVALUE(MID(A2,1,10))+TIMEVALUE(MID(A2,12,8)) gives the same UTC date and time from 2026-11-05T09:30:00Z.
6. Make a chart
- On the
Charttab, select columns A and B. - Choose Insert → Chart. Sheets usually picks a line chart; if not, set Chart type to Line.
- Under Setup, check that column A is the X-axis and tick Use row 1 as headers.
Empty cells, where the device skipped a reading, show as gaps in the line rather than drops to zero. Add a column C for humidity from Data!D2:D in the same way to plot both.
How fresh the sheet is
Google fetches IMPORTDATA on its own servers and decides how often it refreshes. It is typically about an hour, and Google does not promise a fixed interval. Postlad has each reading the moment the device sends it, and does not cache the export, so whatever Google fetches is current at that moment.
Editing the formula makes Sheets fetch again. For a view that updates within seconds, use the stream's own share page or an embedded live chart instead of the sheet.
Excel
Excel can read the same address. Use flavor=excel instead of header=bare:
https://app.postlad.com/api/v1/streams/greenhouse/export.csv?range=7d&flavor=excelIn Excel, choose Data → From Web, paste the address, and load the result into a table. Data → Refresh All fetches it again, and the query's properties can refresh it on a timer. The Excel version of the file differs from the plain one in ways that suit a spreadsheet:
- No
#comment lines, and a UTF-8 byte order mark so°Cdisplays correctly. - Human column headers:
timestamp_utc,timestamp_local (<zone>), then each field as its name and unit, such asTemperature (°C), or its key if you have not named it. timestamp_localis writtenYYYY-MM-DD HH:MM:SS, which Excel reads as a date. It is in your account's time zone when the address uses your read key, and in UTC for a public address or secret link.- There is no
epoch_mscolumn. The numbers are the same as in the plain file.
The honest trade-off
With this route the readings live in Postlad and the sheet is a live view of them. That has consequences in both directions:
- The sheet shows whatever window the formula asks for. Rows older than that window drop off the top as new ones arrive, and readings past your plan's full-detail period are no longer in the export at all.
- If you need every reading appended to the sheet and kept there forever, the sheet has to be the place that stores them, and Apps Script, or a scheduled copy of the imported values, is still the tool for that.
- In return, the board sends plain HTTP to one fixed address, there is no script deployment to manage, and you get a shareable live chart and a CSV download of the same data. CSV export works on every plan.
Moving from ThingSpeak and its own CSV? See Migrate ThingSpeak CSV to Postlad.
Troubleshooting
The sheet shows an error instead of data
Open the same address in a private browser window. If the reply says no stream is published at that address, the slug or token is wrong, the stream is private, or the read key was revoked. A reply about the range means range or from is missing or misspelt; range names are lower case.
The first rows start with #
Add &header=bare to the address.
The dates are numbers like 46,000
That is a correct date without date formatting. Select the column and choose Format → Number → Date time.
New readings are missing from the sheet
The device may be fine and Google may simply not have refreshed yet. Check the stream page in Postlad: if the readings are there, the sheet will catch up on its next refresh.
FAQ
Do I need Google Apps Script?
No. IMPORTDATA is a built-in Sheets function that reads a CSV address. You need Apps Script only if you want readings written into the sheet as permanent rows.
How often does the sheet update?
Google decides how often it refreshes IMPORTDATA, typically about an hour. Postlad has each reading as soon as the device sends it; the sheet catches up on Google's schedule.
Can I use a private stream?
Yes, with a read key in the address. Anyone who can see the formula can read that stream with it, so revoke the key on the stream page if the sheet is shared more widely than you meant.
Which column is the timestamp?
Column A is the time in UTC as ISO 8601 text and column B is the same instant in unix milliseconds. Divide column B by 86400000 and add DATE(1970,1,1) to get a Sheets date.
Does this work with boards other than the ESP32?
Yes. Any board or script that can make an HTTP GET request can send the readings, and the sheet side does not change.
How much data can the sheet pull?
Up to 200,000 rows per request; a larger request is refused rather than cut short. On the Free plan the export reaches back 30 days, because it returns full-detail readings only.
Start logging
Create a free account, put the stream's write key in secrets.h, and paste the formula into a sheet once the first readings arrive.
Related guides
- Send ESP32 data to the cloud: the device side in more detail.
- Send sensor data with one HTTP request: the same request from any board or script.
- Embed a live sensor chart on any website: a view that updates within seconds.
- ESP32 BME280 weather station: temperature, humidity and pressure.
- DS18B20 temperature logger: a waterproof probe for liquids and soil.
- Greenhouse monitor with ESP32: a project that suits a weekly sheet.
- Raspberry Pi data logger: the same idea from Python.
- Free IoT dashboard for students: sharing and retention for course projects.
Sources and verification
- Postlad read API, including the CSV export: https://app.postlad.com/docs/api
- Google Sheets
IMPORTDATA: https://support.google.com/docs/answer/3093335 - Apps Script web apps and quotas: https://developers.google.com/apps-script/guides/web and https://developers.google.com/apps-script/guides/services/quotas