Energy System

Launch both OpenLEADR VTN (top node) and VEN (end node) using Docker for development

(June 3, 2022) Let's explore using OpenLEADR to set up a virtual OpenADR network on a local Docker installation. The result will let us edit both the OpenLEADR source code, as well as both VTN and VEN nodes, automatically reloading both VTN and VEN when any files are changed.

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

(June 7, 2017)

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.

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

(July 2, 2017)

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.

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

(June 7, 2017)

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.

Control a power outlet with an ESP8266 running MQTT via a relay

(April 17, 2017) The ESP8266 is a little computer gizmo with bundled WiFi that's easy to incorporate into a wireless control system. The on-board computer is tiny, but it's powerful enough to run a MQTT client. MQTT in turn is an extremely light-weight message-oriented communication system. The example shows an ESP8266 with custom software controlling a relay, that in turn controls enough AC power to turn a light on/off. Controlling the relay is fairly simple, since the ESP8266 has an output strong enough to drive the coil of a relay.

Learn about MODBUS, DNP3, SCADA technologies used for electrical system control

(June 17, 2016)

One area where the MODBUS, DNP3 protocols, and SCADA methodologies, are used is in electrical system devices. MODBUS is a communications protocol widely used for industrial machines, in which a device exposes its current status as "registers" which can be queried over a MODBUS connection, and its current behavior can be modified by storing values in some of those registers. DNP3, a.k.a. Distributed Network Protocol, a.k.a. IEEE 1858, is a set of communications protocols used between components in process automation systems. SCADA, a.k.a. "Supervisory control and data acquisition", is a control system architecture that uses computers, networked data communications and graphical user interfaces for high-level process supervisory management, along with other peripheral devices such as programmable logic controllers and discrete PID controllers to interface to the process plant or machinery.

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

(June 18, 2017)

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.