Open cpietsch opened 3 years ago
Or at least a proper documentation of the I2C registers?
after fiddling with the bme680 and its software, I doubt that without proper computing these sensors won't yield plausible results
Has anyone made any progress on this? I'm looking for how to port it but it's a bit difficult without the register information.
I have only found the following but it does not seem to work: Python port
This is what I have managed so far by looking at the Arduino code but I am not able to make it work.
import time
import smbus2
import struct
class GAS_GMXXX:
GM_102B = 0x01
GM_302B = 0x03
GM_502B = 0x05
GM_702B = 0x07
CHANGE_I2C_ADDR = 0x55
WARMING_UP = 0xFE
WARMING_DOWN = 0xFF
GM_VERF = 3.3
GM_RESOLUTION = 1023
def __init__(self, bus, address):
self.bus = smbus2.SMBus(bus)
time.sleep(1)
self.address = address
self.is_preheated = False
def write_byte(self, cmd):
self.bus.write_byte(self.address, cmd)
def read_32(self):
data = self.bus.read_i2c_block_data(self.address, 0, 4)
return struct.unpack('>I', bytes(data))[0]
def preheat(self):
self.write_byte(GAS_GMXXX.WARMING_UP)
self.is_preheated = True
def un_preheat(self):
self.write_byte(GAS_GMXXX.WARMING_DOWN)
self.is_preheated = False
def get_gm102b(self):
if not self.is_preheated:
self.preheat()
self.write_byte(GAS_GMXXX.GM_102B)
return self.read_32()
def get_gm302b(self):
if not self.is_preheated:
self.preheat()
self.write_byte(GAS_GMXXX.GM_302B)
return self.read_32()
def get_gm502b(self):
if not self.is_preheated:
self.preheat()
self.write_byte(GAS_GMXXX.GM_502B)
return self.read_32()
def get_gm702b(self):
if not self.is_preheated:
self.preheat()
self.write_byte(GAS_GMXXX.GM_702B)
return self.read_32()
def change_address(self, new_address):
self.write_byte(GAS_GMXXX.CHANGE_I2C_ADDR)
self.write_byte(new_address)
self.address = new_address
def calc_vol(self, adc):
return adc * self.GM_VERF / (self.GM_RESOLUTION * 1.0)
Any help would be welcome.
Thank you very much!
@cpietsch or someone, please, could you test if my code works with the sensor if you have one?
I am trying to test with the sensor I have but the example in Arduino always gives me all the values at 0.
The same thing that happens to this user:
I don't understand anything, I don't know if the sensor directly doesn't work or what happens.
Try code under: https://github.com/atsclct/atsc_sensors two versions of python code work for raspberry pi and pico respectively.
Hi,
thank you very much for! I'll have a look into this project.
Best regards,
Martin
Am Fr., 17. März 2023 um 22:32 Uhr schrieb atsclct @.***
:
Try code under: https://github.com/atsclct/atsc_sensors two versions of python code work for raspberry pi and pico respectively.
— Reply to this email directly, view it on GitHub https://github.com/Seeed-Studio/Seeed_Arduino_MultiGas/issues/4#issuecomment-1474422569, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFCGAAJYPDVE77WT7HTSP63W4TJ77ANCNFSM4WXWA67A . You are receiving this because you are subscribed to this thread.Message ID: @.***>
It would be great to have a Python Library for Raspberry Pi. On the Grove Website it says: "To Do" for Platform Raspberry Pi.
Any news on that topic ?