Logging Data to Google Sheets with the Tessel 2

Pages
Contributors: D___Run___
Favorited Favorite 1

Introduction

My family just became the proud new owners of an upright piano. This piano was owned by my wife’s grandmother and is somewhat of a family heirloom. It comes with great emotional value, and it’s only natural that we want to take care of it. After moving the piano into our house (not an easy task), my wife made the important call to “the piano guy” to talk about tuning it, cleaning it and general care.

piano

I was sitting close by and overheard the mentions of “temperature swing” and “humidity range.” If either fell within a certain range, the piano would need to be placed in a certain spot in the room versus another. Upon hearing this, a smile crept across my face, recognizing the birth of a new project. In fact, my wife literally told the man over the phone, “Temperature range? My husband can take care of figuring that out for you, and we will let you know.” He is going to get more than he bargained for!

Thus, I set about using the Johnny-Five Inventor’s Kit to log the temperature and humidity of the room.

Logging is Never a Question of Why, but How!

Collecting data in a reliable and useful way is always a challenge. When it comes to embedded electronics/computers, the challenge is not so much a matter of collecting a large volume of data as it is the challenge of storage size, formatting the data output and post processes.

This tutorial will focus on collecting data using a Tessel 2 and a single sensor that comes in the Johnny-Five Inventor’s Kit to monitor and log the air temperature and humidity in the piano room in my house.

As you will see in this project, managing data collection, formatting that data and processing it can be simplified by using Node.js and leveraging the huge community that supports it through its package manager called NPM.

We will look at two different ways to log this data, format it and bring it into Google Sheets to be able to graph it and share it easily with others.

More Than One Way to Skin a Cat

As with any electronics project, there is more than one way to do this! We are going to look at two different approaches to accomplish the same task using the Tessel 2. The main difference between the two methods being whether or not you have a WiFi/network connection.

This has been written as a “choose your own adventure” of sorts when it comes to the firmware for this project. One way is to use the file system and a USB drive; the other is to use an IoT service called IFTTT. Each script has its own section that will break down the code for you, and then we will tie up any loose ends.

Internet-Connected Method

IFTTT Logo

If you have a connection to a the internat, either through WiFi or Ethernet, you can use the node module for If This Then That (IFTTT) to build an IFTTT recipe to send data to a Google Sheet using the Maker Channel. This is the preferred method if you are in a situation where you have network connection, as you will be able to view the data from your Google account in real time and see changes almost immediately.

Local, Offline Method

local version

The second way to do the same thing but with a little more work on your part, is to set up the Tessel 2 to log the data to a USB mass storage device and then periodically pull the data from it and manually add it to a Google Sheet. This is obviously more work on your part, but in cases where there is poor or no network connection, it’s a great alternative.