I use a RUT956. I need to format datetime information like “2025-01-06T17:12:10” for the MQTT Borker.
But the custom data input available is “%local_time%” (YYYY-MM-DD HH:MM).
Did you have more information about “datetime” format available for RUT956? Perhaps, it is possible to use “tag Expansion” (exemple : %local_time%@ISO8601) for a good “datetime” format?
Thank you in advance for your support.
Hello,
There is no option to add ISO 8601 timestamp as a base data point to the Data to server
payload by default.
But it is possible to work around it.
Data to server offers the possibility to gather and send customized data via Lua scripts.
You could try to adding to the script something as follows and upload it to Data to server configuration:
function handle_data_request()
return { time = os.date("!%Y-%m-%dT%H:%M:%SZ") }
end
With the following configuration:
It should send to your server the following:
Alternatively, you can write ISO 8601 timestamp into the MODBUS custom registers following the instructions here: Modbus custom register block RutOS - Teltonika Networks Wiki
This is the script that will write data to the custom register file:
#!/bin/ash
while true
do
date -u +"%Y-%m-%dT%H:%M:%SZ" > /tmp/regfile
sleep 1
done
Additionally, you will need to Enable Modbus TCP server in the WebUI Services → Modbus → Modbus TCP Server page as well as Custom register block option.
Then in Services → Modbus → Modbus TCP client page:
- Add a new instance;
- Enable it;
- Set Address option field to the router‘s IP address;
- Set Period option (in seconds) according to your needs (this will determine how frequently the data will be read);
- Configure a new request:
- Data type: ASCII ;
- Function: Read holding registers (3):
- First register number: 1025;
- Register count/Values: 10
- Save the settings.
If your script is running correctly and you have set up MODBUS correctly, you can test it via WebUI and expect the following output:
Best regards,