Using both I2C and Canbus on Photon

HI,

From the photon docs, it looks like the I2C and CANbus share pin D1. Is there any way I can use both communication protocols at the same time? A soft I2C library perhaps, something like this?

Thanks,
Tom

A software I2C library should work for some applications. Give it a try and report back! I’d love to hear your experience.

I’ll also page @jvanier to see if he has any thoughts. He’s quite familiar with CANbus on the Photon.

When I get some parts in, I’ll give it a shot. I’m not particularly knowledgeable about I2C, is there anything I should look out for when porting that library over?

Tom

If you see any assembly code or any code that looks particularly low-level you might prepare yourself a bit of trouble. We should be able to help you debug your port however.

It’s not possible to use the hardware I2C and CAN at the same time on pin D1. There’s no way to remap those pins.

One other possibility would be to use an Electron since it has 2 CAN buses. You can use the 2nd CAN bus and use the D1 pin for I2C.

3 Likes

Hi

So, if we use can_rx and can_tx on photon (D2,D1) we can not use I2c.
We are also not able to use SPI1.

I am using SPI for SD card, can, and want to use SPI oled display.

Can it be done with SPI (oled and SD card) with separated SS (chipselect) pin?

Yes, that should be possible when using SPI.beginTransaction() and SPI.endTransaction().
SdFat does internally use SPI transactions but you may need to account for this issue
https://github.com/particle-iot/device-os/issues/1668


I also moved your "double" post from the other thread here to keep things together.

1 Like

Hi
Did someone try to use sd card (SdCardLogHandler) and oled display on same SPI on photon? Is there allowed to use SS pin selector for SD card and oled display (spi multiple slave configuration)?

The SdFat library supports SPI transactions, so as long the library for the display does as well, then both can share the same SPI bus, with different CS pins, of course.

1 Like