tinkertechtrove / pico-pi-playing

Playing with the awesome Raspberry Pi Pico
MIT License
71 stars 22 forks source link

Pico to Wemos D1 Error #11

Open llewmihs opened 2 years ago

llewmihs commented 2 years ago

I'm looking to replicate your setup but with a Wemos D1 Mini instead of the Uno. Everything looks to be working from the D1 seide, but the Pico side throws an error when the programme is run

Traceback (most recent call last):
  File "<stdin>", line 18, in <module>
OSError: [Errno 5] EIO

The code running on the Pico is as follows - some adaptations from your original to help with debugging

from machine import Pin, I2C
from time import sleep

MSG_SIZE = 15

i2c = I2C(0, scl=Pin(17), sda=Pin(16), freq=100000) 
devices = i2c.scan()

if len(devices) == 0:
    print("No I2C device found")
elif len(devices) > 1:
    print("Multiple I2C devices found -")
    for d in devices:
        print("  0x{:02X}".format(d))
else:
    print("I2C device found at 0x{:02X}".format(devices[0]))
    device = devices[0]
    i2c.writeto(0x09, 'Hi from Pi')
    sleep(0.1)
    a = i2c.readfrom(0x09, MSG_SIZE)
    print(a)

print("done")

The Pico is able to find the Wemos as an I2C peripheral

I2C device found at 0x09

but is unable to write to it. Any help gratefully appreciated, your youtube video on the topic was incredibly helpful.

llewmihs commented 2 years ago

Well, I think I've solved my own problem - this is already covered here - https://github.com/esp8266/Arduino/issues/5762