Example using IFTTT -> Google Drive

Joined the beta today I have been looking forward to IFTTT support for a long time.

Before IFTTT was available I was using a combination of spark.variable and a Google Apps script to poll the spark API to acquire the new data and add this to a spreadsheet. This worked well for the most part, there was the odd issue when the API request to check the spark variable would time out, it was also impossible to put the spark in to deep sleep mode whilst still having the variable available, this would cause issues with battery powered projects.

Here is the link to the Google Apps script if you haven’t already seen it :https://community.spark.io/t/example-logging-and-graphing-data-from-your-spark-core-using-google/2929

Now I have IFTTT support I have been able to use the spark core to take temperature and humidity readings and push them in to a spreadsheet for later use using IFTTT. Once the publish is completed the core goes straight in to deep sleep for 15 minutes.

My next plan is to have IFTTT push the current temperature and humidity readings to Numerous App using IFTTT once Numerous is released for Android. Numerous app looks pretty cool, but I do not have access to an iDevice. http://numerousapp.com

The code for this is very simple, there is no processing, the data is simply collected, formattedand thrown at the cloud using Spark.publish.

// This #include statement was automatically added by the Spark IDE.
#include "idDHT22/idDHT22.h"

// declaration for DHT11 handler
int idDHT22pin = D4; 
void dht22_wrapper(); // must be declared before the lib initialization
// DHT instantiate
idDHT22 DHT22(idDHT22pin, dht22_wrapper);
// mus be defined like this for the lib work
void dht22_wrapper() {

char publishData[] = "" ; 

void setup(){ 
    Spark.sleep(SLEEP_MODE_DEEP, 900); //sleep for 5min. 

void updateTempReadings(){
    //wait will acquiring. 
	while (DHT22.acquiring())
	int result = DHT22.getStatus();
	if (result == IDDHTLIB_OK){ 
sprintf(publishData,"%.2f ||| %.2f ",DHT22.getCelsius(),DHT22.getHumidity());

Screenshot of IFTTT recipe:

Based on the data collected this evening, it looks like the triggers have been pretty reliable. When pulling data from Spark.variable using a Google apps script I would have periods of missing data.

Screenshot of sheet + graph:


Thanks for posting this code and the details on IFTTT and that Numerous app. This should fit in nicely with what I want my Spark Core to do.

This is great @markp1989!! Thanks for sharing. What temperature and humidity sensors are you sharing?

Thanks :slight_smile: , the sensor I am using is a DHT22 pretty common & cheap with a reliable library available.

Great example @markp1989. I have mine up and running, logging data from my thermocouple. How often does you sheet update, mine looks like it is updating every five minutes. Is there some way to adjust this refresh rate?

Have you made a static graph of a specific data set or is there a way to make the graph self updating?

And another one for good measure, :slight_smile:

Like mine your graph shows the full date and time of the reading, is there a way to format this to be say a 6 digit date with a 24hr time stamp?


OK sorted it - for the self updating graph, don’t select the specific data, select the whole columns that you want on the graph, it then self updates.

Still could do with sorting out the data format though :slight_smile:

Currently it is getting the date from the IFTTT ({{createdAt}}) it should be possible to include the properly formatted time stamp from the spark core using an NTP/RTC library. I agree the date/time format provided by IFTTT is a bit strange.

To change the interval of the readings change the duration of
" Spark.sleep(SLEEP_MODE_DEEP, 900); " to something more suitable, 900sec = 15min.

1 Like