text.skipToContent text.skipToNavigation

WiFi Datalogger

Download Project Resources View on Github

Deprecation Notice:

Note: This project has been replaced by Jaycar-Electronics/Motherload-Datalogger. You can also check out Jaycar-Electronics/Intruder-Alert for a project that uses the IFTTT service

Use ESP8266 and IFTTT Services to control the cloud

Do you have a garden or home-brewing set up that you need to monitor multiple things at once? This project uses the popular "IF THIS THEN THAT" service (IFTTT) with the MCP3008 chip to send your sensor data to the cloud! Example code has Google sheets and Gmail functionality, and 3 sensors are bundled below. Try out all 3 or mix and match your own.

Bill of materials

QtyCodeDescription
1XC3802ESP8266 board
1ZK8868Microchip MCP3008 8ch ADC
1HP9550Prototyping board
1WC6026Socket socket leads
1XC4494Temperature sensor
1XC4604Soil moisture sensor
1RD3485Light dependent resistor
1HM3211Header pins
1RR059610k resistors

Software & Libraries

This project uses the IFTTT service, found at

It also uses the following arduino library:

LibraryAuthorVersion
ArduinoJsonBenoit Blanchon6.11.2

System overview

system overview

Luckily for us, the heavy lifting is done through the IFTTT service, which makes things a lot simpler. IFTTT Provides a url that we can access with our ESP8266 and send data to; When the data is uploaded, IFTTT can then apply it to any other service that you want; in our case we will put it on a Google Sheets spreadsheet.

The XC3802 board only has 1 analogue pin, up to 1 volt, which is pretty insufficient for most cases, so we use the MCP3008 chip (ZK8868) as our Analog to Digital converter (8 channels, 5V, 10bit resolution - beefy!) and receive the information on the ESP to send to IFTTT.

One limitation of the free IFTTT service is that you can only upload 3 values at a time, but that can be overcome by the ArduinoJson library or by doing some bit manipulation

Circuit Connections

The general connections are very simply connecting the MCP to the ESP.

schematic

Looking at the MCP datasheet, the entire left side of the chip are the analog channels, and the right side of the chip has our SPI connections on pins 10,11,12 and 13, making the wiring very easy.

MCP3008XC3802Description
10D8Chip select
11D7SPI MoSi
12D6SPI MiSo
13D5SPI CLK

Laying it out on the circuit board makes for easy work

layout

Here we used the headers from the pack of the XC3802, and broke the 28pin header into the 3x8 grid next to the chip, looking under the board shows why:

underside

With the ease of this HP9509 prototyping board, the 3 pins next to the chip's position has 2 rails and the chip leg connection. This makes for super simple work to connect up the power and ground rails across the whole grid so that every sensor has it's own +5V and GND.

We also bridge the AGND and Vref of the MCP3008 to the Ground and 5V rails respectively; as we want the full 5V range to be available on the ADC conversion.

Then Bridge the 5V and GND from the XC3802 board to the correct rails. Make sure you know which one is which, as it is reversed when you look at it from the underside!

IFTTT Setup

IFTTT is easy to set up; feel free to skip this part if you're comfortable. We need to make a new applet that connects the google sheet service to the "Maker" Service which provides our URL for us to send data to.

Start with creating an account and logging in, then press "new applet"

First click the blue "This" to create the first part of our setup, which is "receive a web request" - as in: "WHEN we receive a web request ( coming from our ESP) THEN ..."

You can call the event anything you want, ours will just be log_minute

Then we click on the blue "That" to set up the result of our trigger;

You can see there are many services that you are able to use; including gmail and our google-sheets.

We just want to "add row to spreadsheet" for our purposes; This is just a simple datalogging tutorial project; you can really do a lot more with this service.

Once that service is made, you're finished, you will just need your webhooks key to put in the arduino code so that the ESP can trigger the right event you want.

Sensors

Each of the sensors should have a S as well as a - and + - use this to connect to the header grid, noting which pin is positive. It might be best to mark which row has positive and which has negative so that you do not get confused down the track.

The only exception is the LDR which needs a bit more manual set up. This is a simple Voltage Divider circuit, with one of the resistors being the LDR.

We used 3 leads to solder between the resistor and the LDR,

Integration

Once you have the circuit made and ready to upload data, you need to first check your webhooks in IFTTT to get the correct key and event name.

Firstly, Click on your services tab, then click on webhooks.

In the webhooks service, you can find settings in the top right, which will provide you with a Account URL. The final part of this URL is your KEY.

In the datalog.ino, you can see the URL which has EVENT_NAME_HERE and YOUR_KEY_HERE - replace these with what your event name and key is, so that it is all one string variable.

const char* URL = "http://maker.ifttt.com/trigger/EVENT_NAME_HERE/with/key/YOUR_KEY_HERE";//should become ->const char* URL = "http://maker.ifttt.com/trigger/log_minute/with/key/asdf1234qwetyuiopetcexample";

There is also the variables for your WiFi SSID and password as well.

const char* WIFI_SSID = "wifiName";const char* WIFI_PASS = "wifiPassword";

Connect up the ESP, change the board type to WeMos D1, and press upload. You can open the Serial monitor and view what it is doing to debug any issues.

Use

Once the data is uploading you can use it for any purpose. You could connect different soil / moisture / wind-speed type of sensors and make your own weather logger. The information is transmitted and stored proportional to the voltage on the MCP3008's pins, between 0V and 5V.

evidence

When in google sheets, you would be able to select the data and produce charts and graphs over time, and other statistical work.

Future improvements

Through IFTTT you can easily connect this service to any other out there; Gmail is an obvious example, but how about notifying your rpi server?

Got more ideas with what we can add to it? Submit a github issue and get collaborating!

Further reading

Please note, Jaycar does not support nor endorse any of the below links, nor offers any guarantee of their quality or suitability for your needs.