File tree Expand file tree Collapse file tree 2 files changed +73
-0
lines changed
I2C_Multiple_Same_Address
arduino/multi_bme280_ltc4316
circuitpython/multi_bme280_ltc4316 Expand file tree Collapse file tree 2 files changed +73
-0
lines changed Original file line number Diff line number Diff line change 1+ // SPDX-FileCopyrightText: 2024 Carter Nelson for Adafruit Industries
2+ //
3+ // SPDX-License-Identifier: MIT
4+
5+ #include < Adafruit_BME280.h>
6+
7+ // For each device, create a separate instance.
8+ Adafruit_BME280 bme1; // BME280 #1 @ 0x77
9+ Adafruit_BME280 bme2; // BME280 #2 @ 0x37
10+
11+ void setup () {
12+ Serial.begin (9600 );
13+ while (!Serial);
14+ Serial.println (F (" Two BME280 Example" ));
15+
16+ // NOTE: There's no need to manually call Wire.begin().
17+ // The BME280 library does that in its begin() method.
18+
19+ // In the call to begin, pass in the I2C address.
20+ // If left out, the default address is used.
21+ // But also OK to just be explicit and specify.
22+ bme1.begin (0x77 ); // address = 0x77 (default)
23+ bme2.begin (0x37 ); // address = 0x37 (behind LTC4316)
24+ }
25+
26+
27+ void loop () {
28+ float pressure1, pressure2;
29+
30+ // Read each device separately
31+ pressure1 = bme1.readPressure ();
32+ pressure2 = bme2.readPressure ();
33+
34+ Serial.println (" ------------------------------------" );
35+ Serial.print (" BME280 #1 Pressure = " ); Serial.println (pressure1);
36+ Serial.print (" BME280 #2 Pressure = " ); Serial.println (pressure2);
37+
38+ delay (1000 );
39+ }
Original file line number Diff line number Diff line change 1+ # SPDX-FileCopyrightText: 2024 Carter Nelson for Adafruit Industries
2+ #
3+ # SPDX-License-Identifier: MIT
4+
5+ import time
6+ import board
7+ from adafruit_bme280 import basic as adafruit_bme280
8+
9+ # Get the board's default I2C port
10+ i2c = board .I2C () # uses board.SCL and board.SDA
11+ # i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
12+
13+ #--------------------------------------------------------------------
14+ # NOTE!!! This is the "special" part of the code
15+ #
16+ # Create each sensor instance
17+ # If left out, the default address is used.
18+ # But also OK to be explicit and specify address.
19+ bme1 = adafruit_bme280 .Adafruit_BME280_I2C (i2c , 0x77 ) # address = 0x77
20+ bme2 = adafruit_bme280 .Adafruit_BME280_I2C (i2c , 0x37 ) # address = 0x37
21+ #--------------------------------------------------------------------
22+
23+ print ("Two BME280 Example" )
24+
25+ while True :
26+ # Access each sensor via its instance
27+ pressure1 = bme1 .pressure
28+ pressure2 = bme2 .pressure
29+
30+ print ("-" * 20 )
31+ print ("BME280 #1 Pressure =" , pressure1 )
32+ print ("BME280 #2 Pressure =" , pressure2 )
33+
34+ time .sleep (1 )
You can’t perform that action at this time.
0 commit comments