Pippa’s weight scale on data.sparkfun.com

Dog Weight Scale Part 14: Uploading Data to Data.Sparkfun.Com

In my previous post I finished the hardware for the scale and calibrated it. This post covers getting data from the scale to Sparkfun’s Data Warehouse (Update: by 2021 the site has been taken down).

By the way, the nRF Master Control Panel (BLE) from Nordic is the perfect tool for debugging Bluetooth Low Energy devices and messages. It understands a pile of standard Bluetooth data types as well as the Physical Web, so it’s a quick way to find out whether your Arduino project is sending the right data.

As you can see from the screenshot below, the scale is sending the Bluetooth Standard Weight Scale data: flags about what the scale supports, plus a weight measurement, in kg, and a user ID for that weight.

The Scale Data appearing in Nordic’s BLE debugging app
The Scale Data appearing in Nordic’s BLE debugging app

Once I could see that the scale was sending the right data, the next step was to set up a Raspberry Pi 3 to receive and process that data, using Node.js. I was surprised to find that although one big selling point of the Pi 3 is its built-in BLE device, it took me a while to find all the bits and pieces needed to configure the Pi to do BLE communications from Node.

My resulting “how to” notes are in the CurieBleWeightMonitor GitHub repository, under piconfig.txt. That file describes how to configure the Pi out of the box, how to bring Bluez – the Linux Bluetooth stack – up to date, how to install a current version of Node.js, and how to install Sandeep Mistry’s Noble library for doing BLE I/O in Node.

My next step was to (re)learn Javascript in Node – it was a breeze. After learning a few basics about Javascript, such as the Event Loop, I wrote a script that happily read data from the scale once per minute.

The next step was to a) setup a cloud to store the scale’s data, and b) write code to transfer the weight data to that cloud.

data.sparkfun.com (update: since taken down) is a wonderful thing for IoT (Internet of Things) experimenters: it offers public, free data storage for data from whatever devices you want to create. It was a matter of minutes to setup a Stream to store the data from the scale: total weight and the weight sensed by each of the four Load Sensors.

Update: with data.sparkfun.com down, you can instead write code for your web site to store and retrieve the data with an SQL database.

Armed with the public and private keys from creating that Stream, I wrote more Node code to format the weight data for Sparkfun and to upload it. You can (could) browse the resultant data at the Pippa Dog Bed Weight stream on data.sparkfun.com.

Pippa’s weight scale on data.sparkfun.com
Pippa’s weight scale on data.sparkfun.com

My next step is to configure that Node program as a Linux Service so that it runs when the Pi is plugged in. Once that’s done I can put Pippa’s bed on the scale, plug in the Pi, and start looking at real data.

To recap: I have built a simple IoT (Internet of Things) implementation involving a BLE sensor, a BLE-to-Wifi gateway, and a cloud data warehouse, and all the code is Open Source on GitHub. Imagine what you can build by modifying that code to, for example, track how much sunlight your living room gets over the year, how often you have visitors over, or when and how often your dog drinks from her water bowl.

In my next post, I turn the Node script into a daemon that runs at power-up, and I install the scale under Pippa’s bed – the end is in sight.