File tree Expand file tree Collapse file tree 4 files changed +21
-14
lines changed
I2C_Multiple_Same_Address Expand file tree Collapse file tree 4 files changed +21
-14
lines changed Original file line number Diff line number Diff line change @@ -18,8 +18,9 @@ void setup() {
1818
1919 // In the call to begin, pass in the I2C address.
2020 // If left out, the default address is used.
21- bme1.begin (); // use the default address of 0x77
22- bme2.begin (0x76 ); // specify the alternate address of 0x76
21+ // But also OK to just be explicit and specify.
22+ bme1.begin (0x77 ); // address = 0x77 (default)
23+ bme2.begin (0x76 ); // address = 0x76
2324}
2425
2526
Original file line number Diff line number Diff line change 99# Get the board's default I2C port
1010i2c = board .I2C ()
1111
12+ #--------------------------------------------------------------------
13+ # NOTE!!! This is the "special" part of the code
14+ #
1215# Create each sensor instance
13- bme1 = adafruit_bme280 .Adafruit_BME280_I2C (i2c ) # default 0x77 address
14- bme2 = adafruit_bme280 .Adafruit_BME280_I2C (i2c , 0x76 ) # alternate 0x76 address
16+ # If left out, the default address is used.
17+ # But also OK to be explicit and specify address.
18+ bme1 = adafruit_bme280 .Adafruit_BME280_I2C (i2c , 0x77 ) # address = 0x77
19+ bme2 = adafruit_bme280 .Adafruit_BME280_I2C (i2c , 0x76 ) # address = 0x76
20+ #--------------------------------------------------------------------
1521
1622print ("Two BME280 Example" )
1723
2430 print ("BME280 #1 Pressure =" , pressure1 )
2531 print ("BME280 #2 Pressure =" , pressure2 )
2632
27- time .sleep (1 )
33+ time .sleep (1 )
Original file line number Diff line number Diff line change 1717# NOTE!!! This is the "special" part of the code
1818#
1919# Create each BME280 using the TCA9548A channel instead of the I2C object
20- bme1 = adafruit_bme280 .Adafruit_BME280_I2C (tca [0 ])
21- bme2 = adafruit_bme280 .Adafruit_BME280_I2C (tca [1 ])
22- bme3 = adafruit_bme280 .Adafruit_BME280_I2C (tca [2 ])
20+ bme1 = adafruit_bme280 .Adafruit_BME280_I2C (tca [0 ]) # TCA Channel 0
21+ bme2 = adafruit_bme280 .Adafruit_BME280_I2C (tca [1 ]) # TCA Channel 1
22+ bme3 = adafruit_bme280 .Adafruit_BME280_I2C (tca [2 ]) # TCA Channel 2
2323#--------------------------------------------------------------------
2424
2525print ("Three BME280 Example" )
3535 print ("BME280 #2 Pressure =" , pressure2 )
3636 print ("BME280 #3 Pressure =" , pressure3 )
3737
38- time .sleep (1 )
38+ time .sleep (1 )
Original file line number Diff line number Diff line change 1717# NOTE!!! This is the "special" part of the code
1818#
1919# Create each BME280 using the TCA9548A channel instead of the I2C object
20- bme1 = adafruit_bme280 .Adafruit_BME280_I2C (tca [0 ])
21- bme2 = adafruit_bme280 .Adafruit_BME280_I2C (tca [1 ])
22- bme3 = adafruit_bme280 .Adafruit_BME280_I2C (tca [2 ])
23- bme4 = adafruit_bme280 .Adafruit_BME280_I2C (tca [3 ])
20+ bme1 = adafruit_bme280 .Adafruit_BME280_I2C (tca [0 ]) # TCA Channel 0
21+ bme2 = adafruit_bme280 .Adafruit_BME280_I2C (tca [1 ]) # TCA Channel 1
22+ bme3 = adafruit_bme280 .Adafruit_BME280_I2C (tca [2 ]) # TCA Channel 2
23+ bme4 = adafruit_bme280 .Adafruit_BME280_I2C (tca [3 ]) # TCA Channel 3
2424#--------------------------------------------------------------------
2525
2626print ("Four BME280 Example" )
3838 print ("BME280 #3 Pressure =" , pressure3 )
3939 print ("BME280 #4 Pressure =" , pressure4 )
4040
41- time .sleep (1 )
41+ time .sleep (1 )
You can’t perform that action at this time.
0 commit comments