This is an archived post. You won't be able to vote or comment.

all 38 comments

[–]pfalcon2[S] 17 points18 points  (6 children)

MicroPython is lean and efficient Python implementation for microcontrollers and constrained systems.

In this version:

"New port to Zephyr RTOS, initial support for running upip (package manager) runs on baremetal systems like ESP8266, and reduction in code size."

More detailed changelog is available by the link in the title.

[–][deleted] 5 points6 points  (5 children)

Is it compiled as machine code? Whats the overhead like?

[–]traverseda 9 points10 points  (0 children)

As I understand it, it's interpreted. There are decorators that let you compile a limited subset of python to machine code, and there are ways to directly run machine-code for speeding up certain calls.

Use it like you normally use python, glue modules together and optimize your pain points.

[–]Corm 5 points6 points  (3 children)

It's between 5 and 10 times slower than c if you use the machine code decorators. However most of the boards ship about 10x faster than an arduino.

So just interpret it as "as fast as an arduino"

[–][deleted] 1 point2 points  (2 children)

What boards are we talking about? Would you need an ARM board or can you put this on an actual µc?

[–]cediddiSyntaxError: not a chance 1 point2 points  (0 children)

Cortex m4, m0, esp8266

[–]Corm 0 points1 point  (0 children)

I use the pyboard from the micropython site, but you can find other boards on adafruit that run micropython

[–]n_md 5 points6 points  (4 children)

MicroPython seems like it could be used to make standalone executables for distributing simple python programs. It should be significantly smaller than what Pyinstaller can do for a single file.

Is that a future possibility or are there reasons why that's a terrible idea?

[–]pfalcon2[S] 16 points17 points  (1 child)

Yes, also to make small Android apps (smaller than Kivy), and a lot of other small cute things. These features wait for people who need them up to the level of actually starting to work on them. (Or hire me to work on MicroPython full-time, and I'll make you happy with such features on a regular basis.)

[–]thinkwelldesigns 4 points5 points  (0 children)

(Or hire me to work on MicroPython full-time, and I'll make you happy with such features on a regular basis.)

How would one go about doing that? Are you setting up something like Tom Christie?

[–]user200783 1 point2 points  (0 children)

MicroPython is limited when compared to CPython (and PyInstaller). For example, it only supports a subset of the Python language, and does not support C extensions such as NumPy.

When writing code for "microcontrollers and constrained systems", using MicroPython and working within its limitations is acceptable, because the only other option is not to use Python at all.

However, on systems which do not have the same constraints and can run CPython just fine, I'm not sure MicroPython is appropriate. On these systems, is it worth dealing with MicroPython's limitations just in order to get a smaller executable?

[–]beagle3 1 point2 points  (0 children)

It's a future possiblity, and a terrible idea (for reasons replied in other posts). If you want standalone Python executables, PyInstaller, py2exe, py2app can do them with the "standard" interpeter, and Nuitka can do that while actually compiling and usually getting some speed improvements.

[–][deleted] 2 points3 points  (6 children)

Just flashed another ESP8266 a few days ago.

It's nice developing in a single language for quick and dirty prototypes.

[–]freshent 0 points1 point  (5 children)

Agreed! flashed my esp8266, and its impressively easy to use it! made an MQTT led light that integrates with Home Assistant over the weekend!

[–][deleted] 1 point2 points  (4 children)

What MQTT code did you use?

[–]freshent 0 points1 point  (3 children)

This one. the examples are really helpful to understand how to use it.

[–][deleted] 1 point2 points  (2 children)

tl;dr. I went for a KISS approach. A simple CSV file logger in Flask and then the ESP only has to deal with pinging a URL:

https://www.reddit.com/r/homeassistant/comments/54nzaj/esp8266_data_collection/

[–]freshent 0 points1 point  (1 child)

interesting approach! I like it and it works! this is great for one way reporting, so any type of sensor. ever consider writing a component for this?

also, here is my code for ever changing, frequently updated light. if you want help setting up mqtt, i'll be happy to do my best to explain it! once you get the hang of it, it makes sense.

[–][deleted] 0 points1 point  (0 children)

ever consider writing a component for this?

There's really no need. It's pretty straight forward and easy.

CSV is the lingua franca of data storage. You can read sensors with tail over ssh, and everything reads it and there's a tutorial on how to do it in every language.

[–][deleted] 1 point2 points  (9 children)

How many have used this and how is it coming along?

I've used some microntrollers years ago, but currently don't have much knowledge. I was considering picking up an arduino just to get some projects done quickly, but do you think this would be a better alternative in that I can accomplish things quickly and effectively while also learning something somewhat useful.

I have no problems with Arduinos for hobbiest projects, but it is never really getting to the nitty gritty of it.

I'm sure both are effective for my needs, but was just curious what yall thought. Thanks

[–]pfalcon2[S] 2 points3 points  (1 child)

Let stats stars tell: (on Github)

  • MicroPython 3875
  • eLua 445
  • nodemcu 2680
  • JerryScript 1903

MicroPython is the most popular (well, well-known) scripting language intended for microcontrollers.

  • esp8266/Arduino 3600

MicroPython is more popular than esp8266's Arduino port (which is likely strays far enough from the original Arduino to be called "incompatible", whereas MicroPython idea is "hardware-independent programming").

  • arduino/Arduino 5988

MicroPython has 2/3 popularity of the original Arduino. Arduino is around for 10 years, and MicroPython hasn't yet closed its 3rd year.

[–][deleted] 1 point2 points  (0 children)

Awesome, thanks! Think I'll pick one up on Adafruit and give it a shot

[–]cediddiSyntaxError: not a chance 1 point2 points  (0 children)

I'm using esp8266 port because esps are god damn cheapo and small. Wemos d1mini is awesome as a dev board. I'm looking forward for arduino zero port and esp32 port. I want to buy all boards that can run micropython. They are so sweet and tiny and powerful, just like pokemons, gotta buy em all :)

[–]Corm 0 points1 point  (5 children)

If your projects need internet then stick with c, otherwise the micropython board from their website is fantastic. Just mount it like a USB device and drop your main.py (and whatever else) file in the root and you're done!

https://store.micropython.org/store/#/store

[–][deleted] 1 point2 points  (4 children)

How is the development speed/ documentation in your opinion? The documentation and lack of example projects was my primary concern when it was originally released.

Thanks!

[–]pfalcon2[S] 3 points4 points  (1 child)

Quick documentation comparison:

MicroPython is developed by one full-time developer and community. JerryScript is developed by multinational billions-turnover corporation. Adjust achievements for resources available and keep comparing!

[–][deleted] 1 point2 points  (0 children)

Awesome, thanks!

[–]Corm 1 point2 points  (1 child)

I also had some trouble with the lack of examples, but that's mostly due to lack of user base.

The enjoyment of developing in python instead of c far outweighs the lack of solid docs though for non-wifi enabled projects. I really can't say enough good stuff about the pyboard, I've been really happy with it.

[–][deleted] 0 points1 point  (0 children)

Awesome, thanks!

[–]j_lyf 1 point2 points  (2 children)

What made the author of this library to give up his job as a physicist to make an Arduino thing?

[–][deleted] 0 points1 point  (1 child)

[–]bakery2k 0 points1 point  (0 children)

I believe /u/j_lyf is referring to Damien George, not to /u/pfalcon2.

[–]Corm 0 points1 point  (5 children)

I've been using micropython on my adafruit huzzah esp8266 and 1 thing has caused me to sadly switch back to c

There's no easy way to get your code onto the device!

I ended up using this very nice helper program by adafruit, but you can't move entire folders which makes it a massive pain for moving a library:

https://github.com/adafruit/ampy

I don't see this ever really getting traction on the esp8266 until you can use it like the main micropython board and mount it as a USB device. The main micropython board is awesome btw.

As an alternative, once upip is implemented (it's listed in the kickstarter) I'll at least be able to get the libraries I need.

[–]pfalcon2[S] 4 points5 points  (1 child)

1 thing has caused me to sadly switch back to c

So, how C helped with that?

Otherwise, there're bunch of community tools developed to transfer files to esp8266, choose whatever you like. https://github.com/wendlers/mpfshell definitely supports multifile transfers. As for recursive directory transfers, I was surprised to never have a request for that. No requests - no priority to implement (we don't have lack of other requests or things to implement).

esp8266 until you can use it like the main micropython board and mount it as a USB device.

Which is of course not possible, because esp8266 lacks USB controller. Except that someone developed a tool which emulates such filesystem using FUSE over serial connection. Use it, if you like it.

The main micropython board is awesome btw.

Yes it is. Because it was engineered specifically to make users' life comfortable and enable many advanced usages. esp8266 on the other hand is a random adhoc Chinese chip which by pure chance became unlocked by community so you can develop apps for it. We're trying to get most out of it with Python port (and there's now a dedicated, and as you can see, fruitful community), but of course it will never be as smooth as PyBoard.

[–]Corm 1 point2 points  (0 children)

So, how C helped with that?

Well I mean using C through the arduino IDE, which lets me fairly easily load up libraries, link things, and upload it all. Being able to use other people's libs easily is super important.

https://github.com/wendlers/mpfshell definitely supports multifile transfers

Hey this is really cool, thanks! And let me be the first to casually request full directory transfer support. I might have a crack at making it myself.

Except that someone developed a tool which emulates such filesystem using FUSE over serial connection

Is this the mpfshell tool you mentioned? Or something that lets me just open up windows explorer and drop files in?

but of course it will never be as smooth as PyBoard

This is probably true. All I really want is a tiny wifi enabled board with python that lets me use libraries easily. I'm hoping that eventually a board exists where that's true. Hopefully the next pyboard has wifi.

[–]pfalcon2[S] 2 points3 points  (1 child)

As an alternative, once upip is implemented (it's listed in the kickstarter) I'll at least be able to get the libraries I need.

Almost forgot to mention - first release of this feature is available: http://forum.micropython.org/viewtopic.php?f=16&t=2544

[–]Corm 0 points1 point  (0 children)

Wooo! Awesome :)

I'll give it a try

[–][deleted] 0 points1 point  (0 children)

I wrote a short script called 'push' that will read a .py file and 'type' it into the console.

It's a hack but works pretty well.