I monitor 10 Modbus devices with a Raspberry Pi 3B. Each modbus device sits about 20-30cm from the Pi and sends signal to the Pi through a Modbus RS485 to USB converter, which is shown here: https://www.amazon.co.uk/gp/product/B08CRL6KHV
The Pi, through a cron job that runs every minute, sends the collected data to my server with an API call with the Python requests library operating through an Ethernet cable.
The above system is implemented with Pymodbus, and works flawlessly...for about 4-5 days. Then I notice that a test ping to my server (which runs on a cron to test the internet connection separately) happens, but that the subsequent readings which I expect to see after the test do not happen. Some minutes later the test pings also stop. Strangely, every now and again I will sometimes see an intermittent test ping from the Pi.
I tried a dirty fix of this problem which involved:
- Forcing a restart of the Pi with a cron job every 6 hours and
- Using an internal watchdog to restart in the event of memory running low
After the above measures the Pi would still freeze every 4-5 days.
The Pi is unfortunately on-site at the moment hundreds of km from me so I cannot check the log files (though I hope to get them soon).
Reading about similar spontaneous stoppages of Pi sensor systems elsewhere, I have seen the following possibilities surrounding failure:
- Voltage issues with the Pi (in my case the supply is a stable 5.1V and 2.5A)
- Poor wiring with the Modbus devices. I am not using the double-wound wiring (recommended to reduce electrical interference) but I presume this doesn't matter because the devices are only 20-30 cm from the Pi. When I used this same wiring setup on my desk it appeared to work perfectly.
- The FTDI chip in the Modbus-RS485 USB converter could (according to some people) be prone to spontaneously causing locks in the USB port. Some posts suggest using a more sophisticated RS485 converter, like this one: https://thepihut.com/products/rs422-rs485-serial-hat
Has anyone out there experienced spontaneous stoppages with their Pi Modbus devices? If you have, how did you fix them? And do you have an informed opinion on whether the FTDI chip in the RS485 converter could be a factor?
Many thanks in advance!