ūüźć  Celebrate CircuitPython Day with us on August 19th! Sign up for our webinar: "Reimagining IoT Deployments with CircuitPython"

Today we’re happy to announce a new series of Blues Wireless Notecard balenaBlocks. The new blocks make it trivial to add a Notecard to balena projects, and allows balena users to easily and securely send data over a cellular network.

What is Balena?

balena is a complete set of tools for building, deploying and managing fleets of connected Linux devices. Devices on balena run the balenaOS, which is a Yocto Linux based host OS which only runs Docker containers through balena Engine. The balena device runs the supervisor on its own container which allows balena to continue updating the devices with the latest release deployed for the devices. The backbone of balena is the balenaCloud platform which enables you to manage your devices visually.

How does it work?

The integration between the Notecard and balena is done through a balenaBlock.

balenaBlocks allow balena developers to deploy multiple executables, run them on top of a balena base image, and wrap around them to make them easier to configure and manage. balena users can find a list of all balenaBlocks on balenaHub, and as of today, there are a series of new Notecard balenaBlocks for integrating into your projects.

Using the new Notecard blocks is as easy as adding a new service to your balena project’s existing docker-compose.yml file, as shown below.

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

(The currently supported architectures are aarch64, armv6hf, and armv7hf.)

With the service deployed, you can communicate with the Notecard by POSTing JSON requests to http://notecard:3434.

For example, the Python code below issues a Notecard hub.set command.

import requests

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)

Because the requests operate over HTTP, you can send the requests in any language that can run in a Docker container. For example, the following Node.js code sends the same hub.set request to a Notecard.

const axios = require("axios");

axios.post(
    "http://notecard:3434",
    {
        "req": "hub.set", 
        "product": "com.company.name:myproject",
        "mode": "continuous"
    },
    {
        headers: {
            "Content-Type": "application/json",
        },
    }
);

balena users can use the Notecard balenaBlock to access the Notecard’s full API. And if you’re looking for a more thorough example, we also have a complete reference application you can reference, or clone and make your own.

If you have any questions, or find any issues, feel free to reach out in our forum. And have fun building with balena & Blues!

Share on:

We’re making IoT quick and easy.

Start your IoT journey with us!

Subscribe to our newsletter

Expert tips, exciting projects, and IoT insights delivered every month