Python script
from
bme280
import
BME280
import
smbus
import
os
import
time
(
'TCA9548A Multi BME280 script'
)
class
multiplex
:
def
__init__
(
self
,
bus
):
self
.bus = smbus.
SMBus
(bus)
def
channel
(
self
,
address
,
channel
):
if
(channel
==
0
):
action
=
0x01
elif
(channel
==
1
):
action
=
0x02
elif
(channel
==
2
):
action
=
0x04
elif
(channel
==
3
):
action
=
0x08
elif
(channel
==
4
):
action
=
0x10
elif
(channel
==
5
):
action
=
0x20
elif
(channel
==
6
):
action
=
0x40
elif
(channel
==
7
):
action
=
0x80
else
:
action
=
0x00
self
.bus.
write_byte_data
(address,
0x04
, action)
- 23 -