Self-signed certificates for MQTT server

 Author:   Posted on:    No comments

During the last series of posts, I set up an Orange Pi single board computer running Armbian and I installed Mosquitto on it. My intention is to have a self-hosted MQTT broker for IoT applications. I already have it running with the configuration from previous post and it can be used for local connections in my home LAN and WiFi. Since this is a closed network, behind a firewall running on the Internet gateway I got from my ISP, there is no need for MQTT over SSL. But I need more: I want to be able to connect to MQTT server from remote devices (my Android phone, for example).

To do this, I need to configure a secured listener in Mosquitto and open its port for internet access. Since most ISPs offer dynamic IPs to residential clients, I also need a dynamic DNS service provider to have a domain name which always points to my IP. If you can get a static IP, then you don't need this.

Self-signed certificates for MQTT server

Configure Mosquitto™ MQTT broker on Armbian

 Author:   Posted on:    No comments

In the previous post I installed Armbian on an Orange Pi Zero single board computer (SBC). I intend to use this device for IoT and home automation, therefore I wanted to have a running MQTT server (broker). I prefer a self-hosted broker instead of a remote one hosted at a 3rd party company. In this way I have full control and I am sure sensitive data stays in the home network. Nevertheless, current SBC devices have enough processing capabilities and are energy efficient.

In this post I will configure the broker software. I want the server to listen for unencrypted connections on a port available for local clients only. It should also listen for encrypted connections on ports that I will open for remote access. There are two kinds of TLS connections: PSK (pre-shared key) and SSL certificate. The certificate will be self-signed and generated with OpenSSL (in a follow-up post).

Configure Mosquitto™ MQTT broker on Armbian

MQTT Broker on Orange Pi Zero (Armbian)

 Author:   Posted on:    No comments

Some time ago I was attempting to install the Mosquitto MQTT broker software on an old router with OpenWrt firmware. I no longer think that is the best option for a self-hosted MQTT broker with the advent of single board computers (SBC) like Raspberry Pi and Orange Pi. To my surprise, the Orange Pi Zero board (with quad core 1 GHz CPU and 256 MB RAM) requires less power to run than an old router (300 MHz single core CPU and 64 MB RAM).

With sufficient processing capabilities, the SBC can run more than the MQTT broker. I’m thinking of turning this Orange Pi board into a Home Automation Gateway which manages local devices and makes data available in a web interface. There is plenty of software support for what I want (I’m thinking of Node-RED with a web-based dashboard). Another good candidate is Raspberry Pi, but because it does not have wired network port (Zero version), I chose Orange Pi.

MQTT Broker on Orange Pi Zero (Armbian)

Generate square wave signal with Raspberry Pi Pico PIO

 Author:   Posted on:    2 comments

I recently bought a couple of Raspberry Pi Pico microcontroller boards. Although I read about the PIO peripheral, I didn't pay too much attention to it. However, it seems to be an interesting peripheral that I haven't seen before on other microcontrollers. It is supposed to be a versatile I/O interface which will allow you to implement custom serial or parallel protocols in a better way than bitbanging a GPIO pin.

Actually, the PIO is made of two blocks, each containing four state machines. These are individual processing units optimized for I/O, with "a focus on determinism, precise timing, and close integration with fixed-function hardware" as the datasheet claims. Sounds good, doesn't it? This is until you get to program these "machines" in... assembly language. I'm totally new to this, so in this post I will generate a square wave signal using the PIO.

Generate square wave signal with Raspberry Pi Pico PIO

Set up Raspberry Pi Pico for MicroPython

 Author:   Posted on:    2 comments

Raspberry Pi Pico is a newly released microcontroller board from Raspberry Pi Foundation. Since it is quite powerful and versatile, it may prove an excellent alternative to Arduino Nano or STM32 Blue Pill. Having a similar form factor to those two development boards, the Raspberry Pi Pico can be bought for about 4 EUR (5 USD). Keep in mind that this is the price of the original product, from most approved resellers, much lower than an official Arduino Nano or the retired Maple Mini from Leaflabs (the “blue pill” is based on it).

But there is more to it than the lower cost. The microcontroller has a dual core CPU running at a frequency up to 133 MHz with 264 kB of SRAM and 2 MB of flash. With 26 GPIO pins and native USB device and host support, Raspberry Pi Pico seems better than Arduino Nano and STM32 Blue Pill. It is definitely missing the kind of connectivity you get with ESP chips (WiFi and/or bluetooth), that’s why I’m not comparing it to the ESP8266 or ESP32. Even though, it is a good choice for projects that do not require such connectivity. Nevertheless, a LAN or Bluetooth connectivity module may be interfaced to Raspberry Pi Pico when needed.

Set up Raspberry Pi Pico for MicroPython

Dump data from NAND flash with Arduino

 Author:   Posted on:    No comments

A while ago I decided to see if it is possible to read data from a NAND flash memory chip using an Arduino. Although I found out it is possible, it is not quite practical. The ATmega328 Arduino is way too slow to read and transfer large amounts of data. Nevertheless, dumping data is possible. But for common usage, such a slow and limited microcontroller shall not be used for this purpose.

In the previous posts I wired the NAND to a 3.3V Arduino and wrote a basic sketch to communicate with the flash chip and read its ID register. Now I will attempt to read data from the memory and transfer it to PC over serial port. I must say I have no prior experience with NAND memory chips and this is the first time I’m ever attempting this.

Dump data from NAND flash with Arduino