PiJuice and 0.96" I2c oled - Separate bus addresses coding

Hello friends!
I recently purchased a PiJuice to use with my security camera server, and had a 0.96" oled displaying the IP address etc which ran fine.
Since adding the PiJuice, the address of the display no longer works. If i manually adjust the bus with dtoverlay i can access 1 or the other but not both on the same bus (with the display on pins not used by the PiJuice).

I have also changed the overlay to create a second bus (i2c2), and this way i can find the display address on the separate bus without problems.
The issue now is adjusting the coding to address the display on i2c2, which is where i am stuck! If anyone has any suggestions, that’d be awesome!

2 Likes

Hi Sven,

Sounds like you’ve isolated the issues to an I2C address conflict. Can you please link the exact display you were using and the source code you were trying to edit? I would think both devices should be able to operate on the same I2C bus with some changes so that you don’t need a second I2C bus for a single device.

1 Like

Hey Trent,
That would be awesome!
I installed the adafruit library for 1306 oled display, and then used the following code for the display:

git clone https://github.com/mklements/OLED_Stats.git

Display link:

The display address correctly shows as 0x3c when on bus2 as well as when overriding pijuice on bus1, it just won’t read both on bus1 at the same time. I’m using GPIO pins 22 and 23 (15/16) for the display as the juice uses 2 and 3 i believe.
Cheers

1 Like

Hi Sven,

I can see that your code uses board.I2C() to construct the object “i2c”, and looking at the MicroPython Docs, you can change the pins it uses! I’d try changing the pins over and seeing if that works:
https://docs.micropython.org/en/latest/library/machine.I2C.html?highlight=i2c#constructors

You can also check and change the pins used for i2c on your Pijuice through the software:

Keen to get you back on track!
-James

1 Like

Hey James,
I’ve changed the pins over both wiring and code, but when i run i2cdetect, it only shows one or the other on the default bus despite no address conflict. If i set the display pins on a second bus they are detected, but not by the coding for the display.
Am i correct in reading that if i “import machine.Softi2c” for the display code and adjust the address in the code, it might work?
Cheers!

1 Like

Hmm, that didn’t work…
New to all this, so clearly my understanding is lacking! :joy:

1 Like