Volume and media control buttons with Raspberry Pi Pico

 Author:   Posted on:    No comments

A while ago I used STM32 bluepill board to emulate a consumer control device that would allow me to control volume and media playing on PC, over USB. Implementation wasn't very easy, since I had to modify an existing library to add support for consumer control HID class. Nevertheless, I succeeded and the details and my library can be found in this post.

Meanwhile, a new cheap development board appeared. It is the Raspberry Pi Pico which has native USB port. I thought this could be used as well to emulate a keyboard, mouse or consumer control HID. This board can be programmed in C/C++ or MicroPython. Since I wasn't willing to install the C/C++ development kit, I attempted to use MicroPython. Unfortunately, it lacks required modules for USB HID and rotary encoder. Then I found about CircuitPython, which is based on MicroPython and is supported by Adafruit. At its current version, it is bundled with rotary encoder module and, for USB HID, you can use Adafruit HID library.

Volume and media control buttons with Raspberry Pi Pico

Media control device built on breadboard

Alternative firmware for XTW100 Programmer

 Author:   Posted on:    No comments

I have bought the XTW100 Mini Programmer and while attempting to read the firmware of the STM32 MCU using an ST-Link programmer, somehow I erased the flash and got a totally useless piece of hardware. XTW100 is advertised as a better replacement for the CH341A based programmers and after tracing the schematic I failed to find any reasons why it should be better. The information I gathered can be found here.

With the original firmware, the programmer should be able to interface SPI and I2C EEPROMs and flash memory chips. However, since I have no way of getting that back to test whether the programmer works or not, I found there is an open-source firmware available. Unfortunatety, it does not come with I2C support.

Alternative firmware for XTW100 Programmer

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