Home Iot Database

What was the problem?

  • The first problem that I originally came across that prompted this project was learning how an unconditioned crawlspace could end up causing a lot of issues for my house down the road.

  • The second problem I had was that every time I had an idea for a sensor, I would have to make new scripts, which became another codebase I had to maintain.

What was the Solution?

  • I wrote a C++ program for an ESP8266 (Wi-Fi enabled microcontroller) that would allow me to use any compatible sensor and send that data to a Google Sheet.

  • I wrote a JavaScript Web App using Google App Script to organize this data on the Google Sheet and make it accessible via API calls for other projects.

What technologies were used?

  • ESP8266

  • DHT22 (Temperature & Humidity Sensor)

  • JavaScript

  • Google App Script

  • Webhooks

  • Google Sheets

How did I execute?

Flexible ESP8266 Program

“The ESP8266 is a low-cost Wi-Fi microchip, with built-in TCP/IP networking software, and microcontroller capability” - Wikipedia.


I bought sensors and wrote a small program on the ESP8266 that would read the values of the sensor and then hit an If This Then That (IFTTT) Webhook. The Webhook was tied to an IFTTT automation that would take the values sent to the Webhook and append them to an existing Google Sheet.


With a few variable changes, this program was able to be used for any sensor project that used an ESP8266. This allows me to very quickly be able to start new projects and start collecting data.

Sorting the Data in the Google Sheet

Every sensor I set up in my house would be sending data to the same Google Sheet, so I needed a way once the data was added to the Sheet to be moved to the proper Sheet. I wrote a JavaScript program in the Google App Script environment that would, on fixed intervals, move the new data into a sheet based on its location and the sensor type. For example, every time a new humidity reading came in from the crawlspace, the data would be moved to crawlspace-dht22 Sheet if a sheet did not exist for the location or the sensor type, a new sheet would be created and named based on the naming convention location-sensor.

Making the Data Accessible to other Projects

As I mentioned above, one of the main problems I was trying to solve with this project was re-writing code every time I had a project idea involving sensors. In the past, every time I had a project it would get its own unique Google Sheet that would house the data. But with this project, I have one centralized Sheet that houses all the data, and the way my projects can access this data is via a Web App.


To access the data, you would need the Web App URL and then attach a series of query parameters to the end of the URL (see below). You could then use a GET request from any program to get the data you want, if it exists and if you have a unique key.


`?location=${loc}&sensor=${type}&start=${start}&end=${end}&key=${key}`;


The data would come back as an array of JSON objects, and I would have to create a small script to parse out the specific data that I needed for each project.