All posts by admin

Mqtt with Beaglebone and ESP8266 – Freeboard

After the Mqtt web client installation

MQTT with Beaglebone and ESP8266 – WebServer and MQTT WebSocket

let’s install now the dashboard freeboard

Freeboard

In a ssh commad shell go into the /var/www/html  folder on Beaglebone as root and clone the freeboard github respository; change the owner of the freeboard folder in www-data:www-data

With a web browser go to the freeboard  folder on Beaglebone webserver to access the dashboard

freeboard

We have to add now Freeboard additional plugins. We add the following

  •  freeboard-mqtt

Clone the https://github.com/alsm/freeboard-mqtt github

Download the mqtt paho javascript library

Paho mqtt javascript library

Here is the direct link to the library

Last Version mqttws31.js

Create the mqtt folder under the Freeboard plugins folder and copy the mqttws31.js and paho.mqtt.plugin.js files

Edit the paho.mqtt.plugin.js file and insert the reference to the mqttws31.js library in the external_scripts section; in this case too we have to change the folder and contents owner

Change the owner

Edit the /var/www/html/freeboard/index.html file and insert the reference to the paho.mqtt.plugin.js plugin in the heads.js section

  • Add the dynamic-highcharts plugin

Clone in a folder the github

Copy the plugin_highcharts.js to the folder /var/www/html/plugins/thirdparty and change the owner

Edit again the file /var/www/html/freeboard/index.html and add the plugin as done above

Access now the Freeboard dashboard and add the links to the temperature and humidity topics, the gauges and timeseries mesauring the values in real time and in a specific range of time . Here are some settings:

  • Datasource

freeboard datasource

  • Gauge

freeboard gauge

  • Timeseries

freeboard timeseriesChrome/Chromium browser allows to save the settings in a json file. This settings can be loaded locally or loaded from the web server, saving for example the dashboard.json file in /var/www/html/freeboard,  with the url

The image shows the Freeboad interface with various widgets showing the status and timeseries of the ESP8266 relay and sensors

freeboard dashboard

In these series of articles we configured the envinronment to access the Beaglebone using the beaglebone.local/beaglebone alias

Debian sd card setup for Beaglebone Black

but you can use anyway the Beaglebone IP tho access the services provided by the board.

In the next article we’ll treat the Mqtt Android client

Mqtt with Beaglebone and ESP8266 – Android Client

 

 

 

Libreelec8 in OrangePI PC

This article describes the steps that I ran to prepare a first version of Libreelec 8 in Orange PI PC cards and other H3 socs.

Starting from the Debian development envinronment, with its installed packages, already used for the compilation of OpenELEC 7

 Openelec compilation for Orange PI PC

we proceed to build an Libreelec 8 image.

We started as basis from the work done for Openelec 7 and Libreelec 7 available on the two github repositories

H3 Openelec 7 Github

H3 Libreelec 7 Github

Log in a unix command shell as user sviluppo; create a folder, libreelec , under orangepi folder and move into it

Clone the Libreelec8 github

The patches have been created for a specific version of the commit, so we align our github clone to that version

Download from the following link the patches, the H3 project and other stuff

H3 Libreelec 8

Unzip this file in /home/sviluppo/orangepi/libreelec

Run the following steps

1)Copy  to /home/sviluppo/orangepi/libreelec/libreelec-8.0/projects the folder

H3

2) Copy to /home/sviluppo/orangepi/libreelec/libreelec-8.0/packages/multimedia  the folders

cedarx
libmpeg2

3) Copy to /home/sviluppo/orangepi/libreelec/libreelec-8.0/packages/tools the folder

sunxi-tools

4) Copy to /home/sviluppo/orangepi/libreelec/libreelec-8.0/packages/sysutils  the folder

  sunxi-sys-utils

5) Copy to /home/sviluppo/orangepi/libreelec/libreelec-8.0/packages/graphics  the folder

sunxi-mali

6) Copy to /home/sviluppo/orangepi/libreelec/libreelec-8.0/packages/linux-drivers  the folder

mt7601u

7)  The following patches are available in /home/sviluppo/orangepi/libreelec/H3LE8/patches folder

linux.patch

image.patch

mkimage.patch

kodi.patch

libcec.patch

u-boot.patch

u-boot-release.patch

u-boot-update.patch

Patch the code from the /home/sviluppo/orangepi/libreelec folder running the following commands

Proceed to the image build for Orange PI PC from the folder /home/sviluppo/orangepi/libreelec/libreelec-8.0  running

At the end of the compilation in the /home/sviluppo/orangepi/libreelec/libreelec-8.0/target folder we find the files to install or update Libreelec 8

 At the link

Openelec 7 H3 FAQ

we find the boards we can build changing the SYSTEM parameter in the building command

SYSTEM=opi2
SYSTEM=opione
SYSTEM=opipc
SYSTEM=opiplus
SYSTEM=opilite
SYSTEM=opipcplus
SYSTEM=opiplus2e
SYSTEM=bpim2p
SYSTEM=bx2

This image is a first attempt to build Libreelec 8 for  H3  socs. The image was installed on Orange PI PC and the system worked well, but still bugs and malfunctions may occur.

Here is the built Libreelec 8 image for Orange PI PC

Orange PI PC Libreelec 8 Image

We tested this image on an Orange PI PC board.

Here are other images we did’t test on the devices

Orange Pi2 Libreelec 8 Image

Orange Pi Lite Libreelec 8 Image

Orange Pi One Libreelec 8 Image

Orange Pi PC Plus Libreelec 8 Image

Orange Pi Plus Libreelec 8 Image

Orange Pi Plus 2e Libreelec 8 Image

WARNING: The image installation on the device is at your own risk. We accept no responsibility if the installation leads to  malfunction or block of the device.

The following article shows how to build the addons

Libreelec 8 addon building for Orange PI PC

MQTT with BeagleBone and ESP8266 – WebServer and MQTT WebSocket

After the MQTT server and  ESP8266 nodes configurations

MQTT with BeagleBone and ESP8266 – Mosquitto installation on Beaglebone

MQTT with BeagleBone and ESP8266-MQTT ESP8266

MQTT with BeagleBone and ESP8266 – MQTT on ESP8266 with temperature sensor

MQTT with BeagleBone and ESP8266 – MQTT on ESP8266 with Relay

we analize now the webserver configuration on BeagleBone and  the Websocket configuration for the broker MQTT mosquitto always on Beaglebone.

First step is to access on the Beaglebone in ssh and disable the following services

Go into the folder /etc/apache2/sites-enabled and modfy 000-default.conf  changing the webserver port from 8080 to 80

In /etc/apache2/port.conf modify the listening port from  8080  to 80

Restart the Http server

Go into folder  /etc/mosquitto/conf.d and create a new file websockets.conf with the following contents inside

Save the file and restart Mosquitto

Disable the IPV6 protocol on  Beaglebone as described at the following link

Disable IPV6 in Debian

In the file /etc/sysctl.conf add

Restart the Beaglebone.

We proceed at this point to install on the http server a MQTT Websocket client and the Freeboard dashboard.

As for the MQTT Websocket client hive-MQTT we download the code from github

Hive mqtt

Log in as root in ssh on Beaglebone and go into /var/www/html folder;  clone the Mqtt client into mqtt-web folder and change the owner of this folder

With a web browser navigate on our Http server to the mqtt-web link obtaining the Mqtt Web client; we can now set the parameters for the connection to the Mosquitto Mqtt Broker

mqtt web client connectionPopulating the values for the subscription and publishing topics we can access to the messages of the topics and the ability to perform a command to the publishing topic

mqtt web clientIn the next article we’ll install the Freeboad dashboard on the Beaglebone

Mqtt with Beaglebone and ESP8266 – Freeboard

MQTT with BeagleBone and ESP8266 – MQTT on ESP8266 with Relay

After the article about the connection with the temperature and humidity sensor

MQTT with BeagleBone and ESP8266 – MQTT on ESP8266 with temperature sensor

in this article we set the esp8266 to run a relay. Here is how we connect the relay to the ESP module

nodemcu relay

In this example too we will consider the option of putting the nodemcu in sleep. To have the node back form the sleep the system has to reboot and  it is necessary to connect the PIN D0 (GPIO16) to RST PIN as specified in the nodemcu documentation

Nodemcu sleep

Let us take a look at the lua code; It consists of init.lua and relay.lua files.

We analyze now the main points of each file

  • init.lua

In the file we set the the parameters to access the wifi network, the address and port of the MQTT broker  and the file to be run on the ESP after wifi connection to the access point is estabilished. If the ESP doesn’t acquire the network address the system is restarted.

  • relay.lua

The relay.lua file manages the relay, the subscription on MQTT broker with submission of the data. Global parameters have been set to manage the topic, the waiting time in tmr.alarm. There are in particular the following topics

  • /home/relay1/status : Status topic. The status is sent at the start and at  request from the command topic /home/relay1/command.
  • /home/relay1/monitor: Status of the esp sent periodically to this topic.
  • /home/relay1/command: Other clients can send commands to the esp:
    • Restart: Restarts the esp.
    • Sleep n: Put to sleep for n seconds the esp.
    • ON: Turn on the  relay.
    • OFF: Turn off the  relay.
    • Status: Request of tthe relay status (ON or OFF).

There are various service functions to manage all. The comments in the code describe each feature.

In the next article we will set up the webserver on Beaglebone and the websocket configuration for Mosquitto always on the Beaglebone

MQTT with BeagleBone and ESP8266 – WebServer and MQTT WebSocket

MQTT with BeagleBone and ESP8266 – MQTT on ESP8266 with temperature sensor

After loading the firmware into the device esp8266

MQTT with BeagleBone and ESP8266-MQTT ESP8266

we now connect this module with a DHT11 temperature and humidity sensor. Here is how we connect the sensor to the ESP module

nodemcu dht11

In this example we will consider the option of putting the nodemcu in sleep. To have the node back form the sleep  the system has to reboot and  it is necessary to connect the PIN D0 (GPIO16) to RST PIN as specified in the nodemcu documentation

Nodemcu sleep

Let us take a look at the lua code; It consists of init.lua and tempumid.lua files.

We analyze now the main points of each file

  • init.lua

In the file we set the the parameters to access the wifi network, the address and port of the MQTT broker  and the file to be run on the ESP after wifi connection to the access point is estabilished. If the ESP does’t acquire the netowrk address the system is restarted.

  • tempumid.lua

The temumid.lua file manages the measurement of temperature and humidity, the subscription on MQTT broker with submission of the data. Global parameters have been set to manage the topic, the waiting time in tmr.alarm. There are in particular the following topics

  • /home/room1/temperature: measured temperature topic.
  • /home/room1/humidity: measured humidity topic.
  • /home/room1/status : Status topic. The status is sent at the start and at  request from the command topic /home/room1/command.
  • /home/room1/monitor: Status of the esp sent periodically to this topic.
  • /home/room1/command: Other clients can send commands to the esp:
    • Restart: Restarts the esp.
    • Sleep n: Put to sleep for n seconds the esp.

There are various service functions to manage all. The comments in the code describe each feature.

In the next article we will set up the esp with the relay

MQTT with BeagleBone and ESP8266 – MQTT on ESP8266 with Relay

 

Mqtt with Beaglebone and ESP8266-MQTT ESP8266

After installing the MQTT server on BeagleBone

Mqtt with Beaglebone and ESP8266-Mosquitto installation on Beaglebone

let us set the MQTT nodes on ESP8266.

As first operation we must generate the nodemcu firmware, as described in the previous article

Nodemcu compilation on Linux

with at least the following parameters activated in user_module.h file

  • DHT
  • file
  • GPIO
  • MQTT
  • net
  • node
  • timer
  • UART
  • WiFi

These settings are the default in the user_module.h file.

At present the latest version 2.0 of nomemcu firmware was released. Here are the compiled files for this version of the firmware

Nodemcu2.0.0 firmware

As already described in previous articles and from the nodecmu link on flashing

Flashing the firmware

 we have to set the correct parameters for  the  esp8266 model.

In our case, with 4MB flash, we used the parameters shown in the image to load the firmware on the device with nodemcu-flasher tool. You can also use other tools for loading the firmware. In our case, the settings used are as follows

nodemcu flasherIn the next article we’ll treat the ESP8266 node that detects temperature and humidity

MQTT with BeagleBone and ESP8266 – MQTT on ESP8266 with temperature sensor

MQTT with BeagleBone and ESP8266 – Mosquitto installation on Beaglebone

After summarizing the architecture that we are implementing in the previous article

 Mqtt with Beaglebone and ESP8266-Architecture

We proceed now with the installation of the MQTT broker on Beaglebone Black with the following version of Debian

The image used is the following

Beaglebone Black Image

We proceed to the configuration as described in the article

Debian sd card setup for Beaglebone Black

Proceed to extend the space on the SD card  with the application gparted in a linux host or using the grow_partition.sh tool on BeagleBone in the /opt/scripts/tools folder

Performing the upgrade with this image we have  had space issue with 4Gb partition.

The message broker we’ll use is  mosquitto

Mosquitto

The version of Mosquitto with Debian Jessie  doesn’t not have the Wesockets services, which we’ll use for the Dashboard. For this reason, we have to install a more recent version of Mosquitto  (or recompile it from source).

Log on as root in a command shell on BeagleBone and add the Debian testing repository

Run the following

After the installation comment  the reference of the debian testing repository  in /etc/apt/sources.list

and run

We test at this point if the server is installed correctly by running in a shell the subscription to a topic

In another command shell run the publishing on topic “topic / test”

The first shell has to show the message “Prova”

mqtt Test

With MQTT protocol we can define different QOS, as described in the  Mosquitto FAQ

QOS Mosquitto

With QoS = 0 the message is sent only once and is not required confirmation of receipt by the subscribers; the MQTT implementation in these articles is without protection with name/password or ssl channel encryption and with QOS=0.

In the next article we’ll proceed to the preparation of ESP9266 module with the Mqtt lua library inside the nodemcu firmware

MQTT with BeagleBone and ESP8266-MQTT ESP8266

Mqtt with Beaglebone and Esp8266-Architecture

In this series of articles we treat a MQTT message broker installed on  BeagleBone Black; this componet   allows  to manage various esp8266 devices, to which we connect various probes such as temperaure sensors, relays.

All this is handled with the help of apps on Android and a Dashboard installed on Apache on BeagleBone.

We start from the message MQTT broker (Message Queue Telemetry Transport); here there is the description of the protocol

MQTT

In particular in the FAQ section there are the first indications on the protocol and its use

MQTT Faq

The system is formed by three components:

  • MQTT Broker: relays the messages published to all subscribers.
  • Publisher: Publish messages in the registered topics on MQTT Broker.
  • Subscriber: Receives messages for its registered topics from MQTT Broker.

The following shows the topology for two topics used in our example

archThe system is composed of a MQTT  broker on BeagleBone. In this MQTT broker server you can define topics; different devices can be registered to these topics. For each topic the action can be subscription and publishing. By subscribing you receive all messages of topics, while with the publishing we can perform actions on the topic (for example, turn on a relay, restart a device, send sensor measurement,etc.). In the example we treat there will be, for example, a queue for the temperature monitor, hooked to esp8266 temperature reading device, another for the management of a relay, always run with esp8266. The MQTT broker relays the received messages among all  subscribers/ publishers for each topic.

We can subcribe/publish to the topics on the MQTT broker using  Android apps; the apps can receive messages and send commands to the esp8266 end device (Turn onRelay, Restart sensor, etc.).

With the javascript framework Freeboard

Freeboard

installed on the Beablebone Apache web server we can monitor in real time the end devices.

For more informations on MQTT system, consult the web site listed above.

In the next article we’ll start by installing the MQTT broker on BeagleBone Black

MQTT with BeagleBone and ESP8266 – Mosquitto installation on Beaglebone

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.

Running

 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