Has anyone used Python (probably with smbus) to access I2C on the Duo boards?
If so, do you have any example code you can share?
I’ve seen the C code using /dev/i2cdev-x and ioctl, but I would rather use a cleaner interface, such as smbus, with python.
I’ve done this on Raspberry Pi’s, but the tools on the duo boards are so convoluted.
Any help is appreciated.
1 Like
As for the bigger core, have you ever tried MicroPython / CircuitPython? It should do.
Thanks for the reply.
That’s interesting… is there a port of CP for the MilkV?
I use CP on all my other boards (except Raspi)… RP2040, ESP32S3, etc.
Is there a guide/documentation somewhere about porting CP or even MP onto the MilkV boards?
1 Like
Just try looking at this, it is probable that you will like it (but it’s not ideal).
1 Like
Hardware requirements
BMP280 with i2c interface.
Software requirements
python-periphery
Hardware requirements
BMP180 with i2c interface.
Hardware requirements
pcf8574x.
2 Likes
Thanks for the info.
Where do I get the periphery lib?
And how do I install on the duo?
Do I need to add it in build-root or can I just put into the python library?
I tried to import pinpong, but it failed.
Do I have use build-root to bake it into an image?
Any help on the config would be appreciated.
Which Duo board are you using? What firmware image are you using?
Duo256m and Duo running release SD1.1.1.
But I have the build-root SDK, so I can build what ever is necessary.
Milk-V Duo (64M), SD image. I built it myself against the official buildroot&SDK (v1.1.1), the only difference is no ION reserved.
Here’s pinpong, with a textbook example you could find by the link I sent earlier:
[root@milkv-duo]~# python3
Python 3.9.5 (default, Feb 13 2024, 18:09:16)
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import time
from pinpong.board import Board,Pin
Board("MILKV-DUO").begin()
led = Pin(Pin.D25, Pin.OUT)
while True:
led.value(1)
print("1")
time.sleep(1)
led.value(0)
print("0")
time.sleep(1)>>>
>>> >>> milkv-duo
__________________________________________
| ____ _ ____ |
| / __ \(_)___ / __ \____ ____ ____ _ |
| / /_/ / / __ \/ /_/ / __ \/ __ \/ __ `/ |
| / ____/ / / / / ____/ /_/ / / / / /_/ / |
|/_/ /_/_/ /_/_/ \____/_/ /_/\__, / |
| v0.5.2 Designed by DFRobot /____/ |
|__________________________________________|
<pinpong.board.Board object at 0x3fb9233ee0>
>>> >>> >>> >>> ... ... ... ... 1
1
1
1
1
1
1
1
1
1
1
1
1
1
^Cexit_handler