# Badger 2040; i2c pins

**URL:** <https://forums.pimoroni.com/t/badger-2040-i2c-pins/19327>\
**Category:** Support\
**Created:** [April 17, 2022, 10:37am UTC](https://forums.pimoroni.com/t/badger-2040-i2c-pins/19327 "2022-04-17T10:37:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jhawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/b5e925/32.png) [@jhawkesworth](https://forums.pimoroni.com/u/jhawkesworth)\
**Post date:** [April 17, 2022, 10:37am UTC](https://forums.pimoroni.com/t/badger-2040-i2c-pins/19327/1 "2022-04-17T10:37:59Z")

</div>

Hello,

I’m hoping to use an ICP10125 breakout with my Badger 2040, but I’m not sure what pins I should pass when initializing the PimoroniI2C library

In the example here:

> <https://github.com/pimoroni/pimoroni-pico/tree/main/micropython/modules/breakout_icp10125#getting-started>
>
> //github.com/pimoroni/pimoroni-pico/tree/main/micropython/modules/breakout\_icp10125

It says

> Breakout Garden uses pins 4 & 5 and Pico Explorer uses pins 20 & 21.

… but no mention of the Badger.

I should say my plan is to connect the ICP10125 via the QW/ST connector.

Looking at the badger schematic and comparing with the explorer hat schematic I think what is wanted is the GPIO pins for the 2040 controller with SDA as first argument and SCL as second argument. If that’s the case then I think as per the example GPIO 4 and GPIO 5 are the right pin numbers.

```auto
import pimoroni_i2c
i2c = pimoroni_i2c.PimoroniI2C(_sda_gpio_pin_here_maybe, scl_gpio_pin_here_maybe)

```

Can anyone confirm that is right? Or better still, teach me how to find out for myself?

Many thanks,

Jon

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [April 17, 2022, 12:28pm UTC](https://forums.pimoroni.com/t/badger-2040-i2c-pins/19327/2 "2022-04-17T12:28:05Z")

</div>

GPIO 4 is SDA and GPIO 5 is SCL  
The following code should confirm it. Run it with the ICP10125 connected.

```auto
import machine
sda=machine.Pin(4) # Explorer 20 Breakout 4
scl=machine.Pin(5) # Explorer 21 Breakout 5
i2c=machine.I2C(0,sda=sda, scl=scl, freq=400000)
 
print('Scan i2c bus...')
devices = i2c.scan()
 
if len(devices) == 0:
  print("No i2c device !")
else:
  print('i2c devices found:',len(devices))
 
  for device in devices:  
    print("Decimal address: ",device," | Hex address: ",hex(device))

```

The above works with the Pimoroni uf2 file. It did for me anyway on a PICO and Pico Lipo, and Tiny 2040.

The following should be what you need to use with the Pimoroni i2c library.

```auto
from pimoroni_i2c import PimoroniI2C

PINS_BREAKOUT_GARDEN = {"sda": 4, "scl": 5}
PINS_PICO_EXPLORER = {"sda": 20, "scl": 21}
i2c = PimoroniI2C(**PINS_BREAKOUT_GARDEN)

```

---

<div class="post-metadata">

**Author:** ![jhawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/b5e925/32.png) [@jhawkesworth](https://forums.pimoroni.com/u/jhawkesworth)\
**Post date:** [April 17, 2022, 12:56pm UTC](https://forums.pimoroni.com/t/badger-2040-i2c-pins/19327/3 "2022-04-17T12:56:06Z")

</div>

Thank you.  
Will confirm once the ICP10125 has arrived.  
That’s a neat trick to use the PINS\_BREAKOUT\_GARDEN constant too.  
Jon

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [April 17, 2022, 5:51pm UTC](https://forums.pimoroni.com/t/badger-2040-i2c-pins/19327/4 "2022-04-17T17:51:33Z")

</div>

I Have a Pico Breakout Garden, and had a Pico Explorer. It was convenient to put it that way in my code. Works with my Pico Omnibus too.

Anytime I breadboard or Proto Board I purposely use GPIO 4 and 5 for i2c. It lets me use the Pimoroni i2c library. I’m almost always using their custom uf2, with their breakouts. Why complicate things.

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [April 17, 2022, 6:52pm UTC](https://forums.pimoroni.com/t/badger-2040-i2c-pins/19327/5 "2022-04-17T18:52:55Z")

</div>

The following can be used,  
`i2c = PimoroniI2C(sda=(4), scl=(5))`  
in place of  
`i2c = PimoroniI2C(**PINS_BREAKOUT_GARDEN)`

There are other options to change the baud rate and specify the i2c0 or i2c1. You have to look at the pimoroni\_i2c.cpp file, and do some guess work. Not something I have had to do just yet.

---

<div class="post-metadata">

**Author:** ![jhawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/b5e925/32.png) [@jhawkesworth](https://forums.pimoroni.com/u/jhawkesworth)\
**Post date:** [April 22, 2022, 9:21am UTC](https://forums.pimoroni.com/t/badger-2040-i2c-pins/19327/6 "2022-04-22T09:21:48Z")

</div>

Thanks for this. Good to know i2c1 is an option too, although I doubt I’ll add more sensors to this particular project (want to keep it still looking like a badge).

To confirm, yes your scan code shows the device as follows.

Scan i2c bus…  
i2c devices found: 1  
Decimal address: 99 | Hex address: 0x63

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [April 22, 2022, 10:02am UTC](https://forums.pimoroni.com/t/badger-2040-i2c-pins/19327/7 "2022-04-22T10:02:19Z")

</div>

You can have multiple devices on i2c, as long as no two devices have the same address all is good.
