Is it possible to execute a micropython code on Rasperry Pi ?
Is it possible to execute a micropython code on Rasperry Pi ?
Hi here,
I would like to know if it's possible to execute a micropython code with I2C / Spi access on raspebbry Pi, maybe with Unix port?
Is it possible ?
Or should I need to adapt my code to work with normal python (3.7) ?
Best Regards
I would like to know if it's possible to execute a micropython code with I2C / Spi access on raspebbry Pi, maybe with Unix port?
Is it possible ?
Or should I need to adapt my code to work with normal python (3.7) ?
Best Regards
Re: Is it possible to execute a micropython code on Rasperry Pi ?
I looked into this post before post, but i don't know how to use spi and i2c with this script.
I need to mix some python code with micropython so maybe i should rewrite all in normal python code ?
I need to mix some python code with micropython so maybe i should rewrite all in normal python code ?
Re: Is it possible to execute a micropython code on Rasperry Pi ?
That script provides a way to use /dev/i2c from MicroPython. It's called SMBus but that's (mostly) just another name for I2C.
But really, on a Raspberry Pi, you might just be better off using regular Python.
Re: Is it possible to execute a micropython code on Rasperry Pi ?
The i2c.py from the link should just work as-is with MicroPython.
There doesn's eem to be a readily available SPI implementation.
But yes if you just use CPython everything works out of the box..
There doesn's eem to be a readily available SPI implementation.
But yes if you just use CPython everything works out of the box..
- rcolistete
- Posts: 352
- Joined: Thu Dec 31, 2015 3:12 pm
- Location: Brazil
- Contact:
Re: Is it possible to execute a micropython code on Rasperry Pi ?
CircuitPython runs on Raspberry Pi, via Blinka :
https://learn.adafruit.com/circuitpytho ... spberry-pi
https://learn.adafruit.com/circuitpytho ... spberry-pi
My "MicroPython Samples". My "MicroPython Firmwares" with many options (double precision, ulab, etc).
Re: Is it possible to execute a micropython code on Rasperry Pi ?
Seeing recent queries on the Raspberry Pi bulletin board, I'm not convinced this is a great idea. All of Adafruit's device drivers are being moved over to Blinka, so you basically have to install Blinka (and all of its many, many dependencies) in order to access one sensor from Python. Adafruit have moved old, working code out of their main repos so many tutorials just don't work any more.
I'm also seeing people getting confused why CP code for Adafruit devices like the Circuit Playground Express doesn't run on a Raspberry Pi. They're in a "move fast and break stuff" phase.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Is it possible to execute a micropython code on Rasperry Pi ?
CPython 3.8, CircuitPython and MicroPython all run on the Pi. Where they differ is in their hardware support and their support for asynchronous programming.
The killer (for me) is asyncio support which is excellent in CPython and MicroPython but non-existent in CircuitPython. It is difficult to write non-trivial firmware applications using synchronous code.
There is a baremetal MicroPython port which could be a real game changer except that I believe its hardware support is minimal.
Much as I love MicroPython on other platforms, on the Pi I would use CPython with the Pi official libraries.
- MicroPython has minimal hardware support. It's fine for socket/internet programming but not for I/O.
- CircuitPython has fairly new hardware support.
- CPython has official Pi libraries offering hardware support which have had years of development.
The killer (for me) is asyncio support which is excellent in CPython and MicroPython but non-existent in CircuitPython. It is difficult to write non-trivial firmware applications using synchronous code.
There is a baremetal MicroPython port which could be a real game changer except that I believe its hardware support is minimal.
Much as I love MicroPython on other platforms, on the Pi I would use CPython with the Pi official libraries.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: Is it possible to execute a micropython code on Rasperry Pi ?
*CircuitPython libraries* run on Raspberry Pi in CPython. This is not the unix port.scruss wrote: ↑Thu Nov 12, 2020 2:49 amSeeing recent queries on the Raspberry Pi bulletin board, I'm not convinced this is a great idea. All of Adafruit's device drivers are being moved over to Blinka, so you basically have to install Blinka (and all of its many, many dependencies) in order to access one sensor from Python. Adafruit have moved old, working code out of their main repos so many tutorials just don't work any more.
I'm also seeing people getting confused why CP code for Adafruit devices like the Circuit Playground Express doesn't run on a Raspberry Pi. They're in a "move fast and break stuff" phase.
Thanks for the Raspberry Pi board mention. I'll add it to my weekly rounds. (I work on CircuitPython for Adafruit and try and check other forums once a week.) Our overall goal is to have a single hardware API (CircuitPython's) across all platforms. That is why we're moving away from the older libraries.
Take a look at the latest CP. We haven't advertised it, but `async` and `await` is now turned on by default. It was enabled in: https://github.com/adafruit/circuitpython/pull/3540 Note that the API is changed from MicroPython to be closer to CPython and that it's based on MicroPython <1.13.pythoncoder wrote: ↑Thu Nov 12, 2020 11:01 amThe killer (for me) is asyncio support which is excellent in CPython and MicroPython but non-existent in CircuitPython. It is difficult to write non-trivial firmware applications using synchronous code.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Is it possible to execute a micropython code on Rasperry Pi ?
That's a big improvement.tannewt wrote: ↑Tue Nov 17, 2020 12:58 am...
Take a look at the latest CP. We haven't advertised it, but `async` and `await` is now turned on by default. It was enabled in: https://github.com/adafruit/circuitpython/pull/3540 Note that the API is changed from MicroPython to be closer to CPython and that it's based on MicroPython <1.13.
It seems a pity that it's based on V < 1.13 as V1.13 has an entirely new version of uasyncio (V3) which has much better CPython compatibility. Had you based on that, you might not have seen a need to write your own scheduler. One of the quoted reasons for doing this is to remove the need to use the event loop. Under V3 it is possible (and recommended) to write code without any reference to the event loop. Your example
Code: Select all
tasko.schedule(hz=10, coroutine_function=read_sensor)
tasko.schedule(hz=10, coroutine_function=animate_beach_ball)
tasko.schedule(hz=5, corouting_function=read_from_3d_printer) # Note the typo here!!!
tasko.schedule(hz=100, coroutine_function=rotary.loop)
# And let tasko do while True
tasko.run()
Code: Select all
import uasyncio as asyncio
# code omitted
async def main():
asyncio.create_task(read_sensor())
asyncio.create_task(animate_beach_ball())
asyncio.create_task(read_from_3d_printer())
await(rotary.loop()) # Run forever
asyncio.run(main())
I should add that, in my opinion, uasyncio V3 is exceptionally well written and minimal. I strongly recommend you take a look at it, if you haven't already.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.