MODBUS devices in the Energy System

Initial notes on using MAX485 based TTL-to-RS485 adapter boards with Arduino or Raspberry Pi

(Sun Jul 02 2017 00:00:00 GMT+0300 (Eastern European Summer Time))

I've been looking for an inexpensive but robust way to connect an inexpensive embedded computer to an RS485 network. The MAX485 based interface boards look enticingly inexpensive, and claim to be easy to connect. They should be more reliable than a USB RS485 adapter, because the MAX485 boards are hardwired to GPIO pins. It took much searching to find any advice about connecting these adapters to a computer. The board I received was marked DI/DE/RE/RO on one end, and Vcc/A/B/GND on the other. The latter is clear, that's power and the RS485 pins, but what could the other end mean.

Using an Arduino to read a simple MODBUS/RTU RS-485 temperature sensor

(Sun Jun 18 2017 00:00:00 GMT+0300 (Eastern European Summer Time))

Arduino's are very popular for DIY or IoT projects involving a small computerized controller board, some GPIO pins to read inputs from the environment or to control devices, with optional communication with remote services. Theoretically an Arduino, or for that matter larger computers like the Raspberry Pi, can replace the PLC devices commonly used in industrial control applications. Why spend several hundred dollars on an expensive PLC device when the same goal can be achieved more flexibly and inexpensively with newfangled embedded computers like the Arduino?

A key to this is for an Arduino (or other embedded control computer) to interface with MODBUS and other protocols used in industrial settings. In this article we'll go over using an RS-485 Shield for Arduino, using it to communicate with the simple MODBUS temperature sensor we're using.

The libraries we'll discuss in this article enable using the Arduino as either MODBUS Master or Slave. The last is interesting considering the huge variety of sensors available for Arduino. Consider a simple energy monitoring project - One can interface a CT (current transformer) to measure the current in a circuit, and directly measure the voltage using an analog input, a Sketch could read that data from the sensor, and make it available via MODBUS. An Arduino could be a very simple and inexpensive device in a MODBUS network.

Read a MODBUS temperature sensor through USB-RS485 adapter on Ubuntu and Raspberry Pi

(Wed Jun 07 2017 00:00:00 GMT+0300 (Eastern European Summer Time))

Running MODBUS/RTU over an RS485 network is pretty cool, in an old-school way. The technique was invented decades ago, and allowed you to connect to a few dozen MODBUS devices over simple twisted pair copper wire, over a thousand feet distance or more. It's such a successful technique that it has not been supplanted by new modern communication technologies like TCP/IP. Unfortunately most modern computers do not have RS-485 interfaces. Fortunately there are many USB-RS485 adapters available. In this article we'll use a cheap USB-RS485 adapter on both a Raspberry Pi and a regular x86 Linux box to communicate with a simple MODBUS temperature sensor.

What we'll do is create simple MODBUS client programs, in C and Python, to communicate with the chosen temperature sensor device.

Overview of a simple MODBUS/RTU RS-485 temperature sensor

(Wed Jun 07 2017 00:00:00 GMT+0300 (Eastern European Summer Time))

We want to experiment and learn about controlling MODBUS devices from devices like the Raspberry Pi or Arduino. In traditional process control systems, you use a PLC device costing several hundred dollars, and programmed with "ladder logic". Today single-board-computers are cheap, and are attractive for embedded control systems. Without breaking the bank, I found some ultra-cheap MODBUS temperature sensors made in China, available for about $10, and after some trial and error and more error, I have some success to report. In this post we'll simply go over the device I chose.

With any MODBUS/RTU device it's important to evaluate the setup and use of the device. What serial-line parameters to use (baud rate, parity, stop bits, etc), setting the client ID, and the registers which can be used, are all basic considerations. While this post looks at a specific device, the general outline of the evaluation is what is done for every MODBUS device.