# PlatformIO and ESP32 development

**URL:** <https://discuss.tinyml.seas.harvard.edu/t/platformio-and-esp32-development/491>\
**Category:** Programming Q&A\
**Created:** [March 16, 2021, 9:02am UTC](https://discuss.tinyml.seas.harvard.edu/t/platformio-and-esp32-development/491 "2021-03-16T09:02:41Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![gameldar](https://avatars.discourse-cdn.com/v4/letter/g/ecae2f/32.png) [@gameldar](https://discuss.tinyml.seas.harvard.edu/u/gameldar)\
**Post date:** [March 16, 2021, 9:02am UTC](https://discuss.tinyml.seas.harvard.edu/t/platformio-and-esp32-development/491/1 "2021-03-16T09:02:41Z")

</div>

Bringing this over from the projects topic

> [@Using the pico for your project](https://discuss.tinyml.seas.harvard.edu/t/using-the-pico-for-your-project/361/7):
>
> Among the frustrating parts of working with embedded systems is in establishing a stable workflow that you can re-use easily to bring up a new project. I like the vscode platformio extension way better than the arduino IDE and have been using it for a couple of years now in deploying on the esp8266.
> 
> I too, am enamored with the esp32. Espressif seems to really push on using ESP-IDF instead of Arduino as the development platform. Have you gotten ESP-IDF working under platformio? Do you use the vscode platformio extension? What kind of computer are you using?
> 
> I have an Esp-Eye and a Rover or 2 and have gotten the toolchain to work using the vscode espidf extension on a windows machine running WSL2 & ubuntu 20.04 (not in a remote vscode window). More work to do. So far, mainly in keeping myself unconfused over the multiple forks I have made in my quest for a stable workflow.

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](https://discuss.tinyml.seas.harvard.edu/t/micro-speech-example-from-tensorflow-on-an-esp32/376/8) 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](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.

---

<div class="post-metadata">

**Author:** ![rdr91h](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.tinyml.seas.harvard.edu/rdr91h/32/232_2.png) [@rdr91h](https://discuss.tinyml.seas.harvard.edu/u/rdr91h)\
**Post date:** [March 22, 2021, 10:20am UTC](https://discuss.tinyml.seas.harvard.edu/t/platformio-and-esp32-development/491/2 "2021-03-22T10:20:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![vjreddi](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.tinyml.seas.harvard.edu/vjreddi/32/35_2.png) [@vjreddi](https://discuss.tinyml.seas.harvard.edu/u/vjreddi)\
**Post date:** [March 22, 2021, 1:56pm UTC](https://discuss.tinyml.seas.harvard.edu/t/platformio-and-esp32-development/491/3 "2021-03-22T13:56:29Z")

</div>

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:

> **[110+ ESP32 Projects, Tutorials and Guides with Arduino IDE​ | Random Nerd...](https://randomnerdtutorials.com/projects-esp32/)**
>
> Discover all our ESP32 Guides with easy to follow step-by-step instructions. Each tutorial includes circuit schematics, source code, images and videos.

---

<div class="post-metadata">

**Author:** ![rdr91h](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.tinyml.seas.harvard.edu/rdr91h/32/232_2.png) [@rdr91h](https://discuss.tinyml.seas.harvard.edu/u/rdr91h)\
**Post date:** [March 22, 2021, 8:29pm UTC](https://discuss.tinyml.seas.harvard.edu/t/platformio-and-esp32-development/491/4 "2021-03-22T20:29:59Z")

</div>

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.](https://github.com/tanakamasayuki/Arduino_TensorFlowLite_ESP32). You only have to add the library and choose ESP32 board in the Arduino IDE to follow the course.

---

<div class="post-metadata">

**Author:** ![vjreddi](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.tinyml.seas.harvard.edu/vjreddi/32/35_2.png) [@vjreddi](https://discuss.tinyml.seas.harvard.edu/u/vjreddi)\
**Post date:** [March 23, 2021, 2:04pm UTC](https://discuss.tinyml.seas.harvard.edu/t/platformio-and-esp32-development/491/5 "2021-03-23T14:04:53Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![brian\_plancher](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.tinyml.seas.harvard.edu/brian_plancher/32/85_2.png) [@brian\_plancher](https://discuss.tinyml.seas.harvard.edu/u/brian_plancher)\
**Post date:** [March 23, 2021, 2:29pm UTC](https://discuss.tinyml.seas.harvard.edu/t/platformio-and-esp32-development/491/6 "2021-03-23T14:29:14Z")

</div>

@rdr91h you can find the Arduino example in our **[Arduino library here](https://github.com/tinyMLx/arduino-library/tree/main/examples/multi_tenant)**. You can also find the documentation and background materials for the example in our **[courseware repository here](https://github.com/tinyMLx/courseware/tree/master/edX#chapter-47-visual-wake-words)**. 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!

---

<div class="post-metadata">

**Author:** ![rdr91h](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.tinyml.seas.harvard.edu/rdr91h/32/232_2.png) [@rdr91h](https://discuss.tinyml.seas.harvard.edu/u/rdr91h)\
**Post date:** [March 23, 2021, 2:43pm UTC](https://discuss.tinyml.seas.harvard.edu/t/platformio-and-esp32-development/491/7 "2021-03-23T14:43:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![gameldar](https://avatars.discourse-cdn.com/v4/letter/g/ecae2f/32.png) [@gameldar](https://discuss.tinyml.seas.harvard.edu/u/gameldar)\
**Post date:** [March 23, 2021, 2:56pm UTC](https://discuss.tinyml.seas.harvard.edu/t/platformio-and-esp32-development/491/8 "2021-03-23T14:56:41Z")

</div>

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](https://platformio.org/lib)  
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](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.

---

<div class="post-metadata">

**Author:** ![rdr91h](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.tinyml.seas.harvard.edu/rdr91h/32/232_2.png) [@rdr91h](https://discuss.tinyml.seas.harvard.edu/u/rdr91h)\
**Post date:** [March 23, 2021, 3:03pm UTC](https://discuss.tinyml.seas.harvard.edu/t/platformio-and-esp32-development/491/9 "2021-03-23T15:03:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rdr91h](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.tinyml.seas.harvard.edu/rdr91h/32/232_2.png) [@rdr91h](https://discuss.tinyml.seas.harvard.edu/u/rdr91h)\
**Post date:** [March 25, 2021, 8:59pm UTC](https://discuss.tinyml.seas.harvard.edu/t/platformio-and-esp32-development/491/11 "2021-03-25T20:59:15Z")

</div>

Here [https://youtu.be/P9lFlCsu20Q](https://youtu.be/P9lFlCsu20Q) ,you can see the Micro Speech example from [Arduino\_TensorFlowLite\_ESP32/examples at master · tanakamasayuki/Arduino\_TensorFlowLite\_ESP32 · GitHub](https://github.com/tanakamasayuki/Arduino_TensorFlowLite_ESP32/tree/master/examples) 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](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.
