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 ?
making a simple Modbus logger
Re: making a simple Modbus logger
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
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
4) Then add this command to the crontab i.e.
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
Code: Select all
chmod u+x /home/pi/mylogger.sh
Code: Select all
crontab -e
* * * * * /home/pi/mylogger.sh
-
- Posts: 20
- Joined: 25 Sep 2018, 10:17
Re: making a simple Modbus logger
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 ?
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 ?
-
- Posts: 20
- Joined: 25 Sep 2018, 10:17
Re: making a simple Modbus logger
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
The RevPi Connects RS485 device path is
Code: Select all
/dev/ttyRS485