Create a power-saving temperature logger with obniz Board 1Y

Make things

The obniz Board 1Y now has a sleep function. By using this feature, we can create a device that can run for a year on batteries alone.

This time, we will create a program to write the measured temperature in a spreadsheet periodically using the sleep function.

Leverage obniz’s serverless events and IFTTT to ensure that the temperature is periodically recorded in a spreadsheet. Once you’ve written to the spreadsheet, the obniz Board will sleep.

※The measurement interval has been changed in the movie.

Materials

How to make

Hardware Connection

Connect the obniz to the temperature sensor as shown in the following table.

obniz SHT31
0 +V
1 SDA
2 SCL
3 ADR
4 GND

[参考] obniz parts library(SHT31)

Software

Connecting IFTTT and Google

I’m going to use IFTTT to describe it in a Google spreadsheet, but before I do, here’s a quick introduction to what IFTTT is all about.

IFTTT is a service that allows you to do “If XX (This) happens, then XX (That) will be executed. To illustrate with a concrete example, you can create things like “When it’s tweeted, I’ll summarize the content on a spreadsheet” or “When it’s close to my house, I’ll turn on the air conditioner”.

I will create it from IFTTT at once.

First, set the “if” part. Click on “This”.

Choose a service(Step 1 of 6 )
Type “Webhooks” in the search field and click on the one that comes up.

Choose trigger (Step 2 of 6 )
Click on “Receive a web request”.

Complete trigger fields (Step 2 of 6 )
Enter ‘sleep_temp’ in the EventName field and click on ‘Create trigger’.

Next, click on “That” to set the recording destination.

Choose action service (Step 3 of 6 )
Type in “GoogleSheets” in the search field and click on the one that comes up.

(You may be prompted to select a Google account to use here. Select the account you want to use and allow access from IFTTT).

Choose action (Step 4 of 6)
Click “Add row to spreadsheet”.

Complete action fields (Steo 5 of 6)
Set the information to be described in the spreadsheet.

  • Spreadsheet name : Spreadsheet name (in this case, obniz_sleep_temp)
  • Formatted row : What kind of data is written to the spreadsheet
  • Drive folder path : Set which folder in Google Drive you want to save to

Review and finish (Step 6 of 6)
Click [Finish] to complete your creation.

Also, there are some items to check for the settings.

Go to the [Webhooks] settings page and click on “Documentation” in the upper right hand corner.

Copy the bold letters behind the word “Your key is”. I’ll use it later in the program.

Register your obniz Board!

Navigate to the obniz console and click on “Devices” → “Add Device”.

When the dialog opens, click on “Use obniz official device”. Follow the instructions on the screen to register.

Let’s write a program

Put the program in a repository to be used in serverless events.
Go to the obniz console and select “Repository” -> “Create New”.

A dialog will appear, and you can set it as follows

  • Type : WebApp
  • Access Level : Private
  • File name : your choice (in this case, sleep_temp)

Once configured, click “Create”. Then, the program input screen will appear, and you can replace it with final program.

Fix the following two areas

  • Change Your Key to a key obtained by IFTTT
  • Change OBNIZ_ID_HERE to the ID displayed on the obniz Board.

After creating the program, hover your mouse over the top left corner of the screen and click “Save”.

Configuring a Serverless Event

Serverless events are a feature that makes it easy to use obniz without having to prepare the servers that each one of you will need.

From the obniz console, click on “Serverless Events” → “New”.

Let’s set them in order.

  • Name : as you like (this time SleepTempEvent)
  • WebApp to run : Name of the program you just saved
  • Trigger : obniz Hardware Event
    • obniz : ID of obniz to measure the temperature this time
    • Event : online

Once you’re set up, click “Create”! Now you’re ready to go.

Execution

You can see it being stored in a spreadsheet every 20 minutes.

I can also see that obniz works with the screen on once every 20 minutes, and as soon as it comes online, the screen goes off and sleeps again. (IFTTT may not be immediately responsive due to possible delays of up to 15 minutes).

※The measurement interval has been changed in the movie.

Program

In this way, power-saving temperature measurement devices can be easily created using IFTTT and sleep functions.

With obniz, you can change the sleep interval on the console, even if you’re in a remote location.
It also has the advantage of being able to easily update the program when replacing a different type of sensor.

Why don’t you try your hand at using the obniz Board 1Y and create your own!