Skip to content

Commit

Permalink
Replace SMBusWrapper with SMBus.
Browse files Browse the repository at this point in the history
  • Loading branch information
is-qian committed Oct 16, 2024
1 parent 1467b17 commit 8f4a88d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions grove/grove_PM2_5_HM3301.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@


from smbus2 import SMBus , i2c_msg
from smbus2 import SMBusWrapper
import time


Expand All @@ -53,12 +52,12 @@ def __init__(self,bus_nr = 1):
self.PM_10_conctrt_atmosph = 0 #PM10 Atmospheric environment concentration ,unit:ug/m3


with SMBusWrapper(bus_nr) as bus:
with SMBus(bus_nr) as bus:
write = i2c_msg.write(HM3301_DEFAULT_I2C_ADDR,[SELECT_I2C_ADDR])
bus.i2c_rdwr(write)

def read_data(self):
with SMBusWrapper(1) as bus:
with SMBus(1) as bus:
read = i2c_msg.read(HM3301_DEFAULT_I2C_ADDR,DATA_CNT)
bus.i2c_rdwr(read)
return list(read)
Expand Down Expand Up @@ -93,7 +92,7 @@ def parse_data(self,data):
print(" ")

'''
with SMBusWrapper(1) as bus:
with SMBus(1) as bus:
write=i2c_msg.write(0x40,[0x88])
bus.i2c_rdwr(write)
Expand Down

0 comments on commit 8f4a88d

Please sign in to comment.