BalenaBlocks are pre-built container images that developers may use to add important functionality to their multi-container apps, allowing for rapid prototyping and development. In this tutorial, you will learn how to easily integrate Ubidots into your balena app by adding the Ubidots block to a Fleet.

Requirements

Table of contents

  1. Create a balena app or project

  2. Add the Ubidots Block to your project

  3. Deploy your app using the balena CLI

  4. Verify incoming data in Ubidots.

NOTE: In the tutorial, it is assumed that you already know how to create a fleet and a device in balena, in case you need guidance on how to do it you can check the balena documentation here , and also you can refer to the first two steps of this tutorial to get started with balena and Ubidots.

1. Create your app

You can use any of the examples found in this repository, for this tutorial, we’ll use the Python version and we will create the app or project on a local computer by copying the example found there.

The code inside the main.py file generates random data which is sent to a device and also to a variable using MQTT to a broker running in the Ubidots Block.

2. Add the Ubidots block to your project

The docker-compose.yml includes the Ubidots balenaBlock container along with its required MQTT network and the volume. Whenever you want to add the Ubidots block to a balena app, make sure to include our image, network, and volume in your docker-compose.yml file as follows.

version: '2'

services:

ubidots-balena:
image: bh.cr/ubidots/ubidots
networks:
- ubidots-mqtt
restart: always
volumes:
- ubidots-config:/ubidots/config

networks:
ubidots-mqtt:

volumes:
ubidots-config:

Don't forget to include your Ubidots token as a device variable as can be seen below.

3. Deploy your app using the balena CLI

While standing on the folder where you have your project, log in to your balena account using the balena CLI and then run the command:

balena push <name of your fleet>

image.png

Once the process concludes you will see the release id and version along with the image of a unicorn.

image.png

4. Verify data transmitted to Ubidots

You should be able to see the data received by Ubidots in your account as follows.

The Device label will be the same as the UUID provided by balena.

Others also found useful:

Did this answer your question?