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.
Many people use the TI Sensortags as a Bluetooth device - today we are going to do something different. To allow large-scale networking, we are setting them up as a 6lowpan device. This requires use to manually flash the firmware of the Sensortags. Fortunately, with the Launchpad, we have all the tools we need to do this.
We use the CC1350 version of the Sensortags. These have a two-pronged radio that allow use to use a lower frequency (sub-1 GHz) while using 2.4 GHz Bluetooth beacons to identify devices.
Hardware- One TI CC1350 Launchpad to act as a serial gateway
- As many TI CC1350 Sensortags as you can find
- One 10-pin ARM Cortex JTAG Debug Connector, to allow flashing of Sensortags via the launchpad device
- One USB OTG host cable micro B male to A female connector to connect the serial gateway to the Raspberry Pi (like this one)
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.
Download the firmware image for the serial gateway:
slipgw1350-868mhz.bin
(Europe)
slipgw1350-915mhz.bin
(US, Oceania, Asia)
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 LaunchpadDownload the firmware image for the Sensortags:
sensortag1350-868mhz.bin
(Europe)
sensortag1350-915mhz.bin
(US, Oceania, Asia)
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.
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 PiThe 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 http://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 http://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 appInstall 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.
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.
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.
Version 3.2.6 out today! New feature: check connectivity with audio - anyone recognize the sound? :) https://t.co/GTw5Rb2OtE #IoT #6lowpan pic.twitter.com/oAwwa5rwLG — Thingsquare (@thingsqr) September 4, 2017
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 readingsNow 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 devices on the map, tap the Select Devices
button to select which devices to see, then tap Select Data
and select the desired values: temperature, humidity, barometric pressure, etc. Use the Suggest range
button to set a minimum and maximum range for the data.
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.
Comments