Page 1 of 1

making a simple Modbus logger

Posted: 02 Oct 2018, 12:46
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 ?

Re: making a simple Modbus logger

Posted: 02 Oct 2018, 15:47
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

Re: making a simple Modbus logger

Posted: 04 Oct 2018, 15:07
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 ?

Re: making a simple Modbus logger

Posted: 05 Oct 2018, 20:05
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 ?

Re: making a simple Modbus logger

Posted: 08 Oct 2018, 10:56
by dirk
The RevPi Connects RS485 device path is

Code: Select all

/dev/ttyRS485