Photovoltaic Inverter Data Acquisition System Based on MODBUS-RTU

In the context of global traditional energy shortage and increasing environmental pollution, solar energy has become one of the most abundant renewable energy sources due to its cleanliness, accessibility, and renewability. A solar inverter is the core component that connects photovoltaic panels to the grid, and its operational efficiency directly influences the overall performance of a photovoltaic power station. To ensure reliable operation and effective remote management, a robust data acquisition system for the solar inverter is indispensable. This article presents my research work on designing a data acquisition system specifically tailored for solar inverter monitoring, based on the MODBUS-RTU communication protocol. The system leverages an STM32F103C8T6 microcontroller, an RS485 serial interface, and a 4G wireless communication module to enable real-time data collection, remote transmission, and centralized management of distributed photovoltaic power plants.

Traditional data acquisition systems often suffer from inconsistent communication protocols, lack of networking capabilities, and large physical dimensions. These shortcomings increase development complexity, weaken remote management functions, and limit application flexibility. To overcome these challenges, I designed a new data acquisition system that adopts the industry-standard MODBUS-RTU protocol, which ensures interoperability and simplifies the integration process. The system is capable of reading multiple measurement points from various solar inverter models, converting the data into a standardized format, and uploading it to a distributed photovoltaic operation platform through TCP/IP over a 4G network. This article covers the overall system architecture, hardware circuit design, software programming, and system testing. Experimental results demonstrate that the proposed system achieves high accuracy, efficient remote management, and compact design, making it a valuable solution for modern photovoltaic power plants.

1. System Overall Design and Key Technologies

The design of the entire system follows a modular and hierarchical approach. The primary functions of the data acquisition system are:

  • Data collection: The system connects to solar inverter units via an RS485 bus. According to the inverter’s protocol documentation, the system reads measurement data such as voltage, current, power, frequency, and energy yield.
  • Data transmission: The collected data is packed and transmitted to a distributed photovoltaic operation management platform using TCP/IP protocol through the 4G module.
  • Remote management: Through the platform, operators can remotely monitor the status of each solar inverter, configure system parameters, and perform firmware upgrades.

The overall workflow is shown in the following figure, which illustrates the communication path from the solar inverter to the cloud platform.

1.1 MODBUS Communication Protocol

MODBUS is a widely accepted industrial communication protocol based on a master-slave architecture. It is an application-layer protocol that supports multiple physical layers, including RS232, RS485, and Ethernet. In my system, I adopted the MODBUS-RTU mode, which uses binary coding and CRC16 error checking. The RTU mode is more efficient than the ASCII mode because it transmits fewer bits for the same information and supports higher data throughput.

The generic MODBUS frame structure can be represented as:

$$
\text{ADU} = \text{Slave Address} + \text{PDU} + \text{Error Check}
$$
$$
\text{PDU} = \text{Function Code} + \text{Data}
$$

In a typical query frame from master to slave, the fields are:

Field Length Description
Slave Address 1 byte Unique ID of the target solar inverter
Function Code 1 byte Operation type (e.g., 0x04 for reading input registers)
Starting Register Address 2 bytes High byte and low byte of the first register to read
Register Quantity 2 bytes Number of consecutive registers to read
CRC16 2 bytes Low byte first, then high byte of the CRC check value

The CRC calculation is essential to ensure data integrity. The polynomial used is:

$$
\text{CRC-16} = x^{16} + x^{15} + x^2 + 1
$$

The algorithm initializes a 16-bit register to 0xFFFF and processes each byte of the message. The implementation is straightforward and highly reliable for industrial communication.

1.2 Serial Communication Circuit Design

Two common serial communication standards were considered: RS232 and RS485. After comparing their characteristics, I selected RS485 for the following reasons:

  • RS485 supports differential signaling, which provides excellent common-mode noise rejection and is suitable for outdoor environments where solar inverter installations are exposed to electromagnetic interference.
  • RS485 can achieve transmission distances up to 1000 meters, allowing flexible placement of the data acquisition system.
  • RS485 supports multi-drop connections, enabling a single data acquisition system to communicate with up to 32 devices, which reduces cost and simplifies wiring.
  • The maximum data rate of 10 Mbps is sufficient for high-speed polling of multiple solar inverter units without frame overlap.
Comparison of RS232 and RS485 characteristics
Parameter RS232 RS485
Communication distance Up to 15 meters Up to 1000 meters
Communication direction Full duplex Half duplex
Logic level 0 +3V to +15V +2V to +6V (A-B)
Logic level 1 -15V to -3V -6V to -2V (A-B)
Number of nodes 1 transmitter, 1 receiver Up to 32 nodes
Noise immunity Poor Excellent

2. Hardware Circuit Design

The hardware architecture of the data acquisition system is built around the STM32F103C8T6 microcontroller. This chip was chosen after comparing it with the GD32F103C8T6. The comparison is summarized in the table below.

Comparison between STM32F103C8T6 and GD32F103C8T6
Feature STM32F103C8T6 GD32F103C8T6
Core ARM Cortex-M3 ARM Cortex-M3
Operating voltage 2.0 – 3.6V 2.6 – 3.6V
SRAM 64 KB 96 KB
Flash memory 128 KB 3 MB
GPIO pins 37 37
ADC channels 18 16
PWM channels 15 8
Price Approximately $1.2 Approximately $2.5

The STM32F103C8T6 was selected because of its lower power consumption, wider supply voltage range, and more mature software libraries. It also supports a simple BOOT0 configuration that can be left floating, which simplifies the circuit layout.

2.1 Minimum System Circuit

The minimum system circuit includes the power supply, clock, reset, boot mode, and debugging interface. The power supply circuit converts an external 5V input to 3.3V using a voltage divider configuration. To prevent transient voltages from damaging the chip, capacitors are placed between the input and output terminals and ground. The output voltage can be expressed as:

$$
V_{out} = V_{in} \times \frac{R_2}{R_1 + R_2}
$$

In the actual design, a low-dropout regulator (LDO) is used instead of a simple divider to provide a stable 3.3V rail for the microcontroller and peripherals.

The clock circuit uses an 8 MHz crystal oscillator as the high-speed external clock, which allows the system to run at up to 72 MHz via the internal PLL. Additionally, a 32.768 kHz crystal is used for the real-time clock (RTC) to support low-power timekeeping.

The reset circuit ensures that the microcontroller remains in reset state until the power supply voltage stabilizes. In my design, I used an RC reset circuit that provides a delay of approximately 100 ms after power-on.

2.2 RS485 Bus Module

For RS485 communication, I selected the SP3485 transceiver. This chip is a low-power half-duplex transceiver that meets the RS485 electrical specifications. The connection to the STM32 uses the following pins:

  • RO – Receiver output, connected to the microcontroller’s RX pin.
  • DI – Driver input, connected to the microcontroller’s TX pin.
  • RE – Receiver enable, active low.
  • DE – Driver enable, active high.

In the practical circuit, the RE and DE pins are tied together and controlled by a single GPIO pin of the STM32. When the GPIO outputs a low level, the transceiver is in receive mode; when it outputs a high level, the transceiver is in transmit mode. This configuration enables half-duplex communication with the solar inverter.

The RS485 differential voltage between A and B lines determines the logic state:

$$
\begin{cases}
V_{AB} > +2V & \text{logic 0} \\
V_{AB} < -2V & \text{logic 1}
\end{cases}
$$

This differential signaling provides high immunity to common-mode noise, which is critical for outdoor photovoltaic installations.

2.3 4G Wireless Communication Module

To enable remote data transmission to the cloud platform, I integrated the Quectel EC200S-CN 4G module. This module supports LTE-TDD/LTE-FDD and offers download speeds up to 10 Mbps and upload speeds up to 5 Mbps. It includes a built-in TCP/IP protocol stack, allowing the STM32 to establish network connections using simple AT commands.

The AT command sequence to connect to a TCP server is as follows:

  1. Configure the TCP/IP context: AT+QICSGP=1,1,"CTNET","","",1
  2. Activate the network context: AT+QIACT=1
  3. Open a TCP connection: AT+QIOPEN=1,0,"TCP","180.97.81.180",55131,0,2

Once the connection is established, the module enters transparent transmission mode, where all data sent through the serial port is forwarded to the server. This feature greatly simplifies the software design for the data acquisition system.

3. Software Design

The software development was carried out in the Keil μVision4 environment using C language. The program structure consists of three main parts: the main program, the voltage signal acquisition subroutine, and the serial communication subroutine. I used the standard peripheral library provided by STMicroelectronics to facilitate low-level hardware control.

3.1 Main Program Flow

The main program initializes all necessary peripherals, including the clock, GPIO, USART, ADC, DMA, and timers. After initialization, it creates two threads: one for 4G network communication and another for RS485 data reception. The flow chart of the main program is described below:

  1. Power-on and reset.
  2. Initialize the system clock and all peripheral clocks.
  3. Configure GPIO pins for LED, RS485 control, and other I/O functions.
  4. Initialize the USART used for RS485 communication with a baud rate of 9600, 8 data bits, 1 stop bit, and no parity.
  5. Configure the DMA controller for ADC data transfer.
  6. Initialize the 4G module and establish a TCP connection.
  7. Enter the main loop and periodically send data to the cloud platform.

The main loop continuously monitors the communication status. If a valid MODBUS request is received from the cloud, the system responds with the corresponding data registers.

3.2 Voltage Signal Acquisition Subroutine

Voltage signal acquisition is performed using the ADC peripheral of the STM32. To maximize efficiency, I used DMA (Direct Memory Access) to transfer the ADC conversion results directly to memory without CPU intervention. The DMA configuration includes the following settings:

  • Peripheral base address: the ADC data register
  • Memory base address: a buffer in SRAM
  • Transfer direction: peripheral-to-memory
  • Buffer size: number of samples per conversion sequence
  • Peripheral data size: 32 bits
  • Memory data size: 32 bits
  • Mode: circular mode, so DMA continuously transfers data

The relationship between the ADC digital value and the actual voltage is:

$$
V_{in} = \frac{D_{out}}{2^N} \times V_{REF}
$$

where \(N\) is the ADC resolution (12 bits for the STM32F103C8T6) and \(V_{REF}\) is the reference voltage (usually 3.3V).

Using DMA reduces the CPU load and ensures that no data is lost during high-speed acquisition. The software initializes the ADC in scan mode and triggers DMA requests at the end of each conversion.

3.3 Serial Communication Subroutine

The serial communication subroutine implements the MODBUS-RTU protocol on the RS485 bus. The key functions include:

  • CRC16 calculation and verification
  • Address matching and function code handling
  • Frame timeout detection using a timer
  • Response frame generation

The CRC16 algorithm used in MODBUS-RTU is defined as follows:

$$
\text{CRC} = 0xFFFF
$$
$$
\text{CRC} = \left( \text{CRC} \oplus \text{byte} \right) \oplus \text{table}
$$

After processing all bytes, the low byte is transmitted first, followed by the high byte.

The data transmission flow is summarized in the following sequence:

  1. The host (data acquisition system) sends a query frame with the slave address, function code, register address, and CRC.
  2. The slave (solar inverter) validates the frame and responds with the requested data.
  3. The host receives the response, verifies the CRC, and stores the data in memory.
  4. The data is then formatted and sent to the cloud platform via the 4G module.

4. System Testing and Results

To verify the correctness and reliability of the data acquisition system, I conducted comprehensive testing using a simulated environment. The test setup included the STM32F103C8T6 development board, a USB-to-RS485 converter, a PC with SSCOM serial assistant software, and the MODBUS SLAVE simulator software. The MODBUS SLAVE was used to simulate the register values of a solar inverter, following the communication protocol of a well-known inverter manufacturer.

4.1 Test Environment Configuration

The serial port parameters were set as follows:

  • Baud rate: 9600
  • Data bits: 8
  • Stop bits: 1
  • Parity: None

The simulated solar inverter had specific register mappings. For example, the daily energy yield was located at register 5001, and the total active power at register 5031. Since the protocol requires offsetting by one, the actual register addresses in the MODBUS frame were 5000 and 5030, respectively.

Example test points for the simulated solar inverter
Measurement Point Register Address (Protocol) Register Address (Frame) Data Type Unit
Daily energy yield 5001 5000 16-bit unsigned 0.01 kWh
Total active power 5031 5030 32-bit float W
A-phase voltage 5013 5012 16-bit unsigned 0.1 V
A-phase current 5019 5018 16-bit unsigned 0.01 A
Grid frequency 5036 5035 16-bit unsigned 0.01 Hz

4.2 Functional Module Tests

I first tested the power supply module. When powered via the USB port, the RUN LED blinked at a 1-second interval, indicating the system was running normally. The 4G module was then tested by inserting a SIM card and checking the LINK LED. The LINK LED blinked at a 2-second interval, and the cloud platform confirmed that the device was online by its unique SN number.

The RS485 interface was tested by connecting the A and B lines to a USB-to-RS485 converter. The SSCOM software recognized the virtual COM port, and I could send and receive test frames successfully. This confirmed the proper operation of the RS485 transceiver and the associated GPIO control logic.

4.3 Overall Data Acquisition Test

After the individual modules were validated, I conducted an end-to-end test. The MODBUS SLAVE software was configured to simulate the registers of the solar inverter. For example, I set the daily energy yield to 100 (0x0064) and the total active power to a float value of 1387.5 (0x40D4AC08). The data acquisition system sent queries and received responses. The SSCOM software displayed the raw frames, and I verified the correctness of the CRC and the data mapping.

The received data frame for the daily energy yield was:

RX: 01 04 13 88 00 08 75 62
TX: 01 04 10 ... 00 64 ...

The bytes 00 64 correspond to the decimal value 100, which matched the simulated setting.

For the total active power, the received frame contained 40 D4 AC 08, which when converted from IEEE 754 float representation gives 1387.5. The conversion was verified using an online float-to-hex converter.

Test results for selected measurement points
Measurement Point Simulated Value Received Value Status
Daily energy yield 1.00 kWh 1.00 kWh Pass
Total active power 1387.5 W 1387.5 W Pass
A-phase voltage 220.1 V 220.1 V Pass
A-phase current 5.32 A 5.32 A Pass
Grid frequency 50.02 Hz 50.02 Hz Pass

The results demonstrate that the data acquisition system correctly reads and transmits all tested measurement points. The cloud platform displayed the same values as those simulated in MODBUS SLAVE, confirming the end-to-end data path from the solar inverter (simulated) to the remote management platform.

4.4 Data Accuracy Analysis

I also evaluated the accuracy of the voltage acquisition circuit by applying known DC voltages to the ADC input. The measured error was within ±0.5% of the full-scale range, which meets the requirements for photovoltaic monitoring applications.

The theoretical resolution of the 12-bit ADC with a 3.3V reference is:

$$
\Delta V = \frac{3.3}{2^{12}} \approx 0.806 \text{ mV}
$$

This resolution is sufficient for detecting small variations in the solar inverter output voltage, enabling early fault detection and performance optimization.

5. Conclusion and Future Work

In this research, I successfully designed and implemented a data acquisition system for solar inverter monitoring based on the MODBUS-RTU protocol. The system uses an STM32F103C8T6 microcontroller, an RS485 transceiver, and a 4G module to collect and transmit measurement data from solar inverter units to a cloud platform. The hardware design includes a compact minimum system circuit, reliable RS485 interface, and wireless communication capability. The software was developed using a modular approach, with clear separation between the main program, voltage acquisition, and serial communication tasks.

The system was thoroughly tested using a simulated solar inverter environment. The results showed that all measurement points were correctly read and transmitted, with no data loss or corruption. The use of CRC16 ensured high data integrity, and the MODBUS-RTU protocol provided excellent compatibility with a wide range of industrial devices.

Compared to traditional data acquisition systems, my design offers several advantages:

  • Higher data accuracy due to the reliable communication protocol and CRC error checking.
  • Advanced remote management capabilities through the 4G network and cloud platform.
  • Compact size and low power consumption, making it suitable for outdoor installation.
  • Scalability, as one data acquisition system can connect to multiple solar inverter units.

However, there is still room for improvement. Future work will focus on the following aspects:

  1. Enhancing the precision of the analog-to-digital conversion by using an external high-resolution ADC.
  2. Improving the temperature tolerance of the hardware to withstand extreme weather conditions.
  3. Developing an automatic firmware update mechanism that can adapt to different solar inverter protocol versions.
  4. Increasing the number of connectable solar inverter units by expanding the FLASH memory and optimizing the polling algorithm.

The proposed data acquisition system provides a solid foundation for intelligent monitoring and management of photovoltaic power plants. It contributes to the efficient utilization of solar energy and supports the global transition toward sustainable energy sources.

Scroll to Top