sen0322 temperature calculations

userHead prbonin 2024-10-20 00:24:48 139 Views3 Replies

I'm working with a sen0322 and a Raspberry Pico W running micropython. I'm able to read data from sensor but so far I have found three different methods to get the O2 reading from the sensor and none of them gives a value that makes sense. I've been reading in 10 + 1 bits ( bit[0] is the device address) and my bytearray print out looks like this:

 

b's\xdf\x10j\x06\x02\x00\x00\x00\x00\xc4

 

I don't know why there's a j there and when I print out individual elements , 0 to 11, of the bytearray I get the following integers:

 

116, 223, 16, 106, 6 , 2, 0,0,0,0, 196 

 

converting back to hex gives me

 

x73, xdf, x10, x6a, x06, x02,x00,x00,x00,x00, xc4

 

I'm not sure what bytearray is doing here. 

 

Just clear  the bytearray buffer and tried the whole ordeal again. I ended up with the following inters and hex bits:

 

116, 223, 16, 106, 7, 8, 0,0,0,0, 196

x73, xdf, x10, x6a, x07, x08, x00,x00,x00,x00, xc4

 

So there is fluctuation in the data coming from the sensor which would be expected. So does anyone have a straight forward solution get the %vol from these integers and bits? 

 

2025-01-22 14:42:47

Thank you so much for the info.

userHeadPic Larrick.Smith
2025-01-22 14:42:00

Thank you so much for the info.

userHeadPic Larrick.Smith
2025-01-22 01:35:34

Hi, from what I have found, we have:

 

byte 0: I2C address? 

byte 1-2: ?

byte 3-5: oxy data

byte 6-7: ?

byte 8-9: calibration values

byte 10: read register for calibration values

 

Formula for O2 is given in library:

(byte10/1000)  (byte3 + byte4/10 + byte5/100) = 0.196 * (106 + 0.6 + 0.02) = 20.8975

userHeadPic Matt.Slow