PlatformIO and ESP32 development

Bringing this over from the projects topic

Your reasons for switching to platformio were pretty similar to mine. I hit some serialization issues with the Arduino IDE but primarily I wanted a simple setup that I could use as a base for all my embedded projects.

However I don’t use the VSCode plugin just the command line as I work primarily in Emacs (with evil mode) - I work from Linux rather than Windows so I haven’t had to deal with the WSL2 support either.

In terms of platformio and the ESP32 - I actually still use the Arduino framework (so platform= espressif32, board=lolin32, framework=arduino in my platformio.ini). If you look at the github link from my discussion about the ESP32 micro_speech here on this forum you can see the full details of it.

I have compiled using the ESP-IDF in particular for compiling, deploying and using the tensorflow lite micro hello_world and micro_speech examples - the documentation from the tensorflow readme (https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/micro/examples/micro_speech#deploy-to-esp32) was most of the guide for getting that to work. The output from these I then used to create a tensorflow library for platformio to work with. I haven’t really written down the ‘how’ of this as it was largely trial and error (you’ll see I had to manually include some of the tensorflow dependencies to get it to work).

In terms of ESP32 boards - I have largely just been using the one board a Weemo Lolin32 for the tensorflow tests but I have been used an 8266 in the past too.

I love esp32 and esp8266. There are inexpensive and with a lot of possibilities. I use Platformio + VScode.
In Platformio there is a library, TensorFlowLite_ESP32 with the examples of the course migrated to the esp32 board. I have tried MagicWand and Microspeech in a M5StickC and work fine.

1 Like

Welcome! It would be great if you folks could help share some resources around running on ESP32. I myself have been tinkering with some of them.

Here is one for starters:

Thank you! Here you can find the ESP32 version examples use in the third course GitHub - tanakamasayuki/Arduino_TensorFlowLite_ESP32: Allows you to run machine learning models locally on your ESP32 device.. You only have to add the library and choose ESP32 board in the Arduino IDE to follow the course.

Awesome, thanks for sharing.

It would be really great to add some of the extensions we put in Course 3 which are not discussed anywhere. For instance, it would be nice to run multi-tenancy – show people how we can run more than one model at a time; in production use cases, there are scenarios where you want more than one model on the MCU.

If you have time and bandwidth, I’m sure many folks would appreciate seeing it run on the ESP32. @brian_plancher can you please point @rdr91h to the multi-tenancy example where we pair the speech and vision example together on TensorFlow Lite Micro?

1 Like

@rdr91h you can find the Arduino example in our Arduino library here. You can also find the documentation and background materials for the example in our courseware repository here. Also I would point you in the direction of @cbanbury for questions as he put together much of the example! Good luck and have fun!

1 Like

Thank you!! I will try to run multi-tenancy in an esp32.

Random Nerd Tutorials tends to be my goto if I’m looking for something specific as well.

The other resource is through platformio they have a curated list of libraries: A professional collaborative platform for embedded development · PlatformIO
I’d find the appropriate library for what I need through that and look at the examples (often ending up on the library’s github repository to find more examples too)

The main problem I’ve found is that there is a large variety of development boards and it isn’t always easy to find documentation about your specific board. For example I have a couple of Wemos Lolin32s which wemos no longer have information about on their site. So it took me a while to find out how to flash the board.

In terms of getting some of the tensorflow examples up and running I started out with this link:
https://towardsdatascience.com/tensorflow-meet-the-esp32-3ac36d7f32c7

I did try the TensorFlowLite_ESP32 library that @rdr91h mentioned but I didn’t get it working (but it was also very early on in the process and I’m guessing now I’ve managed to get something running that I’d likely know what was wrong second time around).

I did find most of the code examples in the blog posts around tensorflow and the ESP32 ended up being out of date despite being only a few months old. Generally the problem was that they made use of experimental features that had since moved into the official API.

So apart from that I generally ended up going through the code examples from tensorflow and looking at the specific implementation differences for the ESP32. The links from the READMEs for the examples gave enough information to get me up and running.

Thank you for your kind words. I will record how it runs in an M5StickC, it´s based in an ESP32-PICO Mini, 520KB SRAM and 4MB flash memory.

Thank you for the great TinyML courses.

Here https://youtu.be/P9lFlCsu20Q ,you can see the Micro Speech example from Arduino_TensorFlowLite_ESP32/examples at master · tanakamasayuki/Arduino_TensorFlowLite_ESP32 · GitHub runs in a M5stickC based on ESP32. It is the same of the course 3 with some visualization improvements

And here https://youtu.be/ClvRC5CKS40, the Person Detection example on an ESP32-CAM

I have tried to run Multitenant example but there is a problem, the version used in 3 course is the 2.4.1, and the library I use is 2.1.1. When I have time I will try to fix it.