changks
December 20, 2015, 4:12pm
1
Hello:
I got two Adafruit BME280 sensors and I want to compare if they are able to get similar/identical readings in the same environment.
Here is my SPI wiring on a Photon:
BME280 #1:
Vin -----> VIN
GND -----> GND
SCK -----> A3
SDO -----> A4
SDI -----> A5
CS -----> A2
BME280 #2:
Vin -----> VIN
GND -----> GND
SCK -----> D4
SDO -----> D3
SDI -----> D2
CS -----> D5
Am I doing this wiring correctly?
Can you please provide an example how to print out their readings?
Thanks a lot.
ScruffR
December 20, 2015, 5:01pm
2
Actually you can have both sensors share the CLK, MISO, MOSI lines, only the CS lines need to be seperated and be active mutually exclusive.
Are you using the Adafruit or the SparkFun library?
Either way, there are demo applications with the libraries that should give you an idea how to use the libs.
changks
December 20, 2015, 6:05pm
4
Thanks. I will take a look on Adafruit library.
changks
December 20, 2015, 6:32pm
5
The code is a little complicated. I can define two specific CS pins, but I do not know which sensor is generating the output.
ScruffR
December 20, 2015, 7:01pm
6
It’s not that difficult
You’ll have two seperate objects
Adafruit_BME280 bme1(BME1_CS); // hardware SPI
Adafruit_BME280 bme2(BME2_CS); // hardware SPI
void loop()
{
Serial.print("Sensor 1: Temperature = ");
Serial.print(bme1.readTemperature());
Serial.println(" *C");
Serial.print("Sensor 2: Temperature = ");
Serial.print(bme2.readTemperature());
Serial.println(" *C");
}
changks
December 20, 2015, 10:39pm
7
Thanks a lot. I learned. One more question: I see It has different SPI library for Photon. Can these Adafruit code work for Photon?
ScruffR
December 21, 2015, 8:30am
8
If a library is hosted on Particle Build (Web IDE) then it should be running on the Particle devices - that’s the whole point of having a dedicated library repository.
You might need to look into the docs
https://docs.particle.io/guide/getting-started/build/photon/
Particularly
https://docs.particle.io/guide/getting-started/build/photon/#using-libraries
Sometimes libraries need porting, sometimes you might just need to alter the pins used in the demos.