01-27-2022 01:30 PM
Hi all. I'm trying to convert these register values into a serial number and sensor value using the info from the device manual pasted below. Any help would be much appreciated. Thank you.
Solved! Go to Solution.
01-27-2022 04:11 PM
Does not compute to expected value.
If you expect 71963431, the registers should be 1098 and 4903. I suspect you are reading registers 1 and 2 of the input registers, but reading register 0 and 1 will actually return registers 30001 and 30002. Try that, and use type cast on the arrays of u16. Wire any u32 for the serial and a single precision float to the measurement value.
01-28-2022 10:54 AM
Great. I'm almost there. Two out of three are working. I am getting the correct serial number and value 1 (humidity), but I still can't get value 2 (temp). You were right about reading the wrong registers for the serial number. I guess I expected the modbus read input register vi to return 30001 and 30002 by wiring 30001 as the starting address and 2 as the number of input registers. But I had to wire 30000 as the starting address to get the right serial. Is it supposed to work that way or could the chart be incorrect?
To get value 1, I had to use 31001 as the starting address, which was what I expected from the chart. But I can't find any way to get value 2. If I start at 31003 with 2 registers, I get Error -389113 occurred at an unidentified location. I can read a max of 4 registers starting at 30000 and not sure how to get value two out of those, which is expected to be around 70.
I'm stumped on value 2. Any ideas there?
.
01-28-2022 10:59 AM
01-28-2022 11:29 AM
I think the device is sending the registers in different order. It's a bit odd they do it for floats and not for the u32 serial, but if you swap the registers it gives data that seems believable (21 C for room temperature)
So change the read to be 0-indexed and then reverse or otherwise swap the registers before type cast.
01-28-2022 11:49 AM
Great that does it. Thanks much! The funny part is that I did manage to get the 21 temp value before, but derped and didn't realize that it was in C because the device is set to F so I thought it was wrong. Thanks again!