Advice sought - learning mbed from Arduino background

18 Sep 2019

Hi all,

I want to migrate from using Arduino to using mbed for development of low power devices, initially uControllers containing Nordic BLE chips.

I am willing to put in some up front time learning c or c++, before diving into mbed proper - but will this be worth it, if so which? Which is the best way you would advise me to proceed?

To give you some context here is a precis of my relevant background :

Programming: I worked on LAMP dev (mostly backend) for many years, as such I'd say I'd say I was somewhat Enterprise Software oriented - TDD, Unit Tests, Design Patterns etc granted that is in scripting languages PHP, Javascript some Python etc. I'm cool with CLI Linux setups and simple BASH scripts. I've used Arduino for personal projects for about 5 years without having to actually stop and take the time to learn what is going on, I just picked up stuff that works by trial and error, re-use other people's libraries, read code. I always manage to just get by - but am often stymied when I wander "off piste" and try to write stuff of my own.

Hardware : I have no formal EE training, just started with Arduinos and moved to breaking electrical gadgets to see how they work, then spent time soldering up perf board prototypes etc. This is mostly in the low power domain, targeting remote connected devices with simple sensors and gateways (I live in a rural environment). This year I discovered these Nordic Arm chips and am wowed at their potential, I'm doubly motivated now given the recent adoption of mbed into Arduino BLE boards.

Mbed : I have used the mbed online compiler, and have simple programs that run on my chosen target (including the NRF 52_DK) I read through the rich library of open examples that others have contributed and can largely grok what is going on.

Forgive the long post, but I'm hoping it yields regarded replies. I was unable to find a similar question on here, or on SO. I've taken the time to wander around in the uController space but now find myself yearning to get back into programming proper- I just need some direction here.

(from interaction on various Arduino forums I'd say I am not alone in feeling dissatisfaction with a "software only" existence, fwiw)

25 Sep 2019

Hi Paul,

It is worth of learning c / c++. c is the basic language with microcontrollers. Think what you want to do with the hardware you have (which works with mbedOS). Check the hardware / boards what properties you hardware have. Look the list of IO features. Then look Tutorials: https://os.mbed.com/docs/mbed-os/v5.14/tutorials/index.html Start to play with features starting from leds, buttons, button interrupts, timers ... Use serial communication: https://os.mbed.com/docs/mbed-os/v5.14/tutorials/serial-communication.html

Regards, Pekka

25 Sep 2019

Pekka,

Thank you for your reply.

I'm all for playing with things and making them work - and this indeed has been my means of learning this far.

The focus of my question was really that I believe that I have reached the pinnacle of how that method of learning is going to serve me (I acknowledge others' are happy doing this).

I now need to have a far deeper understanding of the language - but, which one? C or C++?

An example might help.

Recently, I was rolling a class to encapsulate a particular BLE advertising payload.

It took me ages to work out that arguments which were arrays passed to a method had to be done so as a pointer.

I've just discovered what a destructor is in C++, but am unsure about when to use it.

How much memory am I using after run time, am I expected to garbage collect, what is best practice?

These are Qs I am sure I could just post of the forum and get answers to, but I don't like working like that.

You see I come from a universe where to something "simple" like reverse an array, you just use array_reverse() on it, and my first inclination is to find the equivalent in C or C++.

26 Sep 2019

I came from Arduino as well. My background is in analog electronics, but need some digital assistance from time to time. I'm far from an expert, but I felt I'd gone as far as I could with Arduino. This came down to two big problems for me.

Documentation: If you want to do something in Arduino that fell outside of anything on their reference page you'd often find yourself delving deep into 20 page threads on their forum with little way to get back to the information to reference it later without going through the search hunt again.

Hardware: The hardware is limited. There are other boards and MCUs with unofficial support, but that goes back to problem #1, only worse. Want to use an STM32 other than the bluepill with stm32duino? Go ahead, but you'll need to do a lot of work just to get started. It took me forever to get an STM32f303k8 running. I had to set up the clock and do many things via registers. That is probably all great stuff to learn long term, but it takes away from the advantage of mbed and arduino being able to easily test out ideas before you commit too much time.

I've only really been getting into C++ for a few years, so I'm no expert. It's only been in the last two years that I've made an effort to learn best practices, read some books, watch tutorials, etc. The truth is I have no idea when to use a destructor either. C++ is a very versatile language. There's usually a number of ways to do things. You will do things "wrong" as a beginner. You'll look back and cringe and ham fisted code once you learn a few new tricks.

27 Sep 2019

Looking back and cringing, yeah, I think I've earned a PHD in that. Maybe that is unavoidable then.

Thanks for your regarded answers all the same, I'll figure it out.