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() {
18
18
19
19
// In the call to begin, pass in the I2C address.
20
20
// 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
23
24
}
24
25
25
26
Original file line number Diff line number Diff line change 9
9
# Get the board's default I2C port
10
10
i2c = board .I2C ()
11
11
12
+ #--------------------------------------------------------------------
13
+ # NOTE!!! This is the "special" part of the code
14
+ #
12
15
# 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
+ #--------------------------------------------------------------------
15
21
16
22
print ("Two BME280 Example" )
17
23
24
30
print ("BME280 #1 Pressure =" , pressure1 )
25
31
print ("BME280 #2 Pressure =" , pressure2 )
26
32
27
- time .sleep (1 )
33
+ time .sleep (1 )
Original file line number Diff line number Diff line change 17
17
# NOTE!!! This is the "special" part of the code
18
18
#
19
19
# 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
23
23
#--------------------------------------------------------------------
24
24
25
25
print ("Three BME280 Example" )
35
35
print ("BME280 #2 Pressure =" , pressure2 )
36
36
print ("BME280 #3 Pressure =" , pressure3 )
37
37
38
- time .sleep (1 )
38
+ time .sleep (1 )
Original file line number Diff line number Diff line change 17
17
# NOTE!!! This is the "special" part of the code
18
18
#
19
19
# 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
24
24
#--------------------------------------------------------------------
25
25
26
26
print ("Four BME280 Example" )
38
38
print ("BME280 #3 Pressure =" , pressure3 )
39
39
print ("BME280 #4 Pressure =" , pressure4 )
40
40
41
- time .sleep (1 )
41
+ time .sleep (1 )
You can’t perform that action at this time.
0 commit comments