Hi,
UPS communication configured for modbus. UPS rs232 port ==> FTDI USB ==> raspberry pi 3B
Openhabian3 ,
First line of the datasheet modbus registers APC UPS:
- All data is transmitted MSB first (i.e. big-endian).
https://download.schneider-electric.com/files?p_Doc_Ref=SPD_LFLG-A32G3L_EN
I am reading int16 from register 40132, result needs to be divided by 32 as stated in the datasheet.
Checked the data with Simply Modbus Master on win10.
ups responds byte-swapped “hex 2D0A” => byte-swap 0A2D => 81,4 dec
Voltage swings between 63V and 84V.
Things file
Bridge modbus:serial:smrtups1_ups1 [ port="/dev/ttyUSB0", baud=9600, id=1, dataBits=8, parity="none", stopBits="1.0", encoding="rtu" ,timeBetweenTransactionsMillis=1000, connectMaxTries=3, reconnectAfterMillis=10000 ] {
Bridge poller ups1_1 [ start=40132, length=2, refresh=1000, type="holding" ] {
Thing data Battery_VoltageDC_ups1 [ readStart="40132", readValueType="int16" ]
}
}
items file
//ups1
Number Battery_VoltageDC_ups1 "UPS1 Battery_VoltageDC [%.1f V]" ( gss_modbus_measure_ups1_voltage) ["Voltage"] { channel="modbus:data:smrtups1_ups1:ups1_1:Battery_VoltageDC_ups1:number" }
In OpenHab
Some data comes in but is not correct, Byte swap does not aid.
Transformation
function swap16(inputData) {
return ((inputData & 0xFF) << 8)
| ((inputData >> 8) & 0xFF);
}
Openhab cannot seem to get the correct data from the UPS,
events.log
2023-07-30 23:38:51.531 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'modbus:data:smrtups1_ups1:ups1_1:Battery_VoltageDC_ups1' changed from UNINITIALIZED to INITIALIZING
2023-07-30 23:38:51.599 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'modbus:data:smrtups1_ups1:ups1_1:Battery_VoltageDC_ups1' changed from INITIALIZING to ONLINE
2023-07-30 23:38:54.960 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Battery_VoltageDC_ups1' changed from NULL to -1
would appreciate some help.
Thanks