Mbed-os-example-client in practise

Few days ago ARM mbed team introduced us the new MBED OS 5.

So we decided to test the new OS with measuring ambient temperature and logging it to the cloud.


Multiple interesting spots for measuring ambient temperature which are far from the router.


6LoWPAN mesh network. Nodes are capable of forwarding messages, so we can solve our coverage problems.

Technology used:


  1. Importing Mbed-os-example-client to the online compilerEasiest way:


On the right site of the page we have Import into Compiler button. Just import it and that’s it.

  1. Initial setup of demo application


First thing is to define connection type in “mbed_app.json”. We tested mesh-thread type. Another thing is to get a client side certificate, for communication with mbed Device Connector.

  1. Reaching node through mbed Device Connector.


For connecting our mesh to the internet we are using mbed 6LoWPAN gateway router (with ThreadStatic.bin). To see if device is online and reachable trough mbed Device Connector, lets go to My devices > Connected devices. Here, we can see our connected devices. With Api Console, we can check the device resource: 3200/0/5501 (Number of presses SW2 on K64F board). If we get the response -> wohoo, we can communicate with our board.

  1. Adding new temperature resource to the application


Ok, so now we need a temperature sensor (we used mbed application shield which has a LM75B temperature sensor). Add driver library to our project. In our main.cpp we add a new temperature resource and update it every 5 seconds.

  1. Adding upgraded application to 4 more nodes


Now if everything is ok and if our temperature resource is reachable through mbed Device Connector, let’s add more K64F boards with app shields. Of course we have to generate additional client certificates.

  1. Building Python application for retrieving data from mbed Connector API and logging data to the database


Probably we don’t want to check the temperatures in the Device Connector and write it on a piece of paper . So let’s write some Python script that will do that for us, but we’ll use a database instead of a paper… There is a nice Python library https://github.com/ARMmbed/mbed-connector-api-python. This library uses the requests library to interface to mbed Connector via HTTP REST calls. For secure communication we must initialize a Connector instance with an API token from the Access keys. Now we can use simple GET request which returns asynchronous request response, or we subscribe to a resource to automatically be notified of changes to resource values. And when we receive the temperature value, we write it in a database.

  1. Python application for plotting data and publishing to the server


Another option is to build a web app, but for a quick test we used nice Python library Plotly. You can even use offline plot capability for generating interactive plot export in html and put it on your server.

  1. Debugging


For debugging purposes we used a Raspberry pi, for logging serial data from nodes or board router. And in the Python application for retrieving data from mbed Device Connector, a function for log responses from Device Connector.




Graph: Temperature 1


Graph: Temperature 2


Graph: Temperature 1 – mbed OS 3


And long log files .


Graphs “Temperature 1” and “Temperature 2” are logged temperature from the nodes, compiled with new mbed OS 5.

Graphs “Temperature 1 – mbed OS 3” and “Temperature 2 – mbed OS 3” are from the similar source code but constructed for mbed OS 3.

As it is seen from the graph, thread-mesh application on top of new mbed OS, it is not as stable as it was on older OS. This is due to an early release and some significant changes made within new mbed OS 5.

Biggest are:

  • RTOS instead of MINAR event scheduler
  • Simplified tooling: Python CLI instead of yotta and Online compiler support
  • Compatibility: due to RTOS, all legacy components and libraries of mbed OS 2 (“Classic”) ecosystem compatibility

So there are still issues in the source code of OS and other libraries, but new commits are being pushed on an hourly basis.

Away from an Online compiler, we additionally tested compilation with mbed CLI. Either way compilation was successfull.

Now it’s time to make it stable, so stay tune for a new blog posts!



By continuing to use the site, you agree to the use of cookies. More info

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.