Live data from Hacker News

MicroPython – Python for Microcontrollers

micropython.org

11–20 of 106 posts

Re: MicroPython – Python for Microcontrollers

#14
Hm, interesting. I remember the upcome of Arduino: They advertised their system (setup() once, loop() forever) as very friendly towards tinkerers using 8bit uControllers. Anybody could jump straight ahead without setting up anything in ASM let alone programming the EEPROM externally.

With hardware progress (ESP32 is 32bit/80MHz+), it seems another iteration happened: processing power is traded again for accessability/usability. In this case python.

I could see python becoming the predominant system for 32bit micro controllers. But for small 8bit systems that just read out a sensor and turns of a switch, that will stay in the realm of Arduino and C.

Re: MicroPython – Python for Microcontrollers

#15
post #3

Anybody has experience with how it stacks up against TinyGo [1]? [1] https://tinygo.org/

How large are typical binaries with TinyGo?

Go is a great tradeoff, it's about as easy to learn and fast to write as Python for prototyping, while being a much slicker, faster, compiled language. But will the runtime fit a tiny MCU PROM?

edit: A Hello World written in Go and compiled with TinyGo is just 10kB! https://tinygo.org/getting-started/overview/

It also works on Arduino Nanos, has builtin support for UART, SPI, I2C and PWM, and can also generate Linux binaries. This is a great find!

Re: MicroPython – Python for Microcontrollers

#16
A possible alternative to MicroPython is Nim - it's a strongly typed language with Python-like syntax that compiles down to C. Since it compiles to C, it can use existing C libraries without much fuss (just wrap signatures as needed), plus there's no need for a "micro" version of the language.

Several members of the community have been working on improving the embedded ecosystem: although I haven't played around with either yet, the nesper library (for the ESP32) and ratel (generic framework: tested for the Arduino/AVR) have been recommended.

https://nim-lang.org/

https://github.com/elcritch/nesper/

https://github.com/PMunch/ratel

Re: MicroPython – Python for Microcontrollers

#17
post #15
post #3

Anybody has experience with how it stacks up against TinyGo [1]? [1] https://tinygo.org/

How large are typical binaries with TinyGo? Go is a great tradeoff, it's about as easy to learn and fast to write as Python for prototyping, while being a much slicker, faster, compiled language. But will the runtime fit a tiny MCU PROM? edit: A Hello World written in Go and compiled with TinyGo is just 10kB! https://tinygo.org/getting-started/overview/ It also works on Arduino Nanos, has builtin support for UART, SP…

Yeah, it's a completely different runtime. I think the purists might argue that it's a completely different language, but it feels similar enough that you don't get too upset about the occasional language feature that doesn't work.

I remember using time.Format(time.RFC3339) in a project once. Seemed impossible to have such convenience on a microcontroller, and I probably paid a lot for it, but it did work perfectly.

Re: MicroPython – Python for Microcontrollers

#18
post #15

Earlier quoted context omitted.

How large are typical binaries with TinyGo? Go is a great tradeoff, it's about as easy to learn and fast to write as Python for prototyping, while being a much slicker, faster, compiled language. But will the runtime fit a tiny MCU PROM? edit: A Hello World written in Go and compiled with TinyGo is just 10kB! https://tinygo.org/getting-started/overview/ It also works on Arduino Nanos, has builtin support for UART, SP…

Yeah, it's a completely different runtime. I think the purists might argue that it's a completely different language, but it feels similar enough that you don't get too upset about the occasional language feature that doesn't work. I remember using time.Format(time.RFC3339) in a project once. Seemed impossible to have such convenience on a microcontroller, and I probably paid a lot for it, but it did work perfectly.

If performance is adequate (say 1/3 of C, or 10x faster than Python), this is a big deal.

It means we get a simple, nicely designed language with a great standard library, short development times, and small, performant binaries once compiled. Go on MCUs was out of question because of its runtime size. I'll keep an eye on this.

Re: MicroPython – Python for Microcontrollers

#19

I find reading untyped code unnecessarily difficult. Just this week I came across Swift for Arduino, and SwiftIO, both Swift language solutions for low level boards. I'm looking forward to giving them a spin. https://www.swiftforarduino.com https://www.madmachine.io/

Does micropython not allow typing? That would be odd. I mean, i see how running it with mypy on an esp32 does not work, but the hints can be evaluated on the dev-platform and used by the developer and his IDE/Linter/whatever.

Re: MicroPython – Python for Microcontrollers

#20

I did a lot of product development using Micropython over the past year or so. There are certain things it is very good at - one is rapid prototyping. For instance it’s a lot easier and faster and less verbose to quickly get some http server communication going on the ESP32 in Micropython rather than the C equivalent. The downsides are somewhat dramatic though - it’s, of course, a lot slower and hungrier for memory t…

Yes, I have been using MicroPython on ESP32 and RPi Pico. For projects like home automation, it was super easy and handy. When I started building a game console using RPi Pico (https://github.com/codetiger/GameTiger-Console), I had to rewrite as Python interpreter takes a lot of memory and leaves very little for the application. In my case, I had to avoid using Framebuffer on MicroPython. After switching to C++, its all in your control and take lot of time to write the same simple things
Post reply on HN