Issue
My sensor i2c - (flow sensor) on raspberry pi gives a reading b'\x06g'
. How can |I possibly interpret this?
Code snippet used (this code is based on - href="https://github.com/stripemsu/HoneywellFlow" rel="nofollow noreferrer">https://github.com/stripemsu/HoneywellFlow)
import io, fcntl
I2C_SLAVE=0x0703
I2C_BUS=1
HAFAddr=0x49
maxflow=100 #100 sccm
toHex = lambda x: ''.join([hex(ord(c))[2:].zfill(2) for c in x])
i2c_r=io.open("/dev/i2c-"+str(I2C_BUS),"rb",buffering=0)
i2c_w=io.open("/dev/i2c-"+str(I2C_BUS),"wb",buffering=0)
fcntl.ioctl(i2c_r, I2C_SLAVE,HAFAddr)
print(i2c_r.read(2))
i2c_r.close()
I have uploaded the datasheet of the sensor HERE
Solution
Doing b'\x06g'.hex()
gives 0x0667
(converts bytes codes to hex representation).
Seems like the data you are getting is 0x0667
, or 0b0000 0110 0110 0111
. The page 6 of the datasheet gives the digital output vs flow scale. 0x0667 is roughly 10% of the maximum. (in decimal, it can be interpreted as a value of 1639 over the maximum possible value of 16384 (2^14)).
So, the simplest interpretation you could do is to calculate the ratio of the obtained value over the maximum output value (2^14, or 16384). This will probably not give optimal results though, I'm sure some sort of calibration is needed and is surely described in details in the datasheet.
Answered By - DarkFranX Answer Checked By - Mildred Charles (WPSolving Admin)