Hacker News new | past | comments | ask | show | jobs | submit login

I really like ESP boards. A couple years ago, I had an expensive robotic cat toy which went out of support from the vendor (Petronics Mousr) and the app disappeared and I couldn’t even re-download it. I didn’t want it to become a brick so I decided to go down at rabbit hole of learning more about reverse engineering to figure out how the app works, Bluetooth LE sniffing to analyze the protocols, and then embedded programming to build a standalone device I could use to control the robot without needing a phone app.

Using an ESP32, i2c joystick controller, and i2c 128x64 OLED display I was able to cobble together a device that could control the robot and perform all its functions, as well as get telemetry from Bluetooth LE and show it on the display along with displaying controller inputs.

It wasn’t simple - it took months of work to get to a point where I had a mostly working prototype. That work including reverse engineering the device software and firmware, POCs running on my computer and then my phone before even starting on the standalone ESP32 version.

Pretty much from the start I was impressed with the capability of the ESP32. I had quite a bit of past experience doing hobby projects with Arduino and its ATmega 328 but the ESP32 was a whole new world. It was quite a learning curve at times. While I could use Arduino libraries which helped accelerate a lot of my progress, the multi-core nature of the ESP32 also meant that I ran into many interesting issues and incompatibilities with things I would do on the Arduino. Interrupt handling was completely different, for instance. i2c in particular was very challenging with lots of new and exciting issues to contend with.

Any sort of concurrent operations against the i2c bus would cause a crash, so I had to ensure I had careful synchronization of reads/writes. The speed of the ESP32 also meant I could easily saturate the i2c bus. This became a problem as I was trying to read inputs from the joystick, and output data to the display from both Bluetooth LE messages and the controller state. The ESP had the speed handle this no problem of course, but not the i2c bus. I had to write a rudimentary frame queue to control display output without saturating the bus since dropped frames weren’t as big a deal as not quickly processing joystick inputs. I also found many bugs in various Arduino libraries where they made bad assumptions on ESP32 hardware. I’d contribute fixes wherever I could. Most of my HW and libraries were from Adafruit, and they in particular were great about accepting my fixes into their repositories for the various issues I found.

One saving grace throughout any challenges I had was I found much of Espressif’s documentation to be very good - far better than I’m accustomed to from embedded hardware vendors. The community was also really vibrant which meant answers were often easy to find.

There was no serial debugging so I had to get a JTAG-capable device to save my sanity. Thankfully a cheap FT232H board in JTAG mode made a good enough debugger.

After lots of trial and error, I ultimately settled on Platform IO with Visual Studio Code for my development environment. It worked pretty well, although I ran into some really nasty bugs in Platform IO when debugging that would cause it to quickly drain my laptop battery (which they still haven’t fixed as far as I can tell).

Eventually the delisted software that inspired this whole project came back for download and I was able to get it back on all my devices and I kind of lost interest after that. However, the time I spent working on it was definitely a rewarding learning experience and made me a big fan of the ESP32.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: