Hacker News new | ask | show | jobs
by botdan 1420 days ago
I'm a casual embedded-electronics user at best, most of my projects haven't advanced much past turn a simple servo, light some LEDs, maybe read a sensor and POST to an endpoint. For these tasks, Arduino has been pretty good for me and removed a lot of the complexity. The `setup()` and `loop()` model makes a lot of intuitive sense. That being said, I've spent no small amount of time on `String` vs `char*` (as an inexperienced C/C++ developer) and found the guardrails of the Arduino ecosystem to be very frustrating.

Do you have any recommended resources or additional search terms to explore to learn more about hobbyist-level embedded electronics outside of the Arduino ecosystem? FreeRTOS looks interesting but it seems to add a lot of overhead versus something simple like Arduino. Similarly, I've looked at STM32 programming before but my searches were very generic and the STM ecosystem is massive. Specifically, I was trying to figure out if I could reprogram some old drone flight controllers (equipped an STM32F103CBT6 with a bunch of useful embedded sensors, running old versions of "betaflight") for personal projects but the entrypoint to STM programming (STM32Cube?) and the setup code was considerable.

2 comments

The beauty of the Arduino is the ecosystem behind it. The original hardware is verging on obsolescence, to be polite, but the same code and programming methods can be used on STM32 hardware (that's Arduino-compatible, like the Blackpills) or ESP32. The main difference is that now you have much faster, more modern processors, far more Flash and RAM to play with, not to mention a more powerful I/O peripheral structure if you want to dig into it at that level.

FreeRTOS on an ESP32 in the Arduino IDE is effectively free: you don't have to do anything to enable it. It's pulled in by default.

AFAIK, Arduino support for STM32 is limited to the F103 & F4xx series.

I confess that since my entry point is as a professional, I really haven't kept up with what other hobbyist-level entries are still on the market. That said, a good place to start would be with an STM32 Discovery board -- if you can find one these days! Looks like Digi-Key has exactly 1 in stock rn. It's a $19.95 board with an 'F407 and some sensors and output devices. No external tools needed: you can program it through a USB port. All the tools can be downloaded from ST Thomson or its partners for free. This is more entry-level professional than hobbyist, but there's no sharp dividing line there.

The Raspberry Pi pico is also taking off: https://www.raspberrypi.com/products/raspberry-pi-pico/ I haven't used one yet, but they seem to be amazing little devices and the community is rallying around them.

Pi Pico is also dual core, So in essence it should be easier to write multi-tasking code there.
I think AVR is a good architecture to learn on, because the devices are far simpler than ARM or other more modern chips. The main concept to master as an embedded developer is operating a device by its registers. The common arduino device, ATMEGA328, has a total of 84 registers across all peripherals. A simple program to blink the LED is less than 10 lines total. The datasheet is tiny compared to most ARM devices, but is still a complete source of information.

There are lots of libraries online that demonstrate how to set up registers for various peripherals. Avrgcc is an open source toolchain, and avrdude can program devices running the arduino bootloader.

That was true when one had to write assembly code. Now we don't really have to any more, thanx to Arduino mainly (which bilds upon avrgcc and avrdude). It's easier to learn on the new platforms because you can use higher level programming languages like MicroPython, especially for easy stuff. I can do a blinky by writing three lines in the uPy REPL.
If the registers are abstracted away, you're left relying on other people's code. I suppose learning microcontrollers can mean different things to different people, but as for becoming a professional embedded developer, micropython and Arduino are dead ends. There is no transition to truly understanding the hardware.
We use MicroPython commercially so my perspective is different. :) I do agree with your intent though; just because you're using a high-level language it doesn't excuse you from learning how the hardware works.

However, if you do know the hardware, if you are familiar with what's going on under the hood, then MicroPython allows you to write the majority of your system significantly faster.

This is subject to change, as embeded developers now focus on writing lower or higher level code mainly in C/C++ as the industry migrates away from 8-bit MCUs to 32-bit ARM and RISC-V. Of course you're relying on other people's code, as you can't expect everyone to write their own RTOS and standard library and also achieve an acceptable time to market. Most embedded hardware products use an existing RTOS and build upon it. Understanding how the hardware works always helps, but most of the time you don't have to dig to register level to do that.

Micropython and Arduino are not dead ends but hobby grade tools.