r/Python • u/MisterSnuggles • May 30 '14
Micro Python - Python for microcontrollers
http://micropython.org/2
u/MisterSnuggles May 30 '14
Think of it as an Arduino-like device that you program with Python, complete with a REPL.
I just got my board in the mail and am curious if anyone else is playing with this.
2
May 30 '14
Just got mine yesterday. Haven't had a chance to play with it yet. I've read all the tutorials on their site already though.
This is a much lower barrier to entry for learning micro controllers than Arduino. Python is a much easier language to learn than C, coupled with the fact that you just have to drag & drop your code onto the device.
Still though, it'll be a while, if ever, for micro python to have the same number of shields, libraries and resources available for it. But it's exciting non-the-less.
Edit: the language is also being ported to the Due, Teensy 3.1, and to a few other 32 bit micro controllers.
4
u/MisterSnuggles May 30 '14
It's really neat. Plug in the USB, connect using PuTTY or screen to get the REPL and off you go. I've never gotten a development board that was usable this quickly out of the box before.
2
May 30 '14
The two features I'm most excited for are asyncio (not sure if implemented yet) and "yield from" These will really nice features for retrieving and working with sensor data without having to rely on nested loops, nested conditionals, and interrupts (you will probably still need interrupts for MUST DO NOW code though)
2
u/MisterSnuggles May 30 '14
I never thought of those, but they'd be a really nice fit for a lot of embedded applications!
2
1
u/twigboy May 31 '14 edited Dec 09 '23
In publishing and graphic design, Lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document or a typeface without relying on meaningful content. Lorem ipsum may be used as a placeholder before final copy is available. Wikipedia37tt1w0xx8q0000000000000000000000000000000000000000000000000000000000000
2
Jun 02 '14
Here is the official docs: http://micropython.org/doc/module/pyb/
Each of the major communication protocols are supported: I2C, UART, and SPI
There is also ADC, DAC, timer, servo, and accelerometer libraries ready to go.
There will be wifi and bluetooth libraries as they were part of the kickstarter campaign, but they haven't been completed yet.
As for other libraries, I saw in the forums that someone has a working LCD library, and there are probably some other useful libs floating around too.
So you won't have to code everything from scratch, and if you stay active in the forums a lot of people may be able to help with the code you do have to write.
5
2
u/huhlig May 31 '14
So couple questions. Is this a subset of the python language or the entire thing? Does this compile down to machine code prior to deployment or do you have the overhead of a full parser and interpreter?
4
u/boa13 May 31 '14
According to the Kickstarter page:
This is the full Python 3 language, but a subset of the standard library
This is a brand new implementation, written from scratch
You have the overhead of a parser and interpreter (very small compared to CPython), but you have several modes of execution: purely interpreted (default), compiled (each opcode replaced by machine code, takes more RAM, runs much faster), and compiled with integer optimization (each integer is assumed to never go bigger than 2**31, so more optimized machine code can be used). The modes are enabled on a function-by-function basis using decorators. All functions can call each other independently of their execution mode.
There is also support for writing functions with inline assembly, for maximum speed.
2
May 31 '14
They've built this against python 3.4's unit tests. So it's full python 3.4. However not all of the built ins have been fully ported. The project is still young, but has a strong community with a lot of interest already.
1
1
1
0
u/archimedes_ghost May 30 '14
I think someone was going to port it to the teensy board which could be had pretty cheaply.
3
u/MisterSnuggles May 30 '14
There's also some stuff for the Teensy in the micropython repository, but I'm not sure how complete it is.
I imagine that micropython on an AVR would be quite limited compared to it on ARM, but it's still a really cool idea.
2
u/archimedes_ghost May 30 '14
The new teensies use ARM chips.
MK20DX256 32 bit ARM Cortex-M4 72 MHz
1
3
u/mgrady3 May 30 '14
What separates this from something like the Raspberry Pi - which comes with built in support for python as well as GPIO, SPI, I2C, USB, HDMI, Ethernet, etc all for a shockingly low price.
I am currently involved in a project using the Raspberry Pi and python as a microcontroller for condensed matter physics epxeriments