USB multimedia keys on Arduino STM32

 Author:   Posted on:    No comments

I switched from a keyboard with media controls to a new one without such functionality. Then I realized I was missing the volume and play/pause buttons from the old keyboard. But I have some development boards which I could use to control media and PC volume. I've seen some projects using the Bluetooth functionality of ESP32 to emulate a keyboard. But for now, wired USB interface is what I want. The cheapest and most capable board for this purpose is the STM32 "bluepill". Although I'll end up buying another keyboard with multimedia buttons sooner or later, now I'm going to program the STM32.

I thought this would be easy. But there are multiple ways of programming this ARM microcontroller. It can be done with STM32 HAL. But I found it hard to develop the USB HID device. I looked for something easier. With the Arduino IDE, you have access to two development kits, one from STmicroelectronics and another one from Roger Clark (which is based on libmaple). I attempted to use the official package from ST, but their USB library only supports a basic keyboard (same as Arduino Keyboard library). I found that the other package, from Roger Clark, supports USB Consumer HID. Although it is based on old libmaple it still works. I decided to work with the official package though.

USB multimedia keys on Arduino STM32

USB multimedia keys with STM32 on breadboard

Program "blue pill" with STM32 Cores in Arduino IDE

 Author:   Posted on:    No comments

Back when I wrote Set up STM32 "blue pill" for Arduino IDE I found two Arduino Boards packages for STM32. I didn't know at that time what were the differences between them and that post uses the STM32 package developed by Roger Clark. In fact, that one originates from libmaple which was first developed by LeafLabs for their Maple boards. The library was written in 2012 and it is no longer under active development.

I consider STM32duino to be a better alternative now, since it is actively developed by STMicroelectronics and uses as backend recent versions of STM32 libraries (LL, HAL). More than that it has support for multiple cores and boards including, but not limited to, official evaluation boards, 3D printer boards and flight controllers. To be able to use it you need a board and a programmer, Arduino IDE and STM32CubeProgramer. Fortunately the required software is cross-platform so you can code for STM32 on any platform. In this post I'll show you how to install the required software and how to upload sketches to STM32 "blue pill".

Program blue pill with STM32 Cores in Arduino IDE

Install Oracle Java on Linux Ubuntu

 Author:   Posted on:    1 comment

Java is a cross-platform development platform used by many applications. If you want to run Java based applications, you must install a runtime. Java is developed by Oracle. There are two packages: JDK (Java Development Kit) and JRE (Java Runtime Environment). While the first is needed to develop Java applications, for running them you need the runtime.

Due to licensing, on Linux you have the possibility to install only OpenJDK from software repositories. That is an open source GPL licensed JDK edition. Well, I had this one installed (package openjdk-8-jre) on Ubuntu and I was facing some problems. JabRef, a references manager application, wouldn't run. Initially I thought there is something wrong with the current release. Later I installed (the GUI installer worked) STM32CubeProgrammer, a programming utility for STM32 microcontrollers. Neither this one would launch.

Java JRE Download page for Linux

Java Runtime Download page for Linux

DHT22 sensor web server on ESP8266

 Author:   Posted on:    3 comments

There are plenty of projects using digital temperature and humidity sensors such as DHT11 or DHT22 and various development boards. I'll try to make this one a bit different. A common thing that I didn't like about projects using sensors and web servers is the way most users choose to update sensor data. The easiest way is to use a refresh meta tag in the HTML of the web page.

I don't like this. Asking the browser to refresh the document means to request it again from the server and render it on the client's device. I'll use in this article Javascript code which will request a new sensor reading from the server running on the development board and update the specific HTML element. As additional features, I'll add some user-selectable actions when readings reach a threshold.

DHT22 sensor web server on ESP8266

LM317 Lithium Ion Battery Charger

 Author:   Posted on:    No comments

Even though I have some TP4056 modules for charging Li-Ion cells, those small PCBs generate a lot of heat and the charging current decreases with temperature increase. Since I have parallel pairs of cells from notebook batteries, I would like to charge them with a higher current. Another limitation of those modules would be that the maximum charge current cannot be changed unless I replace a small SMD resistor. Therefore I'll build my own Li-Ion battery charger, with LM317 (LM338). Using a linear regulator does not solve the heat production issue, but at least I can put it on a heatsink.

Li-Ion cells need to be charged in a two-step process. First, until they reach a threshold voltage the charger behaves as a constant current supply. This current is cell-specific, but usually the supplied energy (in Ah) should be less than 80 percent of battery capacity (Ah). When the voltage increases enough, the charger should switch to constant voltage mode, maintaining a stable 4.2 V (or 4.1 V for some cells) until current drops.

LM317 Lithium Ion Battery Charger

Upload files from Arduino IDE to ESP SPIFFS

 Author:   Posted on:    No comments

ESP8266 and ESP32 development boards have SPI flash memory used mainly for program storage. But, if there is enough space, the flash memory can be "partitioned" and used for other purposes. Making a SPIFFS (SPI Flash Filesystem) partition has some advantages. Even though file system is stored on the same flash chip as the program, programming new sketch will not modify file system contents. Since ESP development boards have WiFi connectivity it's easy to think of something useful to do with SPIFFS. For example a web server can store images, scripts, styles and even HTML files that will be used to create the web interface. Another usage would be to create a data log that can be downloaded via a web interface.

Obviously SPIFFS data can be read/written from other interfaces, including serial monitor. If you're developing a web server on ESP8266/ESP32 you'll want an easy way to upload server files to SPIFFS. Fortunately, there are plugins for Arduino IDE that handle this process. We will see how to do this and then check for the existence of files on the SPIFFS partition.

Upload files from Arduino IDE to ESP SPIFFS