MicroController Learning First Steps (ESP vs RPi)

Hello everyone,
I’ve been using SmartThings for a few years, but considering Home Assistant for the last few months.

One of the things I’m most interested in is creating custom hardware and software integrations using microcontrollers. First, I’d like to start with an understanding of which platform will likely result in the best long term success and consistent approach so that I can focus my research and learning in the right areas.

From watching a few YouTube videos, it seems…

RPi Pico/Python is a little more straightfoward to pick up w/ lower power consumption, but has fewer libraries and no integrated WiFi or Bluetooth, whereas

ESP32 is programmed with C++ which is a little harder to code in (noob here) and uses more power, but has an extensive library and integrated WiFi and Bluetooth.

Any recommendations with choosing a platform and where to continue my learning?

Thank you

The title of the category you posted in is the answer to your question.

ESPHome is configured with simple yaml snippets. No programming necessary.

Pitck a sensor/device, copy the yaml from the docs, adjust it for the gpio pin you want to use and upload to your chosen ESP board. It’s that simple. It has a native api that works with Home Assistant and uses discovery for easy inclusion of your devices.

Here’s a well documented doorbell project as an example:

OK, thank you. You’re right, I knew I was basically posting “Should I use ESP?” in the ESPHome forum.

Maybe a better question would be…

If you were starting all over again (and didn’t already know C++), but also wanted to get into advanced custom projects (not just copy/paste YAML) for Smart Home and other projects, would you go ESP/C++ or RPi/Python?

I’ve used c++ to program an Arduino. But replaced it with ESPHome when I started using home assistant.
It really is a case of a few lines of config yaml instead of hundreds of lines of python or c++.
One controller for a filtration system I designed was around 800 lines of carefully written, efficient c++.
This was replaced by around 40 lines of yaml and has the added benefit of a online interface in home assistant, WiFi connectivity.

Ok. Thank you. Maybe I need to ask my question on a different forum.

In the meantime, I did find this which may provide the best of both frameworks:

The answer to your question is that esp32/esp8266 will do what you want and will do it superbly with esphome.

And if you want something that doesn’t have an esphome component then you can add some c++ code into the esphome yaml code.

Ask anywhere you want, but that is still the answer.

Fair enough. Sorry if my reply offended you.

I’m just trying to determine if Arduino and C++ are the best platform to start learning a new hardware and coding language (even if YAML covers most of what is needed for HA).

I think I got the answer that Arduino/ESP/YAML/C++ meets all of your needs for this application, so you don’t feel the need to try another platform.

I’ll look at other forums to understand their perspective.

Welp, you asked for another perspective. I’ll give you one. I’m a C++ dev, I design and write low level code running on massively parallel stream processors for a living. I never used ESPHome and I deeply dislike Python.

If you want to learn how to create quick and easy hardware that integrates with HA, I guess ESPHome is a good way to do that. I can’t really say, I never used it. But it seems very popular around here. ESPHome has very little to do with actually programming an MCU though, unless you fall back to using pure C/C++ in the YAML. If you really want to learn about the gritty details, start with the Arduino IDE. The MCU itself doesn’t really matter at this stage, one of the ESPs or ATMega328 based boards, just pick a cheap one. Later on you will learn to pick the right MCU for the job and maybe go beyond the usual beginner boards. There’s a whole other world beyond ESPs and Arduinos out there.

Learn about how the MCU works, how to use direct hardware registers, signal timing, interrupts, deep sleep modes, what efuses are, how interfaces like SPI or I2C work on a low level, what JTAG is. The gritty details. It’s gonna take a while, there’s a very steep learning curve especially if you start from scratch.

Or use ESPHome if you just want to develop ESP based IoT devices with Home Assistant.

Two different approaches. Pick the one that suits you best.

Btw, you can program the RPi Pico in C as well.

@HeyImAlex That’s very helpful. Thank you.

What do you dislike about Python? From what I’ve come across lately, it seems to be taking the lead amongst programming languages.

One example - https://youtu.be/m1miwCJtxeM

Personal preference. Python uses a very very different approach than C++. Both are very different languages with radically different philosophies and have different application domains. But that’s really out of scope of this thread here. You’ll find lots of (often highly biased and subjective) info on the net about this.

Thanks. Actually, I think I’m trying to bring it in scope with this thread. If MCU’s that have the RP2040 chip like this one…

…take off, couldn’t Python quickly become the preferred language for programming home automation projects? It seems like the best of both worlds - easy to learn/modify and powerful/flexible.

Also, it sounds like there’s some benefit about not needing a compiler that I don’t full understand yet. Big deal?

Well micropython is already a good option for esp and probably other mcus

Of course Python is easier. That’s the whole point behind the language, make it as easy as possible to pick up and code in. At this time, Python is probably the easiest programming language to learn. That made it very popular. Of course there are tradeoffs that come from that simplicity, mainly performance and control. C++ on the other hand is probably one of the hardest languages to learn. It’s extremely vast and overly complex at parts. You typically won’t need most of its functionality when programming MCUs though. The advantages are raw speed and total control over your system. Python itself is written in C++ btw. So in the end, it all boils down to what your priorities are.

Python is like replacing the windshield wipers on your car. You buy a premade kit and latch them into place using a provided premade mechanism. Sometimes it will require some jiggling around and you could technically mess it up, but normally it’s easy peasy and you’ll be up and running again after a short time.

C++ is taking your engine apart and replacing the valves with your own 3D printed parts to increase performance. It’s going to be messy, take longer and if you don’t know exactly what you’re doing, you’re going to damage a lot of stuff. But you’ll get the last little piece of performance and control out of it.

Yes, I’m biased :wink:

Just try out both and go with whatever you like best. Who cares about what the current ‘preferred language’ is. What is important is that you feel comfortable with it.

1 Like

Thanks. Good rundown.

I’ll start with (Micro)Python and see if I run into things I can’t do without C++.

For hardware, now that I understand that software language voice isn’t a factor, my focus is on low power and deep sleep.

Sounds like a good approach. Like hardware, language and firmware build platform are just additional aspects of your overall technical design choices. Those choices are not going to be the same if you’re building a mailbox sensor or a drone flight controller. Assessing the technical limitations of a platform, both HW and SW side, and picking the right tools for a project is part of the learning experience.

1 Like