I2C OLED working on Photon, but not on Electron

Hello I am just trying to test an I2C OLED connected to an Electron. I am using the example code https://github.com/pkourany/Adafruit_SSD1306/blob/master/beginner-128x64-OLED-I2C.ino. I have D0 and D1 connected to SDA and SCL on the screen’s breakout board. I am building the firmware with particle CLI and flashing over USB in DFU mode. I have all the libraries required by the repo in my build directory. If I build the firmware for a Photon and flash it to a Photon, it works as expected, but when I try to build the firmware and flash it to an Electron with the exact same wiring, nothing happens. I have the latest firmware (0.6.2) and I have had success with other code that didn’t use I2C on the very same Electron.

Any help would be appreciated. Thanks!

Hi @generalg

Are you remembering to target Electron?

particle compile electron my_dir

or

particle compile electron mysketch.ino lib.cpp lib.h otherlib.cpp otherlib.h

Yes, I am targeting electron and including all necessary header and cpp files.

@generalg, how are you powering the display on the Photon and on the Electron?

2 Likes

Both are being powered of USB, should I attach a battery to Electron?

Absolutely!

Unsurprisingly, connecting a battery to the Electron does not make a difference. I am moving to using an SPI TFT LCD instead. Will open a different thread if I have problems with that. Thanks for the advice though.

For i2c, I always recommend that you check the pull-ups. They are required.

I tried with 10k pull-ups, still nothing. Also, the Photon didn’t “need” pull-ups to work.

Yes, it did! They may have been provided by some other part of your Photon setup, but they are absolutely required.

Or the pull-ups are on the OLED board. I suggest you check as per @bko’s suggestions.

1 Like

I like how no one asked about my SIM card? I guess it’s my fault for not sharing my blinky light conditions. I’ve been flashing over USB and don’t have a SIM card. Just needed to add SYSTEM_THREAD(ENABLED); at top of code. Duh.

1 Like