# 2x I2C Connection - Invalid Pin Error

**URL:** <https://forum.core-electronics.com.au/t/2x-i2c-connection-invalid-pin-error/19747>\
**Category:** Uncategorized\
**Created:** [22 April 2024 13:17 UTC](https://forum.core-electronics.com.au/t/2x-i2c-connection-invalid-pin-error/19747 "2024-04-22T13:17:56Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mitchell258024](https://avatars.discourse-cdn.com/v4/letter/m/bb73d2/32.png) [@Mitchell258024](https://forum.core-electronics.com.au/u/Mitchell258024)\
**Post date:** [22 April 2024 13:17 UTC](https://forum.core-electronics.com.au/t/2x-i2c-connection-invalid-pin-error/19747/1 "2024-04-22T13:17:56Z")

</div>

I am connecting 2x (in the end 4) BNO85 IMUs to Raspberry Pi Pico W using I2C. I can connect one BNO85 with GP8 & GP9, though when I go to connect the other BNO85 I receive a “ValueError: invalid pins”. I have tried pins GP20 with GP21 and pins GP26 with GP27 but the same error occurs. Any helps greatly appreciated. If any more information is needed, let me know.

---

<div class="post-metadata">

**Author:** ![James46717](https://avatars.discourse-cdn.com/v4/letter/j/e5b9ba/32.png) [@James46717](https://forum.core-electronics.com.au/u/James46717)\
**Post date:** [22 April 2024 22:53 UTC](https://forum.core-electronics.com.au/t/2x-i2c-connection-invalid-pin-error/19747/2 "2024-04-22T22:53:47Z")

</div>

Can you link the BN0085 device you are using. And maybe the Python code you are using.  
I2C works with an addressing scheme, each device will need its own address.

The Adafruit guide for their _9-DOF Orientation IMU Fusion Breakout - BNO085_ says only two addresses can be used. But this might not be the device you are using.

The Core Electronics web page says the device has an SPI interface. This may be the reason for invalid pins, the SPI pins are different than I2C. Micropython knows which pins should be used, so flags an error if the pin designations are incorrect.

The following Python program will show the I2C devices on the bus.

```auto
import machine

i2c=machine.I2C(0, sda=machine.Pin(8), scl=machine.Pin(9), freq=400000)
 
print('I2C address:')
print('Dec Hex')

devices = i2c.scan()
for i in devices:

    print(i,hex(i))

```

 ![image](https://canada1.discourse-cdn.com/flex028/uploads/core_electronics/original/2X/e/e0982889074bdda232e0d4840d8195bd0974d7fe.png)

---

<div class="post-metadata">

**Author:** ![Mitchell258024](https://avatars.discourse-cdn.com/v4/letter/m/bb73d2/32.png) [@Mitchell258024](https://forum.core-electronics.com.au/u/Mitchell258024)\
**Post date:** [23 April 2024 01:43 UTC](https://forum.core-electronics.com.au/t/2x-i2c-connection-invalid-pin-error/19747/3 "2024-04-23T01:43:16Z")

</div>

Thanks James.

I am using - 9-DOF Orientation IMU Fusion Breakout - BNO085

See attached, note not correct error message.

 ![Screen Shot 2024-04-23 at 9.41.31 am](https://canada1.discourse-cdn.com/flex028/uploads/core_electronics/original/2X/c/cd1d359e66571fb77abe9a5e4880acdab6813342.jpeg)  
 ![Screen Shot 2024-04-23 at 9.41.39 am](https://canada1.discourse-cdn.com/flex028/uploads/core_electronics/original/2X/7/7120b7bbfbddbd3cfc6c88816e20a0066204552f.jpeg)  
 ![Screen Shot 2024-04-23 at 9.41.42 am](https://canada1.discourse-cdn.com/flex028/uploads/core_electronics/original/2X/f/f68a27c38027bf20407e5cbf180c9a714527fbbe.jpeg)

---

<div class="post-metadata">

**Author:** ![Mitchell258024](https://avatars.discourse-cdn.com/v4/letter/m/bb73d2/32.png) [@Mitchell258024](https://forum.core-electronics.com.au/u/Mitchell258024)\
**Post date:** [23 April 2024 01:44 UTC](https://forum.core-electronics.com.au/t/2x-i2c-connection-invalid-pin-error/19747/4 "2024-04-23T01:44:23Z")

</div>

Start of 3rd photo has I2C definitions

---

<div class="post-metadata">

**Author:** ![Michael](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/michael/32/3545_2.png) [@Michael](https://forum.core-electronics.com.au/u/Michael)\
**Post date:** [23 April 2024 04:14 UTC](https://forum.core-electronics.com.au/t/2x-i2c-connection-invalid-pin-error/19747/5 "2024-04-23T04:14:24Z")

</div>

Hi @Mitchell258024  
currently you have:  
`i2c2 = busio.I2C(board.GP20, board.GP21, frequency=800_000)`

I think this is wrong for two reasons:

- it looks like CircuitPython [busio.I2C](https://docs.circuitpython.org/en/latest/shared-bindings/busio/#busio.I2C) is expecting the pins to be ordered SCL, SDA. Similar to your setup of i2c1 where the first argument is the SCL pin.
- these pins are for the I2C0 bus, which has already been initialised on GP9, GP8. I2C0 cannot be reused.

so you might want to modify the initialisation of `i2c2` to be as follows  
`i2c2 = busio.I2C(board.GP27, board.GP26, frequency=800_000)`

I use GP27, GP26 in the order SCL, SDA and have selected pins from the I2C1 bus

* * *

To avoid ambiguity, it might be best to use bus names consistent with the pinout diagram. Here’s an alternative initialisation that might reduce confusion. Of course, you’ll have to update the rest of your code.

```auto
i2c0 = busio.I2C(board.GP9, board.GP8, frequency=800_000)
i2c1 = busio.I2C(board.GP27, board.GP26, frequency=800_000)

```

---

<div class="post-metadata">

**Author:** ![James46717](https://avatars.discourse-cdn.com/v4/letter/j/e5b9ba/32.png) [@James46717](https://forum.core-electronics.com.au/u/James46717)\
**Post date:** [23 April 2024 04:31 UTC](https://forum.core-electronics.com.au/t/2x-i2c-connection-invalid-pin-error/19747/6 "2024-04-23T04:31:59Z")

</div>

I think @Michael has hit on the problem which would explain the invalid pin error.  
CircuitPython should be installed on the Pico. I have next to no experience with CircuitPython.

The way the Pico pinout is shown by the Raspberry Pi corporation can be confusing. The Pico has two I2C interfaces which can be allocated to particular pins, once allocated the other pins are available for anything else. Probably you already know all this.

Cheers  
Jim

---

<div class="post-metadata">

**Author:** ![Mitchell258024](https://avatars.discourse-cdn.com/v4/letter/m/bb73d2/32.png) [@Mitchell258024](https://forum.core-electronics.com.au/u/Mitchell258024)\
**Post date:** [23 April 2024 13:31 UTC](https://forum.core-electronics.com.au/t/2x-i2c-connection-invalid-pin-error/19747/7 "2024-04-23T13:31:56Z")

</div>

Epic, works well, thank you… Is there a way to use the information from 2 more BNO85’s - Via the pico W? Note these two BNO85’s will also transmit information to another pico W which again will be linked to an additional 2x BNO85’s

---

<div class="post-metadata">

**Author:** ![Aarav270150](https://avatars.discourse-cdn.com/v4/letter/a/e68b1a/32.png) [@Aarav270150](https://forum.core-electronics.com.au/u/Aarav270150)\
**Post date:** [23 April 2024 21:28 UTC](https://forum.core-electronics.com.au/t/2x-i2c-connection-invalid-pin-error/19747/8 "2024-04-23T21:28:06Z")

</div>

@James46717 I’m really sry to interrupt your conversation but sir is there any way i can contact you, maybe via mail? I’m 17 and i want to build something I’m facing some issue which i think you can help me, I’ve tried my best but got no luck, it’s regarding wireless communication between 2 pico Ws (without any other external wifi network, just the 2 picos communicating independently)  
Regards

---

<div class="post-metadata">

**Author:** ![James46717](https://avatars.discourse-cdn.com/v4/letter/j/e5b9ba/32.png) [@James46717](https://forum.core-electronics.com.au/u/James46717)\
**Post date:** [23 April 2024 22:02 UTC](https://forum.core-electronics.com.au/t/2x-i2c-connection-invalid-pin-error/19747/9 "2024-04-23T22:02:46Z")

</div>

@Aarav270150 This would be a starting point.

> [@Pi Pico W to Pico W - Simple Communications](https://forum.core-electronics.com.au/t/pi-pico-w-to-pico-w-simple-communications/16188):
>
> Following success with my latest project. Main aim being to develop a simple way of getting two Pico W’s to communicate, thought I would share the Python code I developed. One Pico W sets itself up as a WiFi Access Point and listens for a connection from the other Pico W. The other Pico W connects to the Access Point, collects data and sends it. The Access Point responds with ‘success’ if data is received ok. The code here is the basic for the communications, whatever is done with the data …

Just post in that thread.

Cheers  
Jim

---

<div class="post-metadata">

**Author:** ![Samuel](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/samuel/32/11763_2.png) [@Samuel](https://forum.core-electronics.com.au/u/Samuel)\
**Post date:** [24 April 2024 02:54 UTC](https://forum.core-electronics.com.au/t/2x-i2c-connection-invalid-pin-error/19747/10 "2024-04-24T02:54:15Z")

</div>

Hi @Aarav270150, welcome to the forums!

James has suggested an awesome forum post that’s definitely worth reading through and adding to if you need.

Alternatively, if you think your issue is different enough feel free to create your own topic on this matter and we will be sure to dive in with a response!

[There is a tutorial on how to make a forum post here](https://core-electronics.com.au/how-to-create-forum-topic).

---

<div class="post-metadata">

**Author:** ![Aarav270150](https://avatars.discourse-cdn.com/v4/letter/a/e68b1a/32.png) [@Aarav270150](https://forum.core-electronics.com.au/u/Aarav270150)\
**Post date:** [24 April 2024 06:06 UTC](https://forum.core-electronics.com.au/t/2x-i2c-connection-invalid-pin-error/19747/11 "2024-04-24T06:06:20Z")

</div>

okk thank you
