Hello,
I have a TCPIP analog data acquisition board with 8 analog inputs.The device is a 4ma - 20ma current loop type. I can connect and request sensor readings with Hercules SETUP Utility w/ hex send and receive.
Here is the request for readings…
80 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 81
And the Data Return (sensors only installed on ports 1,2 and 8)…
01 8b 0f da 29 00 00 00 00 00 00 00 00 00 00 af 0b 00 00 00 00 00 00 00 00 00 00 00 00 00 00 81
Byte 1 = Function (01, sensor read in this case)
Byte 2,3 = Channel 1 L-H, 8b 0f (0xfab = 3979 μA = 3979/1000 = 3.979 ma)
Byte 4,5 = Channel 2 L-H, da 29 (0x29da = 10714 μA = 10714/1000 = 10.712 ma)
Byte 6,7 = Channel 3 L-H
Byte 8,9 = Channel 4 L-H
Byte 10,11 = Channel 5 L-H
Byte 12,13 = Channel 6 L-H
Byte 14,15 = Channel 7 L-H
Byte 16,17 = Channel 8 L-H, af, 0b (0xbaf = 2991 μA = 2991/1000 = 2.991 ma)
Byte 18-31 = Random unused data
Byte 32 = Checksum
From the guide:
Channel 8 corresponds to Byte[16-17](af 0b), 16th byte is low bit, 17th byte is high bit, so the combined hexadecimal is 0x0baf, and the converted decimal is 2991. What needs special attention is that the collected AD value has been converted by module, the unit of 2991 replied by module is μA,and mA is the unit: 2991/1000=2.991ma. The collected current value error of this module is ±0.002ma. The conversion method of channel 1 to channel 7 is same as above example.
The board’s analog ports input current range is 4ma - 20ma .
I need to set up these analog sensors in HA. I plan on using ACS712 current sensors on 5 of the ports and probably NTC 10K thermistors on the remaining three.
Here is the sequence based on my limited knowledge…
-
send a request to the tcpip server:port to retrieve the hexadecimal data
-
receive the hexamadecimal data and convert it to an integer
-
convert the integer (temperature or current) depending on the sensor type
-
send the converted data to the HA sensors sensor.1xx sensor.2xx… sensor.8xx
-
further automation, etc.
So I will be converting the analog current loop readings to actual current (or temperature) from the sensor?
I am stuck on the best way to do this. I think I have to use Templates but will one template do all this?
Thanks in advance!