Generators, in this post, means the diesel kind that keep factories running when the grid drops. Not the Python kind, although one does turn up in the code below.
We at Enpower supply and commission diesel sets across Pakistan, where load-shedding means a backup set can run for hours a day. More of our customers now have someone in-house who writes code, and they ask the same thing: how do we get the data out of our generators and into something we can query? This is the hands-on version of our answer. You'll wire an RS-485 link, poll the controller with Python, store readings in SQLite and write a few rules that flag real problems.
What you need on the bench
A generator controller with a Modbus RTU port on RS-485, or a Modbus TCP gateway
A USB to RS-485 adapter, preferably an isolated one
A Raspberry Pi or any small Linux box that can live in the panel room
Python 3 with pymodbus installed
The controller's Modbus register map, from its manufacturer
That last item matters more than the hardware.…