XIAO RP2350 - Wire1 not working. #2808

Closed
opened 2025-02-18 19:01:37 +03:00 by metanav · 3 comments
metanav commented 2025-02-18 19:01:37 +03:00 (Migrated from github.com)

I am using a XIAO RP2350 to read a Grove - CO2 & Temperature & Humidity Sensor(SCD41) over I2C. This sensor works perfectly using the Wire but when I use the Wire1 it does not work. I have done the following changes in the file rp2040/hardware/rp2040/4.4.0/variants/seeed_xiao_rp2350.

// #define PIN_WIRE1_SDA  (16u)
// #define PIN_WIRE1_SCL  (17u)
#define PIN_WIRE1_SDA  (0u)
#define PIN_WIRE1_SCL  (1u)

The I2C scan code recognizes the sensor address using either Wire or Wire1. I am using the GPIO6(SDA) and GPIO7(SCK) for Wire and GPIO0(SDA) and GPIO1(SCK) for Wire1. Also, I tried another I2C sensor but the same behavior.

I am using this example sketch with following changes.

// Wire.begin();
// sensor.begin(Wire, SCD41_I2C_ADDR_62);
Wire1.begin();
sensor.begin(Wire1, SCD41_I2C_ADDR_62);
I am using a [XIAO RP2350](https://jp.seeedstudio.com/Seeed-XIAO-RP2350-p-5944.html) to read a[ Grove - CO2 & Temperature & Humidity Sensor(SCD41)](https://jp.seeedstudio.com/Grove-CO2-Temperature-Humidity-Sensor-SCD41-p-5025.html) over I2C. This sensor works perfectly using the **Wire** but when I use the **Wire1** it does not work. I have done the following changes in the file `rp2040/hardware/rp2040/4.4.0/variants/seeed_xiao_rp2350`. ``` // #define PIN_WIRE1_SDA (16u) // #define PIN_WIRE1_SCL (17u) #define PIN_WIRE1_SDA (0u) #define PIN_WIRE1_SCL (1u) ``` The I2C scan code recognizes the sensor address using either **Wire** or **Wire1**. I am using the **GPIO6**(SDA) and **GPIO7**(SCK) for Wire and **GPIO0**(SDA) and **GPIO1(SCK)** for Wire1. Also, I tried another I2C sensor but the same behavior. I am using this example [sketch](https://github.com/Sensirion/arduino-i2c-scd4x/blob/master/examples/exampleUsage/exampleUsage.ino) with following changes. ``` // Wire.begin(); // sensor.begin(Wire, SCD41_I2C_ADDR_62); Wire1.begin(); sensor.begin(Wire1, SCD41_I2C_ADDR_62); ```
earlephilhower commented 2025-02-18 20:05:45 +03:00 (Migrated from github.com)

You don't need to change headers to redefine pins, there are calls your app can make to do that. See https://arduino-pico.readthedocs.io/en/latest/pins.html

Those are also illegal pins for i2c1 (Wire1), the hardware can only use certain pinouts See https://www.raspberrypi.com/documentation/microcontrollers/pico-series.html for the allowed i2c1 pins

You don't need to change headers to redefine pins, there are calls your app can make to do that. See https://arduino-pico.readthedocs.io/en/latest/pins.html Those are also illegal pins for i2c1 (Wire1), the hardware can only use certain pinouts See https://www.raspberrypi.com/documentation/microcontrollers/pico-series.html for the allowed i2c1 pins
earlephilhower commented 2025-02-18 21:14:38 +03:00 (Migrated from github.com)

Actually, looking into the contributed Xaoi RP2350 pins_arduino.h, it's really messed up. They've redefined the Wire device (but not Wire1, so both Wire and Wire1 will try and use the same HW) and confused the wire0/1 pins.

The website shows
Image
Image

So no need to swap I2C devices at all. I will update #2811 to move Wire to the sda0/scl0 16/17, remove the swapping of i2c devices, and set Wire1 to sda1/scl1 on the 6/7 pinout.

Actually, looking into the contributed Xaoi RP2350 pins_arduino.h, it's really messed up. They've redefined the Wire device (but not Wire1, so both `Wire` and `Wire1` will try and use the same HW) and confused the wire0/1 pins. The website shows ![Image](https://github.com/user-attachments/assets/cffc77ab-e3da-441d-ad3f-0598da3994c8) ![Image](https://github.com/user-attachments/assets/60de2c94-6e94-41cf-a1f8-906a7c0c04e4) So no need to swap I2C devices at all. I will update #2811 to move `Wire` to the sda0/scl0 16/17, remove the swapping of i2c devices, and set `Wire1` to sda1/scl1 on the 6/7 pinout.
metanav commented 2025-02-19 16:15:03 +03:00 (Migrated from github.com)

Thank you, @earlephilhower! Both Wire and Wire1 are working now!

Thank you, @earlephilhower! Both Wire and Wire1 are working now!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Max/earlephilhower_arduino-pico#2808