Configuring SPI communication for multiple bmp280 sensors

Hi All, So i have a particle photon connected to two bmp280 sensors, I previously had them connected to an arduino and used SPI communication. With the photon do i have to set the slave select pins for each bmp ? e.g i have the first bmp connected to the default A2 pin, and the second one connected to A1, the particle doesnt detect the second one automatically, so how would i go about configuring that ?

https://docs.particle.io/reference/device-os/firmware/photon/#spi

I am aware of the documentation and I did try use SPI.begin(A1);, which worked but im not sure that this is the correct way to go about this. Any help would be much appreciated. Thanks in advance

I wouldn't know how that can work any differently on an Arduino.
Can you elaborate?

The A1 in this case just ensures that the A1 pin is set as output pin but does not have any bearing on the communication beyond that.
The user - or in this case the BMP library - needs to also know about the assigned CS pin and then internally engage that pin when needed.

In other words, as long the BMP library makes sure that the correct CS pin for its respective sensor is set as output and used for the communication you won't even need SPI.begin(A1).
When the library is written properly you wouldn't even need SPI.begin() as that should be done internally too (ideally even allowing for alternative SPI interfaces like SPI1 - which sadly is not the case in that library).

1 Like

I wasn’t using it correctly(I was trying to use one sensor to test different pin’s by putting it into A2 and then powering the device off, plugging the the same jumper into A1 which wouldn’t work). Thank you for your help

I would need to have seperate devices plugged into A2 and A1 for it to work correctly

Not sure what you mean by that.
I understood you already have two separate sensors connected each individual CS pin to its dedicated counterpart on the Photon (and also had on the Arduino).
(please stick to the facts in your opening post to avoid confusion like this :wink: )

If so, you need to create two instances of the BMP library class and use them concurrently like this

Adafruit_BMP280 bmp1(A1);
Adafruit_BMP280 bmp2(A2);

void setup() {
  bmp1.begin();
  bmp2.begin();
}
1 Like

Sorry about that, I will definitely try and stick to the facts in the future.

I created my own mass confusion.

1 Like