Hi,
It is a bit unclear what exactly is needed here.
Even though you can read the state of the I/O from the router via Modbus (reading from itself) and then send it to Azure IoT Hub via 'Data to server', you can send other information that is not available via the Modbus default registers.
Teltonika devices are running on RutOS, an operating system based on OpenWRT. So, it is possible to run Python code on Teltonika devices. For this, you will need to install Python. Keep in mind, that RUT240 does not have much RAM or Flash memory available. There should be around ~4 MB of userspace flash available for you, which should be enough to install a light version of Python via opkg (package manager), but you will likely be very tight on flash memory:
- opkg update
- opkg install python3-light
If you want to send data to Azure IoT Hub via MQTT, what you can do is use a custom Modbus custom register block and data to server functionalities. Basically, you can write a script that will obtain the information and perform the logic, then save the values in a separate file. This file will be used as a custom register for Modbus server. Then, with Data to the server and Modbus data as a source, the Modbus can take the data from that custom register (file) and send it to Azure IoT Hub via MQTT.
To obtain information about different I/O's, I suggest using ubus commands. To see what's available, execute:
Then, for more information on some specific I/O (based on the output of the previous command), for example, you can execute:
- ubus -v list ioman.gpio.dout2
Then, you can do 'status' and 'update' to view and change I/O status (output), respectively. For example:
- ubus call ioman.gpio.dout2 status
- ubus call ioman.gpio.dout2 update '{"value":"1"}'
So basically, you obtain the information that you want via ubus, apply some Python/shell scripting logic, and save it to a custom Modbus register. Then, configure the device to use a custom register block and read Modbus data from itself. After, configure 'Data to server' to send Modbus data to the Azure IoT Hub.
Kind Regards,
Andzej