top of page

Log temperature using IFTTT

Updated: May 2, 2020

Time to cook: 120min

Difficulty: +++++



Based on the Solar boiler project, we are going to log the temperature from the 3 temperature sensors (Boiler, collector and Hot water outlet) into a google sheet. For this we are going to use the IFTTT service.


IFTTT (If This Then That) is a free web-based service to create a chain of simple conditional statements. More information about the IFTTT platform can be found in chapter2 where we cover the ingredients for this cookbook.


 

Ingredients


Prerequisites

  • An IFTTT account

  • An AllThingsTalk Maker account

  • A Google account, with access to google drive/sheets

  • A Hot solar device (cfr recipe xxx)

Tools


 

The Building Plan


Setting up Webhooks


  • If you don’t have an account yet on IFTTT, register first on ifttt.com

  • Log in to your IFTTT environment

  • Search for webhooks and select the Webhooks Service under Services




  • Select webhooks and Click on connect


Note : This has activated the Webhooks service within our IFTTT account and generated a private key to be used with the webhook service.


More about webhooks can be found in chapter3 where we talk about different technologies for a system of systems architecture.


When you click on ‘documentation’ in the right upper windows, you will see your key and an example of how you could trigger an event using webhooks. There is even a way to test it out!





Create an IFTTT Flow


Lets create a simple flow using the Google sheet applet.


  • In your account settings, select ‘Create’


You will see the If This Then That flow, allowing you to create your own service.



  • click on the first + sign in the flow

  • In choose a service, enter webhooks

  • Select webhooks, then select ‘receive a web request’

  • Enter a name for your event. This will be the name used to trigger the event. As we want to log the temperature from our Solar hot water boiler, let’s name it ‘hotwaterboilerlog’

  • Click, ‘create trigger’












  • now click on the second + sign in the flow

  • In choose a service, enter google sheets

  • click ‘connect’

    • You will be asked to choose a google account and give IFTTT permission to access your account. After all, IFTTT needs to be able to create a sheet and add rows to it.


  • As we want to add a row in the sheet, each time the device reports the temperature state from the boiler, collector and hot wouter outlet, select the ’Add row to spreadsheet applet’









Now we have to complete the action fields for the applet to be able to do its work.


  • You can choose to change the fields, but for our exercise here, the defaults just do fine.



With the above configuration, the appler will create a google sheet doc under the folder: IFTTT/MakerWebhooks/hotwaterboilerlog with the name ‘IFTTT_Maker_Webhooks_Events’. Each time the device reports the temperatures, a row will be created with the following information:


{{OccurredAt}} ||| {{EventName}} ||| {{Value1}} |||{{Value2}} ||| {{Value3}}



  • Click ‘Create action’

  • Click ‘Finish’


Now we have configured our flow on IFTTT, let’s test it out before we are going to implement the webhook on the AllthingsTalk Maker platform.


Test the webhook flow


Let’s go back to our Webhooks documentation and test our webhook.


  • Replace {event} with hotwaterboilerlog

  • Enter 3 values in the JSON Body, each of them will represent a temperature state from our Solarboiler device in the next



  • Click on ‘test it’, this will fire a web request.



Now have a look on your Google drive in the folder specified above. You should see that a Google sheet has been created and includes 1 row with the timestamp, eventname and the 3 temperature values we simulated with the tool in the documentation section.




Setup Webhooks on AllThingsTalk Maker


Instead of using the webhook tool in the webhook documentation, let’s fire the webhook from the AllThingsTalk Maker platform where our Solarboiler device resides (see recipe xxx).


  • Log in with your AllThingsTalk Maker account on maker.allthingstalk.com

  • Select the ground in which you have created your Solarboiler device

  • Select Rules from the left menu

  • Create a New rule

  • Drag and drop your solar device on the ‘Trigger’ field on the right pane

  • Select the 3 temperature assets ‘Boiler Tempsensor’, Solar tempsensor’, ‘Hotwater Tempsensor’

  • Drag and Drop the Webhook component on the ‘Actions’ field on the right pane

  • Select ‘POST’ en enter the webhooks url (same as the one you used in the documentation tool.

  • Add a header with key ‘Content-Type’ and value ‘application/json’

  • In the Body, add the JSON string, this time, instead of the hardcorve values, add the 3 temperature device assets (you can use the + sign for this)


The result should look similar to this:



  • click ‘save rule’


Now each time, the device reports a new temperature, a row will be automatically added in the Google sheet with the 3 values from the temperature sensors.





1 view0 comments
bottom of page