Tag Archives: development envinronment

MicroPython – MicroPython program structure

After reviewing various development tools for MicroPython in previous articles

MicroPython – Development tools Ampy – Eric

MicroPython IDE uPyCraft

in this article we briefly describe the main features of MicroPython. In particular, we examine the documentation relating to the ESP8266, but the concepts can also be extended to the other boards.

The documentation on the ESP8266 soc and MicroPython  is available at the link

ESP8266 MicroPython Documentation

At the link we can find all the informations necessary to implement the code on the card and the features of MicroPython as well as the differences compared to Python.

Here are the main points for coding in MicroPython:

  • MicroPython has a REPL (Read Evaluate Print Loop) console through the serial port to which the device is connected on which we can give the various MicroPython commands interactively.
  • The REPL console can also be accessed via connection to the IP address of the device by enabling the WEBREPL (Web Browser Interactive prompt) console

WebREPL Documentation

importing the webrepl package, enabling it and starting it at each device restart. To access the configured device, we can use the link


or locally cloning it  from github

  • At the start of the device the system runs boot.py and after main.py.
  • The MicroPython libraries are available on the github at the link

MicroPython libraries

  • Additional packages

The additional modules can be downloaded from the link of the libraries presented above or downloaded with the upip utility (Package Manager) from the REPL console if available in the Python Package Index (PyPI) repository


as described below


Below is a simple example that connects to the router and allows us to access the MicroPython console with the browser and WEBREPL.

  • boot.py code

At the first access it is required to enable webrepl to be executed in the REPL console with the command

we can activate the service and the access password.

The procedure generates the webrepl_cfg.py file on the device.

After setting up and restarting, we access the web console by opening the locally cloned webrepl.html file with a browser

WebreplPressing connect and after entering the password ,set in the initial setup, we access the console

WebreplConnectedNow we install from the WEBREPL console, for example, the stat module using upip

To paste commands  execute Ctrl+A e Ctrl+V

WebreplupipIn this case the package was taken from the PYPI repository, unpacked and installed on the device.

We have noticed that some modules, although available on the repository, give an error during installation with upip; these modules are installed directly without using the upip utility,but by downloading the library from the site listed above and transferring the code to the device.

Here is the link of the code shown above


Another option available is to build  the firmware with the required modules.

In the next article we will examine examples similar to what was done with LUA on ESP8266 in previous articles

MicroPython – Nodes examples with DHT11, Relay and MQTT




Micropython – Development tools Ampy – Eric

After the  uPyCraft  intallation in the previous article

MicroPython – IDE MicroPython uPyCraft

let’s now look at other tools available for the development in MicroPython for various platforms.

This article shows the operations to be performed on Windows and Linux.

First Python package to install is Ampy (Adafruit MicroPython Tool)


The tool is available in the python repositories, so it can be installed using the  pip tool.

In Windos run in a dos command prompt

Similarly in Linux run in a shell

The available commands are listed running

ampyAmpy allows the transfer, creation, viewing, and execution of files on the device.

As for the IDE you can install Eric, generic Python IDE


Eric does not allow communication from the IDE with the device as seen with uPyCraft; this task is delegated to Ampy. For the installation proceed as follows:

  • For Linux Debian 9 just run

The tool is available among the development tools; at the first execution it requires default settings

ericSettingsWe define the workspace location

ericWorkspaceand we have the access to the IDE


  • For Windows download the zip


Unzip the zip into a folder from which we run it; install the prerequisites

Perform the eric installation at this point by double clicking on install.py

ericInstallWindowsThe program checks the prerequisites and completes the installation


Clicking twice on eric6.py or running eric6 from a dos command prompt we run the program in the same way as seen for Linux Debian


In the next article we will briefly examine how a MicroPython program is structured

MicroPython – MicroPython program structure


Micropython – MicroPython IDE uPyCraft

After installing the firmware on the Nodemcu esp8266 DevKit board

MicroPython Firmware

let us now examine a development tool can be suitable for the development of Python code.

A tool that allows both to write code and upload it to the device is uPyCraft


The tool currently works for Windows and from version 0.30 is also available for Linux; the source code is available at the link

uPyCraft Source

Here are the steps for Windows and Linux.

  • Windows

Once downloaded the package we must  run it as an administrator; the installation of the Monaco font is required


After the font installation,  we have the access to the IDE

upycraft-v0-29We set the Location in Tools->Preferences->Language Location


and the serial port paramenters in Tools->Preferences->Serial

upycraftserialsettingsWe plug the device into an USB port and set the serial port on uPyCraft

upycraftserialWe choose the device type; in this case it is ESP8266

upycraftdeviceBy clicking on the connection icon we access to the device and view the files on it

upycraftconnectionThe firmware installation expands on the device only the Python file boot.py

upycraftfilesystemThe tool allows to download examples of MicroPython code for the board, blink.py for example

examplesClicking the “Download and Run” button we load the code onto the device and run it

blinkIn this example the led of the Nodemcu DevKit blinks.

  • Linux

The tool is similar in the Linux version; once downloaded the package to which we have to assign  the execution right we run it. We must assign to the user the access to the serial port with the command, already seen above

In our case, on Debian 9, we have the following screens similar to what we saw on Windows.

In the uPyCraft IDE

upycraft-v0-30linuxWe set the Location in Tools->Preferences->Language Location


and the serial port paramenters in Tools->Preferences->Serial

upycraftserialsettingslinuxWe plug the device into an USB port and set the serial port on uPyCraft

upycraftseriallinuxWe choose the device type; in this case it is ESP8266

upycraftdevicelinuxBy clicking on the connection icon we access to the device and view the files on it

upycraftconnectionlinuxThe firmware installation expands on the device only the Python file boot.py

upycraftfilesystemlinuxThe tool allows to download examples of MicroPython code for the board, blink.py for example

exampleslinuxClicking the “Download and Run” button we load the code onto the device and run it

blinklinuxAs in Windows the led of the Nodemcu DevKit blinks..

In version 0.30 for Windows we noticed some bugs, so for this operating system we continue to use the uPyCraft  version 0.29.

Further informations about uPyCraft can be found at the following site

uPyCraft Documentation

In the next article we will discuss another Python development tool

MicroPython – Development tools Ampy – Eric

Generating Images for BeagleBone with Omap Image Builder

This article describes how to proceed to the autonomous creation of an image for the BeagleBone Black /Green using the Omap Image Builder. In this specific example we create the image for the BeagleBone Black Rev. C.

The informations on the procedure to be followed are available on the site

Omap image builder

As a prerequisite to the creation of the image there is the need to perform the operations on arm hardware; with other systems it is possible to have issues. To this end, we will proceed to perform tasks on a  Orange PI PC with Armbian operating system. After preparing the Armbian system for Orange PI PC, as described in

Armbian Boot on Orange PI PC

log  in  ssh on Orange PI PC; in our case we used the sviluppo/password credentials

ssh on Orange PI PC

It is possible also to connect  by enabling Remote Desktop

Remote desktop setup for Armbian on Orange PI PC

Create a folder named beaglebone

Clone the code to create the image

The folder tree is the following

We proceed first to the creation of a standard Debian 8 image for Beaglebone Black

The task takes a long time and creates other folders including the deploy folder within which we will find the images. At the end go into deploy /image folder and run

Compress the created image with the command

To create a customized image proceed as follows:

  1. Go into the image-builder/configs folder and copy a configuration as base named custom-debian.conf. We have used as a base configuration bb.org-debian-jessie-lxqt-4gb-v4.1.conf. In custom-debian.conf add the following changes in  the deb_include section; as example we add the vsftpd server; change the chroot_script value too

    To exclude packages to be installed use the deb_exclude section. In the script are commented the various sections, among which we find those about  the definition of the hostname, passwords, user name creation, etc.
  2. Navigate to the image-builder/target/chroot folder and copy beagleboard.org-jessie.sh as custom-debian.sh.
  3. If you want to add python packages edit the custom-debian.sh file and add the other packages in install_pip_pkgs function

In this example we added only the ftp server. Go into the image-builder folder and run the command

The task  takes a long time. At the end access to the deploy/imagename folder and run

Compress the created image with the command

You can create now the micro sd card  with the FTP server available in the image  and the hostname changed in beagleboneblack.

The microSD burning  is already described in the article

Debian sdcard setup for Beaglebone Black

On Omap image builder site you’ll find other images types among which we highlight those for BeagleBone Black, Green, Iot, Machine Kit (image to manage Machinekit CNC machines), etc.

C Eclipse project reading temperature and humidity on Beaglebone

After the cross building and DHT11 sensor setup on Beaglebone Black

Remote debug on Beaglebone

Sensors on Beaglebone

Temperature and humidity reading on Beaglebone in python

now we show how to create a C project , using  the C source code available with the Adafruit library

Adafruit Python DHT Sensor Library

Using Eclipse, we create a project for the reading of our sensor. It calls the functions in the C code of the Adafruit library. These sources are imported into the Eclipse project

Dht sensor Projectand using the sample C code  dhtSensor.c,  which contains the main C program, we read the sensors by calling the funtions available in Adafruit C sources; the usage is  similar to what seen in Python.


 it shows the help instructions

To read the DHT11 sensor on pin P8_11 we have to run

The output is the following

DHT sensor reading in CHere is the Eclipse C project

dhtSensor Eclipse project

DHT11 sensor reading on BeagleBone with node.js

In the previous article we read the temperature and humidity from DHT11 sensor in python

Temperature and humidity reading on Beaglebone in python

We perform now the same operation in javascript. We download the  dht module for node.js. The module is available on the website

beaglebone dht

Log on BeagleBone in ssh as debian (temppwd as password) and run

to install the module globally.

For the sensor reading create a file test.js  with the following code inside

Reading is performed running

The result in our case is the following

temperature reading node.jsThe same code can be run from Cloud9 IDE. Access the IDE on BeagleBone with the link http: //beaglebone.local:3000 and create a file named dht.js with the following code inside

The script execution gives the following result

DHT11 cloud9Here is the link to download the two sample files

Node.js sample

Cloud9 sample

Temperature and humidity reading on Beaglebone in python

In the previous article we connected the DHT11 sensor to the Beaglebone

Sensors on Beaglebone

We install at this point the library in python and modules in c to read the sensor. The site with documentation about the library is

Adafruit Python DHT Sensor Library

Log in ssh on Beaglebone as root / no password and create the temperature folder from which we run

Install the prerequisites

Proceed to the installation of the library with the python command

Enter the examples directory and do the following for reading the sensor values (dht 11 and pin P8_11)

The result in this case is the following

temperature reading

Sensors on Beaglebone

After describing the Beaglebone and its development tools

Startup of the Beaglebone development board

Development tools on Beaglebone

as an example we show how to interact with the Beaglebone and a temperature and humidity sensor.

Among the most popular we finde the DHT11 sensor. The sensor has 4 pin; we have to connnect it to the power supply through a resistance of 4.7 or 10 kΩ. In our case we have a three-pin DHT11 sensor with the resistance already included in the circuit. In the case of the only sensor follow as specified in the following article

DHT humidity sensor

The following image shows the connections with Beaglebone

Beaglebone DHT11In the article Development tools on Beaglebone we showed the Beaglebone headers; in this case we used  3.3V,  ground and P8_11 headers.

In the next article we will install a library in python and modules in C to read temperature and humidity

Temperature and humidity reading on Beaglebone in python

Remote debug on Beaglebone

In the previous article we have prepared the environment with Eclipse for cross building for BeagleBone

Cross building for Beaglebone

Now we shall configure Eclipse and BeagleBone to debug the code directly on BeagleBone.

On BeagleBone install gdbserver

On the Debian system with Eclipse install gdb-multiarch

From Eclipse access to Run-> Debug Configurations

debug configurationsDouble-click C++  Remote Application to set parameters

Remote debugger configurationAt the next window, create a new ssh connection with the New button

New connectionEnter the parameters for the connection

Connection parametersSet the remote destination folder for the file  and execution management; with the browse button choose where to copy the files, and with the field “Commands to execute before application” will give execute permissions to the file

Remote foldersIn our case we create a folder esempi under /root on the  BeagleBone where to debug remotely

main debug settingsSet the multarch debugger in the Debugger Tab and other startup parameters and gdb command line settings

Debugger multiarch settingsSet the port of the remote debug server installed on BeagleBone in the Gdbserver Settings Tab

debug server settingsCreate .gdbinit files in the project folder with the command

touch debugTo start debugging run the configuration we set

debug runEclipse connects with BeagleBone and performs remote debugging  opening the Debug Perspective

debug perspective

Cross building for Beaglebone

In the article on the Debian environment we prepared the linux machine for the development of embedded systems

Debian development envinronment

In the article on building an image for the Orange PI PC we installed the cross build tools for armhf environment

Building Armbian for Orange PI PC

Starting from the clean image of the Debian envinronment we list the steps required to install the cross compiling environment. We log on Debian Desktop as sviluppo/ password.

As a preliminary step we install  the cross toolchains in Debian


Create the file crosstools.list in the /etc/apt/sources.list.d folder

and add the line

Save the file and add the key of  the repository embedian.org

Install the following packages and add the armhf architecture

We install at this point the Eclipse IDE for Cpp downloading the IDE for Linux 64bit

Eclipse IDE

Unzip the eclipse package under / home /sviluppo.

Install the jre java

Add the line at the end of the file

Run the following commands

Run Eclipse from the eclipse folder to start the IDE

eclipseAs a first example we create a simple program in C for BeagleBone.

Create a new project in C, by inserting the following data

new projectSelect both configurations

project configurationEnter the cross compiler prefix and path

crosscompiler prefixPress Finish.
Add to the project a source file in C

C source fileInsert the following simple code

Proceed with the build by selecting the project with the right mouse button and choosing Build Project

project build Transfer the generated files on BeagleBone. You can use scp or ftp.

Give execution permissions to the file and run it

The result is of course the text inserted in the code

sample run