MateKrater WS2812 driver
Table of Contents
I really enjoy cheap electronics. I think the pinnacle of XXI maker culture is DIY affordable electronics. Even though buying knock-off arduino from china may be somehow morally questionable, it certainly enabled me to overcome fear of accidentally frying my devkit. This freedom to make mistakes is probably why I ended in electronics field at all.
Back in 2012-ish, I made my first somehow complex DIY project - RC tank that I controlled via SSH! :D It used raspberry pi 1 with an old 3G android phone in tethering mode, which theroetically gave the project infinite range.
The electronic circuit controlling the motors was harvested from the original 433MHz-controlled tank. I felt way to anxious to connect this mess of a circuit directly to the raspberry pi - I used a MSP430 microcontroller as an intermediate step of comunication, since back then I had virtually infinite supply of these. If something were to go wrong in the connection diagram, the MCU would probably tank the damage, leaving RPi relativelly safe.
Now the year is 2020 and my love for cheap electronics is bigger than ever, since hardware engineers earn shit.
The ESP-story⌗
ESP8266 was probably the biggest gift given to us from our eastern brothers - WiFi capability, excelent performance, easy programming, super cheap. I messed with it a lot, made some shitty gadgets for my friends, made some projects at my uni.
But now I’ve been presented with a real-life challenge: the “Mate Krate” project.
Our friends from Warsaw hackerspace gave us their “Club Mate”-based display. It was based on an breadboarded ESP8266. It worked fine. The problem was, they gave us no source code.
Afaik, the firmware was developed on a “stupid hackaton”. Afterwards it the code just ceased to be. Yes, the WiFi credentials were hardcoded in, why.
For ~1 year we had a dedicated router with hswaw’s wifi credentials just so that we could interact with the display.
The firmware⌗
One day we decided to fix that problem - via reverse-engineering that thing. Since:
- credentials are hardcoded in the firmware
- the ESP8266 firmware is dumpable and not encrypted
So we attempted replacing credentials in firmware with new ones, and reuploading the new binary back to the device. It didn’t work. (Of coruse it wouldn’t, you stupid me from 2019 - the firmware is CRC-checksummed.)
Then, my friend wrote a new, simple firmware in arduino, as a temporary solution, which we’re kinda stuck with now and is now deployed on 7+ devices around our hackerspace.
The hardware⌗
When developing the hardware plaform for the device, I knew we’re planning on having a lot of various mate displays and “mood lights” in the future - the driver needed to be cheap. I decided to move the programmer to an external board, as in such project it’s usually used once, maybe a couple of times.
This is how “MateKrate” and “Lichtenprog” projects were born. More on them later.
And the software⌗
Apparently the WiFi on ESP8266 doesn’t work that well - the connection likes to lag and randomly drop itself - not realtime at all. There are a couple of solutions/workarounds I have in mind:
- port the firmare to micropython, and implement uploading of python microapps, which would create animations on their own
- ditch the wifi standard alltoghether, and implement communication using raw 802.11 frames - apparently this is very doable with ESP8266s
For now the firmware is shitty anyways, please someone rewrite it…
The external programmer⌗
The BOM cost for a UART-based programmer would be ca. 3$ - mostly the USB-UART bridge and USB connector. The aforementioned devices are meant to be cheap, and in most cases one-time programmable, so saving 3$ on each of these would be a huge benefit.
I decided to move the programmer part to an external PCB, and so the “lichtenprog” project was born. You can read more about it »here« (ok, you can’t yet, WIP)
The programmer is inserted into the programmed devices using state-of-the art ultra-cheap, reusable connector - a (slightly) messed up pinheader:
The conclusion⌗
The idea of external programmer works fine - the setup has achieved the optimum between being cheap-as-possible and usable. The hackerspace has been filled with blinky bois. I now also have like 10 USB-UART bridges laying around, and you can never get eneough of these.
I’m now adapting concept of external USB-UART in my next projects - on ESP32-based, and one for a raspberry pi PCB. It’s just so damn neat, not having to mess with shitty goldpin cables everytime I need to read some UART data.
cover photo by Leonhard Lenz, under the Creative Commons license