Large-Scale Temperature Monitoring with a Raspberry Pi Zero W and TI Sensortags

Long-Range, Battery-Driven Sensors that Collect Temperature, Humidity, Air Pressure

Marcus Linderoth, Thingsquare VP of EngineeringBy Marcus Linderoth, Thingsquare VP of Engineering – September 12, 2017

Today we build a large-scale sensor network with off-the-shelf hardware: TI Sensortags, a TI CC1350 Launchpad serial gateway, and a Raspberry Pi Zero W and show the results on a map. We set up and configure data collection via the Thingsquare smartphone app and web frontend.


Hardware

Step 1: Set up the Launchpad and Sensortag hardware

To set up the Launchpad hardware, we need to upload the right firmware to their built-in SoCs. For this we need Flash Programmer 2 and a laptop computer running Windows.

Install Flash Programmer 2 from here.

Flash the serial gateway

Download the firmware image for the serial gateway:

Use Flash Programmer 2 to flash the firmware to the Launchpad: plug in the Launchpad in the laptop and flash the firmware file to the Launchpad. (Detailed instructions on how to use Flash Programmer 2 here.)

Flash the TI Sensortags using the Launchpad

Download the firmware image for the Sensortags:

Use Flash Programmer 2 to flash the firmware to the Sensortags. Note that you may use the Launchpad’s onboard XDS110 JTAG debugger to flash the Sensortag, as Sensortag hardware has no JTAG debugger. If so, make sure to remove all jumpers on the Launchpad before connecting it to the Sensortag. The Sensortag should then appear in Flash Programmer 2. When all Sensortags have been flashed, restore the jumpers again to restore regular Launchpad functionality.

Step 2: Connect the Launchpad to the Raspberry Pi Zero W

Plug the USB cable from the Launchpad to the USB port on the Raspberry Pi Zero W (not the power port). You will need to use the USB OTG adapter between the Launchpad’s USB cable and the micro USB port of the Raspberry Pi Zero W.

The Launchpad should start blinking red.

The TI CC1350 serial gateway connected to a Raspberry Pi Zero W.

Step 3: Configure the Raspberry Pi

The Raspberry Pi will act as a gateway, with one Launchpad connected to its USB port. The Raspberry Pi bridges the low-power wireless mesh and the Internet and must be connected to a WiFi network for this setup to work.

The Raspberry Pi must be connected to the Internet via its built-in WiFi. Make sure to set this up before starting the rest of the configuration.

The Raspberry Pi will run a serial line IP (SLIP) interface on the USB port that is connected to the Launchpad and a NAT bridge to the WiFi network.

To set up the necessary steps, log in to a terminal on the Raspberry Pi and run the following command:

curl https://www.thingsquare.com/script/setup-slip.sh | sudo bash

(See the actual commands of this script here.)

This will produce an output similar to this:

pi@raspberrypi:~ $ curl https://www.thingsquare.com/script/setup-slip.sh | sudo bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1470  100  1470    0     0  14747      0 --:--:-- --:--:-- --:--:-- 14848
This script will set up your Raspberry Pi as a serial gateway
420
exit 0

843
Installing dnsmasq
Reading package lists...
Building dependency tree...
Reading state information...
The following NEW packages will be installed:
  dnsmasq
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/16.0 kB of archives.
After this operation, 73.7 kB of additional disk space will be used.
Selecting previously unselected package dnsmasq.
(Reading database ... 34431 files and directories currently installed.)
Preparing to unpack .../dnsmasq_2.76-5+rpi2_all.deb ...
Unpacking dnsmasq (2.76-5+rpi2) ...
Setting up dnsmasq (2.76-5+rpi2) ...
Processing triggers for systemd (232-25+deb9u1) ...
Configuring dnsmasq
Device must reboot to complete setup. To reboot, type "sudo reboot" (without quotes) and hit enter.
pi@raspberrypi:~ $

Reboot the device to complete the setup:

pi@raspberrypi:~ $ sudo reboot

After some time, the serial gateway Launchpad should start to blink green.

Step 4: Configure the wireless network with the app

Install the Thingsquare app on your iOS or Android phone.

Turn on Bluetooth on your phone.

Open the app and tap Nearby. You should now see the serial gateway and the Sensortag devices.

The gateway and the Sensortags are shown as nearby devices.

Tap the gateway and tap the Invite button.

Invite the device via the gateway.

The Sensortag devices should start blinking green. After some time all Sensortags will have connected and registered with the backend server.:

Once the Sensortag is up and running, tap on it to see its details.

Finally, tap the Remote button to enable remote access to the devices. You will need to register an account in the app and will also be able to access the Sensortags from the web interface.

To see the Sensortags and the serial gateway via the web web interface, tap `Remote` to enable remote access. You will be asked to create a login first, if you have not yet done so.

Step 5: Configure the data collection rate

Configure the sensor data send rate via the app.

Configure how often you want the Sensortags to report sensor data. For each Sensortag, tap the Sensortag and then open the Power Consumption page. Tap Sensor sample period and select a suitable report period. Configure the Sensortags to run in Lifetime power mode, allowing them to be run on batteries. Finally, tap the Apply Configuration button to push the new configuration to the Sensortag.

Step 6: Place the Sensortags

Deploy the Sensortags by placing them one by one at the locations where they should report data.

To see if a Sensortag is in range, press the button on the side of the Sensortag. The Sensortag should beep if it is in range.

To figure out if a Sensortag is in range, press the button. The Sensortag should make a sound if it is in range.

Final step: Check your latest temperature readings

Now that we have set everything up, it is time to sit back and enjoy the sensor data on the map. After some time, you can also see the sensor data history for each Sensortag.

To see the latest sensor data readings of a Sensortag, tap it to display the Sensortag details and then tap the sensor value shown in the upper part of the screen. A chart containing the most recently reported sensor values appear. Note that you can select among multiple different sensor types by dragging the mouse.

To see the latest sensor data readings of a Sensortag, tap it to display the Sensortag details and then tap upper sensor value to display a chart. Note that you can select among multiple different sensor types by dragging the mouse.

Get started!


Get your own tailored IoT solution

Instead of recruiting a full development team, let us build a tailored IoT solution for you – from prototype to product. Tailored prototypes at a fixed price!



Get in touch – we'd love to hear how we can help you achieve your goals!

Get in touch!


Be in good company
Get in touch with us!

Get a quote!


Be in good company
Adam Dunkels

Adam Dunkels

CEO

Fredrik Rosendal

Fredrik Rosendal

CTO

Marcus Linderoth

Marcus Linderoth

VP Engineering

Setting things up...