(App Ver.) 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 App’s cloud running feature 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 video.

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

[reference] obniz parts library (SHT31)

Software

Connecting IFTTT and Google

We’re going to use IFTTT to write it in a Google spreadsheet, but before we 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, summarize the content on a spreadsheet” or “When it’s close to my house, turn on the air conditioner.”

Let’s create one from IFTTT. 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. Please 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 (Step 5 of 6)
Set the information to be described in the spreadsheet.


  • Spreadsheet name: spreadsheet name (in this case, obniz_sleep_temp)
  • Formatted row: in what format you would like the data is written to the spreadsheet
  • Drive folder path: to which folder in Google Drive you would like to save

 

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.” We’ll use it later in the program.

 

Register your obniz Board!

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

When the dialog opens, click on “Add Bought Device.” Follow the instructions on the screen to register.

 

Make Your App!

Make an app to run the program. You can distribute apps you created and installed and run on each device(Please see App – obniz Docs for more details.)

If you want to run the app first without creating it yourself, install and run the following apps that have already been created.
省電力温度ロガー

For installation instructions, see Install an App and the next section, “Install your App on your Device.”

Go to the obniz console and click on “App Development” → “Create WebApp.

 

Choose “Empty” from the “obniz Board/1Y Templates” and type the name of your app in the window that comes up. Then press “Create New App.”

Then, scroll down the screen a bit and edit the app settings.

In this case, we want to use the sleep feature of obniz Board 1Y to run the program in the cloud every time the device comes online, so we check the “Run on a device become Online” box.

Also, when installing and running the app, set “Settings at Install” as shown below so that you can set an individual IFTTT API Secret Key when installing and running the app.

 

Scroll up a bit to the top and click on the “Edit Program” to enter the program editing screen.

After you get to that screen, paste the program in the 省電力ロガー link in the “Program” section below and save it. Once saved, the application is complete.

 

 

Install your App on your Device

Install the app you have created on your device. Go to the obniz console and click on “Install.”

 

Then, select the obniz Board 1Y that you would like to run the program. Also, enter your secret key of IFTTT you have kept a copy of.

 

 

The secret key you entered is used as Obniz.App.configs().IFTTTSecretKey in the beginning part of the program.

const config = Obniz.App.configs();
const IFTTT_SECRET_KEY = config.IFTTTSecretKey;

 

Finally, just press “install.”

The app automatically runs in the cloud once the device is online, so it will run automatically when you plug it in.

After your device is online, if the app status is green in the “Devices” in the console as shown below, you’ve succeeded.

 

 

Program

Please see the program of 省電力温度ロガー that have already been created.

Run

You can see it being stored in a spreadsheet every 20 minutes.
You can also see that obniz works with the screen 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 video.

At End

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

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!