Is MicroPython the right hammer for my nail?

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
grodstein
Posts: 13
Joined: Tue Dec 01, 2020 6:23 pm

Is MicroPython the right hammer for my nail?

Post by grodstein » Sun Apr 25, 2021 10:57 am

I've probably put 100 hours into learning/using MicroPython on a PyBoard v1.1, but am starting to question whether it's the right road to follow. Any guidance would be appreciated.

My project: I teach computer engineering & biology at a university level, and am putting together an introduction-to-engineering course for first-year students. They're straight from high school and may or may not have any programming experience at all -- this is their first semester of university. The goal is to have them learn a bit of programming and build some fun projects that work with bioelectricity (e.g., reading electrocardiograms and electromyograms and using them to flash LEDs, move robotic arms, etc). Because these are beginners in engineering, I figured that MicroPython with a Windows host would be much more practical than, say, C/Arduino/Linux.

But I'm not really sure that my goal fits with any common MicroPython use model. First, I keep running into issues trying to use a PyBoard from a Windows host. It seems that the overwhelming majority of PyBoard usage is by Linux enthusiasts, and the Windows-specific documentation is very stale. It's not reasonable to expect incoming freshmen to be proficient in Linux, and so I start to suspect that MicroPython is not targeted at beginners. Am I mistaken?

But -- sorry if this is a stupid question -- who is the intended target for MicroPython? Is the goal to build a non-trivial market for real-time programming in Python? That sounds quite challenging, given the obvious performance overhead of Python compared to C.

I guess I'm trying to make a case that MicroPython is a useful tool to use/teach in an engineering school, but am not quite sure that I'm succeeding. Anyone have any suggestions?

Thanks,
/Joel

ellisjr
Posts: 24
Joined: Sun May 17, 2020 8:30 pm

Re: Is MicroPython the right hammer for my nail?

Post by ellisjr » Sun Apr 25, 2021 1:17 pm

I'm a beginner with MicroPython and I've been using it with various generic ESP32 boards (and an ESP32 bare-board setup with a CP2102 to connect to USB) with little problem, using Thonny as my development environment on Windows 10.

The only areas I've found tricky are low power scenarios, trying to actually achieve sub 10uA consumption with real-world software requirements (as opposed to test programs)
John Ellis
What cannot go wrong, will. What definitely cannot go wrong absolutely will... :roll:

BricoMs
Posts: 9
Joined: Sat Mar 13, 2021 8:42 pm

Re: Is MicroPython the right hammer for my nail?

Post by BricoMs » Sun Apr 25, 2021 3:30 pm

I am also a beginner in electronics and MicroPython.
I have used my pyboard or ESP32 with MicroPython on Windows, Linux and Chromebook. No problem at all.

In my opinion it is easier than Arduino IDE and language.
Something that take MicroPython apart for a newbie is the REPL. That way i can test things right away with out need to compile every time.

Christian Walther
Posts: 169
Joined: Fri Aug 19, 2016 11:55 am

Re: Is MicroPython the right hammer for my nail?

Post by Christian Walther » Sun Apr 25, 2021 7:03 pm

grodstein wrote:
Sun Apr 25, 2021 10:57 am
I start to suspect that MicroPython is not targeted at beginners.
You are probably right about this. To name the elephant in the room, are you aware of CircuitPython? It’s a fork of MicroPython with the express purpose of being friendly to beginners, at the expense of some of the power and control MicroPython aims to give to professionals.

grodstein
Posts: 13
Joined: Tue Dec 01, 2020 6:23 pm

Re: Is MicroPython the right hammer for my nail?

Post by grodstein » Sun Apr 25, 2021 11:19 pm

To BricoMs: congratulations! Getting good results for a Pyboard on Windows has eluded me so far. How did you work your way through the Windows driver installs necessary for firmware updates? I've not found anything approaching up-to-date documentation for that.

To ellisJr: again, congratulations! Perhaps I should switch to an ESP32 instead of the PyBoard.

To both of you: still ahead of me is that task of rebuilding MicroPython to include ulab (a version of Numpy that's small enough to fit on a MicroPython board). If I've not even come close to being able to load existing firmware on Windows, it seems even less likely that I'll succeed in building my own custom firmware version. Have either of you tried that?

To Christian: I have heard about CircuitPython. What I've not seen, though, is an in-depth comparison between them. For example, I've heard that CircuitPython supports a single API across all devices, rather than tuning a different API to each device. Clearly simpler to use, but at some performance cost. What I've not heard, though, is any attempt to quantify how much that performance cost is, or specific examples of where that cost is. Do you have any?

The other part of the question still is: if MicroPython isn't aimed at a new user (as evidenced by what looks like Linux being a much more favored platform than Windows), then is it really aimed at more commercial use? What is the intended market for commercial development in Python rather than C, given the obvious cost/performance/power issues? What am I missing here?

Thanks,
/Joel

oyster
Posts: 26
Joined: Tue Feb 16, 2021 1:21 pm

Re: Is MicroPython the right hammer for my nail?

Post by oyster » Mon Apr 26, 2021 2:35 am

Sorry to someone who perhaps feel be offended by following words.

The more I learned micropython, the more I feel that micropython is a tool for hacker, which is (maybe only) used by some hacker users stealthily for practical projects.

The website and resources are afraid (or shamed? ) of telling normal users about how can we finish a successful project with micropython. Don't misunderstand me, if we do some search, we can read successful stories distributed on the forum and internet; but since the stories are too scattered, the evidence is not so convictive for normal people who want to judge whether micropython can fit his project.

On the contrary, https://learn.adafruit.com/how-to-send- ... -adafruit/ (in fact, https://blog.adafruit.com/) gives more friendly stories.

BTW, I always do not think it is a successful story if there is ONLY news on huge amount of sale of various physical boards which support micropython/circuitpython/etc. The similarity lies in Chia e-coin which bursts the sale (and thus price) of harddisk, but to be frankly, nothing is created by Chia, instead electricity is wasted.

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: Is MicroPython the right hammer for my nail?

Post by davef » Mon Apr 26, 2021 4:01 am

It's not reasonable to expect incoming freshmen to be proficient in Linux, and so I start to suspect that MicroPython is not targeted at beginners. Am I mistaken?
The level of proficiency required to do some fairly basic stuff on the command line, ie navigate directories, make files, edit files, run make and then a few commands to load your binary on to the device, using Linux, I suggest is could be taught in an hour or so.

I would suggest searching for articles like this https://ashikquerrahman.medium.com/why- ... 2baf5709dabefore choosing an operating system.

Your stated use cases suggest that you are aiming the training at embedded computer engineering, not writing application software or network security.

kevinkk525
Posts: 969
Joined: Sat Feb 03, 2018 7:02 pm

Re: Is MicroPython the right hammer for my nail?

Post by kevinkk525 » Mon Apr 26, 2021 5:17 am

Personally I think micropython is beginner friendly and a good way to teach embedded systems.
Documentation and how-tos might be lacking here and there but that doesn't mean micropython is only meant for "hackers" or "Linux enthusiasts".

I have no experience with the pyboard and only little experience with the pyboard-d (and that was a hassle.. Not fun getting it set up in windows due to lack of proper instructions at the time..).
But I do have plenty of experience with the esp8266 and the Esp32. Lately I'm even using the Pico.

Connecting to those boards from windows isn't a problem and works out if the box, there are even gui tools to flash a new firmware and good command line tools to connect to the board repl. However, as many mentioned, it is also easily possible to use thonny ide for programming which would make it a lot easier.

Additionally using widely available and very cheap boards like the esp8266, Esp32 or Pico might be a benefit because students are unlikely to invest larger amounts of money into something they might not be interested in. But the mentioned boards cost 2.5$-8$ which could raise the interest a bit for students to buy a board and try more things. Especially the ones with wifi might be interesting (in my opinion) because there are lots of use-cases beyond moving a robotic arm while standing directly besides it. Controlling it remotely might be interesting.

I never tried building a custom firmware on windows, I use Ubuntu wsl for that.

As for circuitpython: I do like that they offer an equal set of functionality across all boards and it makes some things easier. But they don't support any of the mentioned esp modules, which is sad as those are very popular and cheap. Furthermore, personally, I think their approach of python programming is rather frustrating and reminds me more of vba than of python.
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode

grodstein
Posts: 13
Joined: Tue Dec 01, 2020 6:23 pm

Re: Is MicroPython the right hammer for my nail?

Post by grodstein » Mon Apr 26, 2021 3:25 pm

Thanks to all for the information. I think I'm starting to get a feel for the most common use models -- please correct my remaining mistakes.
  • The sweet spot (a.k.a. plurality) of the MicroPython users seems to be hobbyists. They almost exclusively do their development on some flavor of Linux. They appreciate the ability work in Python (rather than, e.g., doing everything in C++ with cross-compilers) because, being hobbyists, their time is in short supply.
  • Because this is Python, after all, there are also some real newcomers to programming. However, their numbers may tend to diminish. First, they can easily move to Adafruit -- which is a commercial enterprise with them as the main customer, with all the benefits that implies. Second, since the MicroPython sweet spot is hobbyists, the mass of the MicroPython documentation tends not to be aimed at beginners. And third, while a Pyboard actually does plug and play perfectly well with Windows 10 (despite the fact that the outdated documentation says otherwise), at some point they may run into Windows Driver Hell (as I have) and lose hope.
  • The actual commercial use of MicroPython is probably not great. In a market where pennies and mW count, it seems unlikely that MicroPython would be competitive with a good compiler. But Python bytecode might be space-efficient enough to win some points here.
For me personally, I don't fall into any of those groups. While I'm perfectly comfortable in either Python or C++, I'm not particularly good at, e.g., USB device drivers. And so I've never succeeded at flashing new firmware for my Pyboard. And my main skills (I spent 25 years in CPU design and post-silicon debug) are not particularly relevant here.

Interestingly, it actually does seem like MicroPython might be a good fit for this particular class. The students get the benefit of using Python; C++ as an intro-to-programming language would not work nearly as well. I have a friendly and competent IT group to figure out all of the device-driver stuff for me. And the fact that Python is so much slower than C++ in most cases is actually a benefit here -- it makes the hardware/software host/controller tradeoffs glaringly obvious :-) and easy to demonstrate. The only problem is that I really cannot make the case that learning more about MicroPython will be useful for their career.

So again: thanks for the help, and please correct any misconceptions on my part.

/Joel

ellisjr
Posts: 24
Joined: Sun May 17, 2020 8:30 pm

Re: Is MicroPython the right hammer for my nail?

Post by ellisjr » Mon Apr 26, 2021 3:37 pm

Well, I have to say that building your own version of MicroPython is more challenging, but your students won't have to do that once you have. I couldn't manage it on Windows but I did succeed on a Raspberry Pi and I would have managed that more easily if I had read every little detail of the process more carefully.

However, and forgive my possible misunderstanding, isn't ulab a module that you can use with standard MicroPython? You might need to use an ESP32 that uses an ESP32-WROVER instead of an ESP32-WROOM so that you have a lot more memory when you are running the code you write.

Finally, I have to agree with others; if I can use it it is probably useable by most people with some idea of programming. Of course some areas that pertain to particular ESP32 functionality can be a bit frustrating but that was the same when I was dealing with Intel 8085 forty years ago :lol: I think I have often had to look for other code examples on the Internet to supplement the MicroPython and ESP32 documentation. Much easier than when there was no access to other's efforts. ;)
John Ellis
What cannot go wrong, will. What definitely cannot go wrong absolutely will... :roll:

Post Reply