Creating a Videoplayer for ESP32

Big Buck Bunny on ESP32

One of the things which makes embedded programming so interesting is that you are constantly dealing with restricted resources. Playing video files is quite resource heavy. Let’s see how ESP32 can handle this. If you have short attention span here is a video instead.

Hardware Agnostic Graphics Library for Embedded

ESP32 board with fire effect

What started as a project to learn C, I have now been using in all my hobby projects. HAGL is a hardware agnostic graphics library for embedded projects. It supports basic geometric primitives, bitmaps, blitting, fixed width fonts and an optional framebuffer.

M5Stack on Fire!

M5Stack fullscreen fire

My life has come to a full circle. I remember sitting in my parents basement in the late 90’s programming the fire effect using mixture of Borland Turbo Pascal and Assembler. I had an Intel 80386 which also had the 80387 coprocessor. I remember downloading Lode’s graphics tutorials from FidoNet. It was all magic.

Last week I found myself reading the same tutorials and creating the same fire effect again. Instead of Intel PC, it was written for ESP32 based M5Stack and using C programming language.

How to Calibrate a Magnetometer?

MPU-9250 breakout board

Magnetometers are used to measure the strength of a magnetic field. They can also be used to determine orientation and to compensate gyro drift. Magnetometer provides the last three degrees of freedom in 9DOF sensors.

There is one problem though, magnetometers are prone to distortion.

Wifi Geolocation With MicroPython


While evaluating M5Stack for a sidehustle project I created a proof of concept which needed to access wifi network, query an API and download an image. Wifi geolocation which displays a static Google map seemed like a perfect fit. Here are some notes about it.

Install Latest MicroPython to M5Stack

M5Stack is an absolutely beautiful ESP32 based enclosure and development board. It has 320x240 TFT screen, three buttons, sd card slot, Grove I2C connector and can be powered with LiPo battery.

Download the Micropython Firmware

You could download the MicroPython firmware from the downloads page. But why bother when we have the commandline. First find the download link.

$ curl --silent | grep "firmware/esp32" | gawk -F'<a +href="' -v RS='">' 'RT{print $2}'

Update Pycom WiPy Firmware From Commandline

WiPy is a bit pricey but good quality ESP32 development board from Pycom. I got mine from Pimoroni. Pycom does offer their own firmware updater but for my taste it has too much magic going on. I prefer to do things from commandline and I stay in control and to see exactly what update is doing. Quick Googling did not reveal anything so here is my upgrade procedure.

Download the Latest Pycom Firmware

For starters we need to find the latest Pycom firmware. Links can be found from their forums. Or you can just query the filename from their software update service.

$ curl ""

  "key":"wipy.wipy with esp32",

Branca as an Alternative to JWT?

Branca is a catchy name for IETF XChaCha20-Poly1305 AEAD message with an additional version number and timestamp. It is well suited to be used as an authenticated and encrypted API token. Branca specification does not specify the payload format. Among others you can use for example JWT payloads but still have modern encryption and smaller token size provided by Branca.

Currently there are implemenations for JavaScript, Elixir, Go and PHP and a command line tool for creating and inspecting tokens.

WiFi Trilateration With Three or More Points

Three circles

The popularity of WiFi networks has been rising rapidly during the last 15 years. In urban areas hotspots are ubiquous. These hotspots together with trilateration algorithms provide a cheap way to find out yours or someone elses location.

Because of my previous work with Apple location services I wanted to figure out how trilateration works. Being a school dropout I am really really bad in mathematics. However I consider myself good at trial and error so I reckon this should be doable.

Reverse Engineering Apple Location Services Protocol

Updates: Added new pdf link to the end (2017-05-11). Header is actually length-prefix framed byte strings (2017-05-13).

While working on Whereami I got interested on how Apple location services actually work. I know it is handled by locationd since Little Snitch keeps blocking it. Usual way of inspecting traffic with proxychains did not work since macOS now has something called System Integrity Protection (SIP).

Alternative way was to setup Charles as MITM proxy for an iOS device. After looking at the traffic which was mostly the device phoning home I got what I needed - a location services request.