FOR TIPS, gUIDES & TUTORIALS

subscribe to our Youtube

GO TO YOUTUBE

12688 questions

15067 answers

24145 comments

47111 members

0 votes
135 views 4 comments
by
Hi,

We have three 1-wire temp sensors connected to a TRB141. We woudl like to be able to store the temperature info in a custom modbus register block (since 1-wire data is not available in the default TRB141 modbus register list). The idea is to be able to read three custom modbus registers from a Modbus TCP server, modbus registers temp data should be updated every 30 seconds.

Can someone help us with the required script to get this working?

Thank you

1 Answer

0 votes
by

Hello,

Please refer to the guide in the following wiki page for instructions on how to set up a custom MODBUS register: https://wiki.teltonika-networks.com/view/RUT240_modbus_custom_register_block.

Best regards,

by

Thakn you, I did see that article, but I am having trouble finding in the documentation that shows us the script parameters for reading the 1-wire temperature registers, so how do I modify this script to add the 1-wire data for sensor00, sensor01, and so on (below is the example with gsm data, we need the 1-wire data):

 #!/bin/ash
 while true
 do
 date > /tmp/regfile  #where data will be stored
 gsmctl -X >> /tmp/regfile
 gsmctl -E >> /tmp/regfile
 sleep 5 

done 

Thank you

by

Hello, 

The basic procedure to read data from one-wire sensors consists of executing the following three commands: 

  • The following command updates information about 1-wire devices:
ubus call ioman.gpio.onewire update '{"value":"1"}'
  • Next command lists connected one-wire devices from the /sys/bus/w1/devices directory:
ls /sys/bus/w1/devices
  •  To read data execute the following:
cat /sys/bus/w1/devices/<device_name>/w1_slave
by

Hi, so based on what you are saying, if we need to read the 1-wire sensor data using the script, the proposed script would be as follows, can you confirm the syntax is correct?

#!/bin/ash

 while true
 do
 date > /tmp/regfile  #where data will be stored
 cat /sys/bus/w1/devices/<device_name>/w1_slave
 sleep 5 
by

You forgot to append /tmp/regfile

cat /sys/bus/w1/devices/<device_name>/w1_slave >> /tmp/regfile

Besides that, call the ubus command before while loop.