TRB 145 Modbus TCP Slave value send SMS every 24hr

Hi all,
Message is Modbus value Slave id: 1, Modbus value:…, id:2, Modbus value:…
How to add the custom script. Any one done it before

Hello,

You can use Modbus CLI commands (you can find examples in other forum posts as well) together with Crontabs to get Modbus data and send SMS messages every 24 hours. To send SMS messages, you can use the following command:

gsmctl -S -s "+370111111111 SMSTEXT"
gsmctl -h

Kind Regards,

Hi, Thank you for reply.

SMS message include Modbus data value. Crontabs has optional Any script

How to add Message command Modbus register & Value, Time Stamp

Hello,

As mentioned, if you want to include modbus data and send it via SMS every 24hours, you need to write your own scripts via command line. The commands on how to send Modbus requests to obtain Modbus data are described in the link that I have provided earlier. The crontabs information and SMS commands are there as well. The logic of the script could be somethings like this:

#!/bin/sh

#get modbus data
modbus_response=$(ubus call modbus_client tcp.test '{"ip":"192.168.1.10", "port":502, "id":1, "timeout":1, "function":3, "first_reg":1, "reg_count":"2", "data_type":"16bit_int_hi_first", "no_brackets":1}')

#phone number
phone_number="your_phone_number"
#Modbus response as SMS text
sms_text="Modbus Data: $modbus_response"

# Send SMS using gsmctl
gsmctl -S -s "$phone_number $sms_text"

Then, you add it to crontab to execute every 24 hours.

Kind Regards,

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