making a simple Modbus logger

Topics about the Software of Revolution Pi
Post Reply
alf@emcom.no
Posts: 20
Joined: 25 Sep 2018, 10:17

making a simple Modbus logger

Post by alf@emcom.no »

Hi.
As a newbie I feel the Modbus RTU master tutorial left me hanging a little bit.
I was hoping to use a few RevPi Connects to make what would essentially be loggers.
The plan is to connect a few water-flow sensors to the Connect on the RS485-connector, and then simply read the modbus-values and log to a USB.
(In phase 2 we will do something more with the data).

From the tutorial I understand the configuration etc, but how do I in a simple way read the modbus values from the different connected meters and save them to a file ?
User avatar
dirk
KUNBUS
Posts: 2174
Joined: 15 Dec 2016, 13:19

Re: making a simple Modbus logger

Post by dirk »

1) First you have to poll the data from the sensors via a Modbus RTU Master. How this is done is in the Tutorial Modbus RTU Master. Then the data is in the process image.
2) The second step is to write this data to a file. This is just one quick way to do this using the Bash with an Unix timestamp and one value

Code: Select all

ts=$(date +%s); value=$(piTest -1 -q -r Output_Word_1); echo "$ts;$value" >> /home/pi/data.txt
3) If you want to execute this every minute then just put this commands into a file i.e. /home/pi/mylogger.sh, make it executable via

Code: Select all

chmod u+x /home/pi/mylogger.sh
4) Then add this command to the crontab i.e.

Code: Select all

crontab -e 
* * * * * /home/pi/mylogger.sh
alf@emcom.no
Posts: 20
Joined: 25 Sep 2018, 10:17

Re: making a simple Modbus logger

Post by alf@emcom.no »

That works like a charm with a 485/USB in between - but after changing from you suggestion Output_Word to Input_Word.
Thank you very much !
I just ordered 2 RevPi Connects yesterday so I can dispose of the extra hardware.

I only wondered about the terms Input_Word vs Output_Word -> is there a more exhaustive manual/description of all parameter-settings etc for Modbus_RTU_master - module ?
alf@emcom.no
Posts: 20
Joined: 25 Sep 2018, 10:17

Re: making a simple Modbus logger

Post by alf@emcom.no »

Also - as I am waiting for the pcs I have ordered to hit me on monday - what is the device path for the R485 on the Connect ?
User avatar
dirk
KUNBUS
Posts: 2174
Joined: 15 Dec 2016, 13:19

Re: making a simple Modbus logger

Post by dirk »

The RevPi Connects RS485 device path is

Code: Select all

/dev/ttyRS485
Post Reply