Live data from Hacker News

MicroPython

micropython.org

81–90 of 152 posts

Re: MicroPython

#81
post #30

MicroPython is stellar. If you're building an embedded system for people to hack and customize, make the highest level abstraction of the embedded system in MicroPython so that users can easily modify/patch/contribute/hack your system with ease. This is what Arduino and Arduino IDE did for millions of hobbyist, but it is time to ditch C/C++ for MicroPython. In this [1] PyCon talk by Matt Trentini, a demo of QR code g…

Great so now in order to create a performant embedded app i need to write everything in two languages. We should make Rust compile to Arduino and other embedded devices and be done with it.

There's a real advantage to having an interpreter.

Write your low-level/high performance code in whatever. Then write top-level logic-- and let your users script in-- micropython.

I'm teaching a middle school class this year with micropython on embedded. I can't fit Rust in with everything else I'm teaching in one trimester. I've even written an IDE which runs in the browser (on chromebook, etc) so there's no external dependencies for them.

Re: MicroPython

#82
post #4

Earlier quoted context omitted.

Why not? I've used it and it works fine, you don't get the granular control you get with C but I don't think there's anything that makes it fundamentally unsuitable for production.

There are a few reasons. Number one, stability issues from heap fragmentation. http://docs.micropython.org/en/latest/reference/constrained.... Even if you are careful about manual allocation, Python is not a compiled language, and the interpreter will frequently request heap allocations on its own. So if you expect a program to run for a long time without crashing, you'll probably need to use much less memory than th…

I have an ESP8266 running MQTT to make an alert on a speaker (I2C) on demand. I just looked at the counter I periodically send to MQTT. It has been up for over 200 days. It does not leak.

Re: MicroPython

#83

MicroPython is stellar. If you're building an embedded system for people to hack and customize, make the highest level abstraction of the embedded system in MicroPython so that users can easily modify/patch/contribute/hack your system with ease. This is what Arduino and Arduino IDE did for millions of hobbyist, but it is time to ditch C/C++ for MicroPython. In this [1] PyCon talk by Matt Trentini, a demo of QR code g…

I haven’t looked at the latest advancements with MicroPython, but last I checked it was both slow and unsafe in ways I wasn’t used to, such as certain language features not being allowed in interrupt handlers, certain operations being interruptible, etc. I totally hear what you are saying about building stuff for less technical people to hack on, but as someone comfortable with C (gasp! shock!), I prefer the predictability I know. And I normally write Python code for nearly everything.

Re: MicroPython

#85
post #54

MicroPython is stellar. If you're building an embedded system for people to hack and customize, make the highest level abstraction of the embedded system in MicroPython so that users can easily modify/patch/contribute/hack your system with ease. This is what Arduino and Arduino IDE did for millions of hobbyist, but it is time to ditch C/C++ for MicroPython. In this [1] PyCon talk by Matt Trentini, a demo of QR code g…

Do you think it's suitable as a game scripting language? How hard is to write bindings for micropython? I've looked into cython but I'm not sure it's what I really need.

It is not too difficult, just extremely verbose (even for a simple int arg function): https://docs.micropython.org/en/latest/develop/cmodules.html

This might help: https://github.com/stinos/micropython-wrap

Re: MicroPython

#86
post #81
post #30

Earlier quoted context omitted.

Great so now in order to create a performant embedded app i need to write everything in two languages. We should make Rust compile to Arduino and other embedded devices and be done with it.

There's a real advantage to having an interpreter. Write your low-level/high performance code in whatever. Then write top-level logic-- and let your users script in-- micropython. I'm teaching a middle school class this year with micropython on embedded. I can't fit Rust in with everything else I'm teaching in one trimester. I've even written an IDE which runs in the browser (on chromebook, etc) so there's no externa…

Exactly. All high level logic (no loops, massive arrays, and heavy arithmetic) can be written in Python. Overhead for C binding calls is minimal. The downsides related to undetectable slowless exceeds the utility and ease of development. Not to mention, over the air `upip` installs! If you have an ESP32/8266 or any wifi enabled chip, you can call:

  upip install foo
at runtime!

Re: MicroPython

#87
post #65

MaixPy ported Micropython to K210 (a 64-bit dual-core RISC-V CPU with hardware FPU, FFT, sha256 and convolution accelerator). It includes a general-purpose neural network processor, which can do convolutional neural network calculation at low power consumption, for example obtain the size, coordinates and types of detected objects or detect and classify faces and objects. It can load TensorFlow Light Neural Nets. htt…

That is awesome! Unfortunately the K210 link on the site is giving me a certificate error so I'm a bit afraid clicking into it. Do you know if the library will work with ( https://www.seeedstudio.com/Sipeed-Maix-Cube-p-4553.html )?

I think it should. I have the Maix-Go (https://www.seeedstudio.com/Sipeed-MAix-GO-Suit-for-RISC-V-A...) and it works pretty well. I also own the m5stick-v which has the K210 builtin (https://m5stack.com/collections/m5-core/products/stickv). I connect to them via screen on linux and get a micropython prompt in an xterm and can use it interactively. There is also an IDE available. See also the docs at M5Stack: (https://docs.m5stack.com/#/en/quick_start/m5stickv/m5stickv_...)

Re: MicroPython

#88

Neat, but not very practical. To be of any use you still need board support to drive the I2C, SPI, etc which means you have to use C anyhow. You can buy one of their boards with the BSP but that's over $40, yikes. To use micropython you need at least an M4 class micro-controller so that a $5 or greater part. Or you could just stick with C and use a M0 class micro that costs A difference of $40 in BOM cost makes it on…

Look into ArduPy, which lets you compile arduino libs as loadable python modules:

ArduPy is a combination of Arduino and MicroPython. MicroPython uses the universal Arduino API to control the hardware so that it can be compatible with new platforms quickly. With the help of the aip package manager we provided, you can transform your favorite Arduino library into a MicroPython library.

https://github.com/Seeed-Studio/ArduPy

It works very well on the Seeeduino XIAO (https://www.seeedstudio.com/Seeeduino-XIAO-Arduino-Microcont...) which is arduino compatible and costs $4,90 per piece. You can even get a grove shield for the same price and you are ready to go.

Re: MicroPython

#90
post #76

MicroPython is stellar. If you're building an embedded system for people to hack and customize, make the highest level abstraction of the embedded system in MicroPython so that users can easily modify/patch/contribute/hack your system with ease. This is what Arduino and Arduino IDE did for millions of hobbyist, but it is time to ditch C/C++ for MicroPython. In this [1] PyCon talk by Matt Trentini, a demo of QR code g…

The one big issue I've had with MicroPython is that it's a PITA to manage files on it. I use this hacky tool called "ampy" to do it, and wish that the device could just be mounted as a media device. CircuitPython, however, does accomplish this, with the microcontroller showing up just like a USB drive.

Very soon you'll be able to mount a PC filesystem to appear on the device, so just make changes locally and they're reflected on the device. It's an exceptionally productive way to develop - I even prefer it to working with USB mass storage.
Post reply on HN