Data to server in a fixed time

I want to set data to server not based on peroid , i need device send the data in midnight everyday, how to set that?

or I need something like on demand send data to MQTT protocal, currently it only send by peroiod.

Hello,

This is not currently possible to set in the WebUI, however, if you ensure that the option “Retry on fail” is enabled in the WebUI, and block the access to the MQTT Broker (so that the router could not send the data), once the connection to the broker is re-established you should receive all of the data collected.
Please keep in mind, that this data is being stored in a database file, which is stored in the volatile memory. This means that if the device reboots, the information will be lost.

Best regards,

How about use crontab with SSH, to set uci set ....datatoserver.enabled=1 to 0 then, at a time set back to =1, this is the current walkaround I’m going to use.

also, I want to export the setting in one device, and and do some modification for other devices, should i use uci export > conf.txt, then do the change then uci import conf.txt?

What I meant is i need MQTT configure for all 2000 + other devices are same, but modbus is a bit different. What is the best way to use config template?

Sure, this will work, but it has the same issue as my suggestion. If the device reboots, the collected data will be lost.

I’d suggest using the backup files to apply the configuration, as that will be the most robust option. For example, when applying a backup file to the newer firmware version, the configuration will automatically be adjusted for the new/changed options when compared to the older firmware. This is not the case when applying changes via UCI.
As for the Modbus template, since it’s different for every device, UCI might be the best option here. To apply the backup file only for specific service, open the backup file, and remove every unnecessary file from /etc/config folder. system file is mandatory, and if you’d like to keep the data to server configuration the same for every device, also leave the modbus_data_sender file in place.

Best regards,

This is not currently possible to set in the WebUI, however, if you ensure that the option “Retry on fail” is enabled in the WebUI, and block the access to the MQTT Broker (so that the router could not send the data), once the connection to the broker is re-established you should receive all of the data collected.

Thanks, is there a way I can access to the database with python or something else, I write my own script to read the data at that time, then use some python library by pip install, to send data to my AWS iot core?

The database file is kept in /tmp/modbus.db.
You could utilize a crontab to send this file somewhere else.
Python can be installed on some of our devices, so it depends on the device being used.

Best regards,

The database file is kept in /tmp/modbus.db .

THat’s great, is that SQLlit? Is the *.db updated real time?

The device we are using got python3 package. Don’t know if it includes pipe so that after install it I can do python3 -pip install <something>

No, pip is not present in the RutOS build of Python, as it simply uses too many resources.
and yes, the database uses SQLite, and is updated every time the Modbus Master reads the values from the slave.

Best regards,

Hi Daumantas,

Thank you for reply.

Now, I got a plan to processing the data:

  1. create a crontab job to schedule the script job at midnight,
  2. use python3’s sqlite3 library, read the modbus_db file, only get the most recent records,
  3. at the same time pre-sign a s3 url, and put the recent records to that url / or use MQTT to send data to iot core, but this way need to install some library don’t know if TRB145 support it(like requests lib).

With this way, I can either get the data on demand or schedule a send data everyday. How do you think about this method? Or do you have any other advise? :grinning: :grinning:

If possible, where I can access the your MQTT api to send data to aws, so that I won’t need to install third party packages to do that.

Hello,

The method seems fine, it’s hard to say if there could be any issues without seeing the actual code or knowing some more specific details.

Yes, the syntax for mqtt_pub is described here: Monitoring via MQTT - Teltonika Networks Wiki
In the latest RutOS releases, mosquitto_pub was replaced with mqtt_pub. However, I’m not sure if sending the data with certificates via CLI will work. Perhaps a better approach would be to use the custom Modbus register file as an intermediate layer before sending it to AWS, and then use Data to Server. We have a configuration example of Data to Server with AWS: AWS MQTT cloud connection - Teltonika Networks Wiki

Hope this helps!

Best regards,

1 Like

This topic was automatically closed after 15 days. New replies are no longer allowed.