RP2040 or some other microcontroller

Jul 24, 2022 Last reply: 3 years ago 6 Replies

Any suggestions on where to begin with microcontrollers? This is for a simple application with very low CPU and other resource requirements.



The idea is to make a battery-powered device which will send and receive GSM texts and interface with some simple devices (LCD display, RTC, GPS, temperature sensors, etc).



Would you recommend a RP2040 uc for that? If not, [and this is somewhat OT, I realise] what else?



I'd prefer to program in C and avoid proprietary software. I hated the Microchip development environment I tried years ago as it wanted to install untold megabytes of overkill lock-in(!).



I use Linux mainly, Windows occasionally.



I guess a number of you have already been down this road probably many years before me. Any guidance would be welcome!


It really depends on how much you want to do yourself, and how much you want to build on existing software. One of the standouts in the hobby microcontroller world is Arduino - this started as a simple way to program 8 bit Atmel microcontrollers, but has since expanded to cover a range of Arm MCUs, including the RP2040.

The advantage of the Arduino ecosystem is the libraries for talking to devices: you don't need to write your own LCD controller driver, you just pick an LCD controller somebody has already written one for and you're away. There's probably also a GUI drawing library as well, etc etc.

The Arduino language uses 'sketches' which are really a dressed up form of C++. You can write native C/C++ and link it all together if you want. Everything is open source, and typically it's really just driving GCC under the hood. The bundle is not small (there's also a GUI written in Java), but that's mostly because there's compilers and libraries for several architectures.

ATMega is the best supported Arduino platform and sometimes the Arm side of things can feel slightly second class, mainly because there's fewer people using it and documenting the differences between platforms. I think it's always improving though (I also haven't used it for a few years, so may be out of date). RP2040 support is new in the Arduino world and I'm not familiar with more mature it is these days.

As far as hardware goes, RP2040 is a decent platform. It's less limited than 8-bit ATMega, and has some useful features (eg dual core). It doesn't have wifi, so most people who want that use the ESP32 or older ESP8266. All are relatively usable with your own PCBs (unlike the full Pi family).

[a few weeks ago the Pi Pico W was launched which fills the wifi hole - looks promising, but I think it'll take time to mature the software support to the level of the ESPs. You'd have to mount the PicoW module on your board, you couldn't do wifi with just the microcontroller chip]

If you don't want to rely on anyone else's libraries, they're all usable with GCC and the RP2040 is particularly well documented in comparison to other silicon. So if writing drivers is your thing, you should be covered.

Theo

It does now. New model rp2040w has wifi.

The RP2040 chip does not have wifi. There is no such thing as an RP2040W. The Pi Pico W module has wifi, by putting an additional wifi chip next to the RP2040. Which I said in the subsequent paragraph...

Theo

F*ck! I stopped reading after "doesn't have wifi", my bad. And you're technically right that the name of the board is PicoW and RP2040 is their chip, of course, but that was a minor slip up in naming. Main thing is I didn't read the whole post.

Better yet is PlatformIO, which can run under VSCodium (or Visual Studio Code if you're not an open-source purist). It supports pretty much every microcontroller and programming environment out there, including Arduino, and only pulls in what you need for the task at hand. I use it for various projects I've come up with, as well as to maintain the firmware for my 3D printers.

(Never cared much for the Arduino IDE...used to have problems with it rendering in ridiculously-small fonts on my 4K monitor, and haven't checked back to see if they fixed that problem.)

Never heard of it, but I think PlatformIO is an IDE rather than an environment? In other words it compiles and debugs stuff, but doesn't have any libraries for specific chips. You have to install the compilers, libraries and become familiar with whatever environment (Arduino, ESP32, etc) and PlatformIO will help you compile it - but it won't provide you with any code.

So a fancy editor and makefile really? Although it looks like a good option if you have to work with multiple environments and don't want to wrestle with every vendor's dumb IDE (there are a lot of vendors and a lot of dumb vendor IDEs out there). Plus you aren't stuck on Windows as a lot of the vendor IDEs are.

However it can't be said enough that the key to making fast progress is good libraries: not having to write the code to talk to the peripherals you have is a huge timesaver, over doing all the bit-twiddling and register reading/writing yourself. The platforms like Arduino come with a vast array of support for external chips and devices, while vendors typically only provide support for the components internal to their chip.

You can use Arduino stuff without the IDE, that's just a convenient frontend. I would suggest a beginner starts with the IDE though, since it can bring up examples that you can compile and run in a few clicks - good for checking that everything is working. Eventually your project will get to the stage of needing to write build infrastructure, and at that point you can depart the IDE, but for simple hello-world type things the IDE is an ok starting point.

(I've had the tiny-text thing - usually because Java programs don't obey the host's DPI scaling. I think that's generally got better, although I can't say I've tried it of late)

Theo

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required