How to set up Blues Wireless to backup sensor data on Raspberry Pi using balena

Learn how to use Blues Wireless as a backup method of data connectivity with your balena devices.

In this post, I’ll introduce Blues Wireless, and how to use it as a backup method of connectivity with embedded devices, like Raspberry Pis. We’ve packed the power of Blues Wireless into a balena Block so that any edge developer can add it to a fleet and provide extra connection redundancy to your devices.

We’re all used to balena covering a lot of different flavors of connectivity, all of them using the NetworkManager. NetworkManager allows balenaOS more flexibility when configuring the network setup, and, in conjunction with ModemManager, allows balenaOS to offer first class GSM/Cellular support and more. Read more here to learn how to configure your network with balena.However in this blogpost we are going to cover a connectivity technology that offers 500MB during 10 years to send a small amount of data providing worldwide cellular coverage.

NOTE: This connectivity does not provide enough data to deploy a new release and deltas on your balena devices but enables the device to send and receive data when the other networks are not available, it’s the perfect backup connectivity.

Let’s begin.


What’s Blues Wireless?

Blues Wireless provides cellular connectivity that works. Founded by industry pioneer Ray Ozzie, Blues Wireless provides the Notecard which enables a device to join a global cellular network.

The Notecard is backed by the Notehub.io cloud service, which securely manages and routes data to any cloud platform. With just a few lines of code, anything you build can be cloud-connected.

Blues Wireless Diagram

Blues Wireless provides the infrastructure for bidirectional communication between edge devices and cloud endpoints via a combination of hardware and software. On the hardware side, in the host device, the Notecard provides an internal endpoint for sensor data. Notecard securely transmits the sensor data to the customer’s preferred cloud endpoint via Notehub, an intermediary cloud application. Notehub provides protocol translation, transport security, data routing, device management, and device firmware update capability.

What is the Blues Notecard?

The Notecard is a cellular and GPS-enabled device using a M.2 key E connector. It uses the Notecarrier to connect to the main device. The Notecard can transparently use any cellular technologies such as NB-IoT, LTE-M, Cat-1 and GPRS, depending on where the devices are located. Connectivity is globally available in 139 countries and counting, and you can use the service in different regions depending on your needs. It comes pre-paid with 500 MB of data and 10 years of connectivity.

Set up Blues Wireless as a backup connectivity method for your balena fleet

The Notecard itself is a tiny 30mm x 35mm SoM with an m.2 connector for embedding on your own board. There is also the Wi-Fi Notecard which can provide Wi-Fi connectivity to devices with the same form factor.

What is Blues Notehub?

Notehub is the Blues Wireless cloud service for securely managing the connectivity of the Notecard fleets. It routes Notecard-provided data to third-party cloud applications. Notehub allows for secure communications between edge devices and the cloud without certificate management or manual claiming of devices.

Build your Blues application with balena

First, let’s set up an example application so that when we set up the Blues Wireless block, we can see the data backup use case in action. After we set up a starter application, we’ll show you how to add the Blues Notecard block on your docker-compose and send data to the block over a REST API.

If you have a real Blues use case you can connect the block to your application. If you don’t have one and need a proof of concept, this example sends a random number generated on a container and sends it over Blues to the Notehub.

Hardware required

Software required

Deploy this Notecard example

Running this project is as simple as clicking the Deploy with balena button and deploying the project to your balenaCloud fleet. Click the button below:

Once clicked, follow the instructions, click Add a Device, download the balenaOS image and flash an SD card. Enjoy the magic 🌟Over-The-Air🌟!

Add the Notecard on the Notehub

Once you have your hardware set up, you’ll next need to create a Notehub account, as well as a Notehub project for your data to flow into.

Set up Blues Wireless as a backup connectivity method for your balena fleet

  • Next, create a project by clicking the blue Create Project button.

Set up Blues Wireless as a backup connectivity method for your balena fleet

  • After you create your project, you’ll see the screen below. The ProductUID (e.g.
    io.balena.marc:balenanotecard below) is a unique identifier that you’ll need later, so go ahead and copy it to your clipboard.

Set up Blues Wireless as a backup connectivity method for your balena fleet

Add your Device Variables

  • Once you created the NoteHub project you got a project ID, copy and paste that value into the variable productID. In case you created a notefile just added as a fileID variable on the balenaCloud Device Variables.

Set up Blues Wireless as a backup connectivity method for your balena fleet

  • Once you successfully connect a device it’ll appear in this list of the Notehub, as shown below.

Set up Blues Wireless as a backup connectivity method for your balena fleet

If you’re seeing something similar to this, good job, it worked!

If you need backup connectivity on your fleet and Blues just fits that endeavor, the only thing that you need is to use the Blues notecard Block now. We tried to reduce friction on how to add Blues connectivity into your fleet once you add the Notecard to your devices.

Use the Notecard block to your fleet

Once the Notecard and Notecarriers are in place with your devices, just add the Notecard block on your docker-compose to enable your device to send data over the Blues Wireless connectivity.

To add the Blues Notecard Block on your Raspberry Pi 4 device, add this service in your docker-compose.yml, as shown below. Check the notecard blocks to see other different versions for the Raspberry Pi family.

notecard:
image: "bh.cr/blues_wireless/notecard-aarch64"
devices:
- "/dev/i2c-1:/dev/i2c-1"
expose:
- "3434"
privileged: true

Once you deploy your project with the notecard service running along, you might see it on the balenaCloud services list.

Set up Blues Wireless as a backup connectivity method for your balena fleet

How to send data to the Notehub

Once you have the new notecard service running on your balena devices, you will be able to send data over the Notecard and receive it on the Notehub using the REST API exposed on:

http://notecard:3434

The most interesting part of the blocks is that instead of coupling the source code of your project with the Blues Wireless Python SDK, you can just POST a REST API running on another service on your device. Below is an example of how to set your Notehub product UID with the hub.set request:

“`
req = {“req”: “hub.set”}
req[“product”] = “com.company.name:myproject”
req[“mode”] = “continuous”

url = “http://notecard:3434”
headers = {“Content-Type”: “application/json”}
result = requests.post(url, json=req, headers=headers)

“`

Notes:

  • You’ll need to replace com.company.name:myproject with your ProductUID that you copied in the last step.
  • Although this example shows Python code, you can write code to communicate with the Notecard in any language you’d like. All you need to do is post your requests to http://notecard:3434.
  • In case that you use other networking communication between containers maybe you will need to use localhost:3434.

And to send data to Notehub just type:

“`
req = {“req”: “note.add”}
req[“file”] = “your-notefile-name”
req[“sync”] = True
req[“body”] = {“mySensorName”: “mySensorValue}

result = requests.post(url, json=req, headers=headers)
“`

After executing this code on your device, you’ll see your device appear in Notehub. And as you add notes, you’ll start seeing them appear in the Events section of Notehub.

Set up Blues Wireless as a backup connectivity method for your balena fleet

What’s next?

This is an example of how to enable any fleet owner with backup connectivity using cellular technology. We see Blues Wireless a great example for some projects where the devices from the fleets might lose connectivity but it’s relevant that the device still sends some data to the cloud. From the Blues Notehub, it’s simple to redirect your data to other services for display or further processing.

We are looking forward to seeing how developers start using Blues connectivity on balena fleets. If you do, please share!

Acknowledgements

Thank you TJ, Rob and Brandon from Blues Wireless for helping on the Notecard block development.


Posted

in

Notable Replies

  1. Hey @mpous that looks like some really cool piece of kit. In the past I was using hologram.io with their Nova modem for an Hackster project. While the experience was ok at the time, the block integration (especially with that being able to ‘network feed’ from a bunch of microservices) and the underlying hardware with balena/blues is looking much more advanced. Hm… I think that would be really worth a comparison between both worlds :wink:

  2. Avatar for mpous mpous says:

    @nmaas87 looking forward to see you testing this technology :slight_smile: let me know if you need a kit :stuck_out_tongue:

  3. @mpous I NEVER mind cool hardware being sent my way :smiley:
    (as long as its nothing too dangerous and customs are not killing me for that / making a ruckus :D)
    My address has stayed the same, or shall I just send you a PM?

Continue the discussion at forums.balena.io

Participants

Avatar for nmaas87 Avatar for andrewnhem Avatar for mpous