Using Docker for Blinking an OpenMote B on-board LED

Program your openmote b board using docker-compose for industrial automation
February 14, 2022 by
Using Docker for Blinking an OpenMote B on-board LED
Boot & Work Corp. S.L., Fernandez Queralt Martinez

Introduction

In the previous post, we learned how to start programming our Openmote B board by flashing the onboard LED on our board.

Although in the previous post we learned how to do it using the 'make' tool, in this post we will use Docker, and Docker-compose, to work with containers, although obtaining the same result: blinking the onboard LED of our Openmote B board.

Latest Posts

Your Dynamic Snippet will be displayed here... This message is displayed because you did not provided both a filter and a template to use.

Requirements

Openmote B board


OpenMote B is an ultra low-power board to develop IoT applications in the industrial space.

It is the reference for the IETF 6TiSCG Working Group and it is supported by the most relevant Open Source 6TiSCG implementation including the Contiki NG and OpenWSN projects.

Openmote B board - Using Docker for Blinking an OpenMote B on-board LED

Docker


Docker is an open source project that automates the use of applications within software containers, it requires an additional capacity of abstraction and automation of application virtualization in multiple operating systems.

But, what is a container? A container is a sandboxed process on your machine that is isolated from all other processes on the host machine. That isolation leverages kernel namespaces and cgroups, features that have been in Linux for a long time. Docker has worked to make these capabilities approachable and easy to use. To summarize, a container:

  • is a runnable instance of an image. You can create, start, stop, move, or delete a container using the DockerAPI or CLI.

  • can be run on local machines, virtual machines or deployed to the cloud.

  • is portable (can be run on any OS)

  • Containers are isolated from each other and run their own software, binaries, and configurations.

Odoo • Image and Text

Docker-compose

Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration.

Compose works in all environments: production, staging, development, testing, as well as CI workflows.

Using Compose is basically a three-step process:

  1. Define your app’s environment with a Dockerfile so it can be reproduced anywhere.

  2. Define the services that make up your app in docker-compose.yml so they can be run together in an isolated environment.

  3. Run docker compose up and the Docker compose command starts and runs your entire app. Docker-compose run runs a one-time command against a service. For example, the following command starts the web service and runs bash as its command.

Blinking an on-board LED

Once we know the basics of openmote and docker-compose, we are now ready to run our command.

1. First of all, we are going to Install Docker-compose on our system >>>

2. Then, plug the openmote board into the USB of our computer. (Batteries and antennas are not needed)

3. Go to Our repository >>>, and click on the latest openmote-fw.tar.bz2 to download it.

Repository openmote - Using Docker for Blinking an OpenMote B on-board LED

4. Once downloaded, extract files.

tar -xvf openmote-fw.tar.bz2

5. Go to the directory.

cd openmote-fw/


6. Now, if you cat the docker-compose.yaml file:

cat docker-compose.yaml

The output should be the output below. Let's analyze it:

Odoo • Image and Text

a. First of all, we are going to see the version of docker-compose that we are going to use. In this case, 3.8.

b. You can create as many services as you want for your application, so they can be run together in an isolated environment and configurations. We created a service called 'openmote'.

c.  Build: Configuration options that are applied at build time. Build can be specified either as a string containing a path to the build context or, as an object with the path specified under context and optionally Dockerfile and args.

d. Volumes. Mount host paths or named volumes, specified as sub-options to a service. You can mount a host path as part of a definition for a single service, and there is no need to define it in the top level volumes key.

e. Stdin_open: true. It is like doing docker run -i or --interactive. It keeps STDIN open even if it is not attached.

f. tty: true: By setting to true the tty flag, we are telling Docker to allocate a virtual terminal session within the container. This is commonly used with the option above or interactive mode.

g. Devices: This is a list of device mappings. Uses the same format as the --device docker client create option.


7. So, once we know what we are going to execute, this is what we are going to do:

Let's run the project called template, with the docker-compose service called openmote. Finally, we are going to remove the container after run with the option --rm.

docker-compose run --rm openmote template


Finally, you will be able to see how your openmote B on-board LED starts blinking!

​Search in our Blog

Using Docker for Blinking an OpenMote B on-board LED
Boot & Work Corp. S.L., Fernandez Queralt Martinez February 14, 2022
Share this post

Looking for your ideal Programmable Logic Controller?

Take a look at this product comparison with other industrial controllers Arduino-based. 

We are comparing inputs, outputs, communications and other features with the ones of the relevant brands.


Industrial PLC comparison >>>