An ESPHome-based solution for monitoring and controlling photovoltaic inverters via Modbus RTU communication. This project provides comprehensive integration with Home Assistant, enabling real-time monitoring and control of solar power systems.
Installation & Presentation: https://youtu.be/iJjsA_MzmnE [PL]
- Default Baud Rate Change for Deye SG0XLP3 and SG0XHP3 Inverters: The default baud rate has been changed from 19200 to 9600 for better compatibility and stability.
- Action Required: If you're upgrading from a previous version and have a inverter configured with baud rate 19200, you must change it to 9600 before updating.
-
Deye SG0XLP1 (Single Phase Low Voltage)
Single Phase Recommended baud rate: 9600 (default, nothing to change)
-
Deye SG04LP3 (Low Voltage)
-
Deye SG05LP3 (Low Voltage)
-
Deye SG01HP3 (High Voltage)
-
Deye SG02HP3 (High Voltage)
3 Phases Recommended baud rate: 9600 (default, nothing to change)
To set the baud rate on your Deye inverter:
- Navigate to: Advanced Settings β Paral. Set 3 β Boud Rate
- Set the value to 9600
- Save the settings
Note: After saving, the screen will turn off and a red LED alarm will flash - this is normal behavior. Everything should return to normal after a moment.
- Real-time Monitoring: Monitor PV production, battery status, grid consumption, and load data
- Remote Control: Control inverter work modes, battery charging parameters, and time-of-use settings
- Home Assistant Integration: Seamless integration with Home Assistant via ESPHome API
- Safety Features: Automatic fallback to safe operating parameters when connection to Home Assistant is lost
- Modular Design: Clean, maintainable code structure with separate packages for different system components
- Multiple Inverter Support: Currently supports both low voltage (SG04LP3) and high voltage (SG01HP3) Deye inverters
- ESP Development Board (e.g., ESP32-DevKit V1)
- RS485 to TTL Converter
- PV Inverter with Modbus RTU support
- Connecting Cables (for RS485 communication)
Connect your ESP32-DevKit V1 to the inverter's Modbus port:
ESP32 RS485 Converter Inverter
GPIO17 (TX) -> DI/A+ -> A+ (Modbus)
GPIO16 (RX) -> RO/B- -> B- (Modbus)
3.3V -> VCC
GND -> GND -> GND (Modbus)
Note: Some RS485 converters may require a flow control pin. Uncomment and configure the flow_control_pin
in the main configuration if needed.
This is the easiest way to get started if you're using Home Assistant.
- Home Assistant with Add-on store access
- ESP development board
- RS485 to TTL converter
- In Home Assistant, go to Settings β Add-ons β Add-on Store
- Search for "ESPHome" and click Install
- After installation, click Start and optionally enable "Start on boot"
- Click "Open Web UI" to access ESPHome dashboard
- In ESPHome dashboard, click "+ NEW DEVICE"
- Click "CONTINUE" on the welcome screen
- Enter a name for your device (e.g., "PV Inverter")
- Select your "ESP" device as device type
- Click "NEXT" and note down the encryption key (save it safely)
- Click "SKIP" for now - we'll add the configuration manually
- Create secrets file:
Create
secrets.yaml
in your ESPHome configuration directory:wifi_ssid: "YourWiFiSSID" wifi_password: "YourWiFiPassword" pv_inverter_api_key: "your-32-character-api-key" pv_inverter_ota_password: "your-ota-password" pv_inverter_fallback_password: "your-fallback-password"
- Click "EDIT" on your newly created device
- Replace the entire content with the configuration from
pv-inverter.yaml
- Click "SAVE" and then "INSTALL"
- Connect your ESP32 to your computer via USB
- Click "Plug into this computer"
- Select the correct COM port
- Click "INSTALL" and wait for the process to complete
- Click "STOP LOGS" when installation is finished
- Disconnect ESP32 from computer
- Connect RS485 converter according to wiring diagram above
- Power up the ESP32 (via USB power adapter or external power)
- The device should appear in Home Assistant automatically under Settings β Devices & Services β ESPHome
If you prefer using command line or don't have Home Assistant:
-
Install ESPHome CLI:
pip install esphome
-
Download Configuration:
wget https://raw.githubusercontent.com/Lewa-Reka/esphome-pv-inverter/main/pv-inverter.yaml
-
Create secrets.yaml:
wifi_ssid: "YourWiFiSSID" wifi_password: "YourWiFiPassword" pv_inverter_api_key: "your-32-character-api-key" pv_inverter_ota_password: "your-ota-password" pv_inverter_fallback_password: "your-fallback-password"
-
Flash to ESP:
esphome run pv-inverter.yaml
Parameter | Description | Default | Required |
---|---|---|---|
name |
Device name in ESPHome | depends on inverter type | No |
friendly_name |
Friendly device name | depends on inverter type | No |
device_description |
Device description | depends on inverter type | No |
modbus_controller_id |
Modbus controller ID | depends on inverter type | No |
modbus_inverter_address |
Modbus address of your inverter | 0x01 |
No |
baud_rate |
Baud rate for Modbus communication | 9600 |
No |
update_interval |
How often sensor values are updated from inverter | 5s | No |
Parameter | Description | Default | Required |
---|---|---|---|
safe_mode_delay |
Delay before activating safe mode when disconnected | 600s |
No |
default_maximum_battery_charge_current |
Maximum battery charge current in safe mode | 140 |
No |
default_max_sell_power |
Maximum power export in safe mode | 12000 |
No |
default_system_work_mode |
System work mode in safe mode | "Zero Export To Load" |
No |
default_solar_sell |
Solar selling state in safe mode | "on" |
No |
- UART Pins: GPIO17 (TX), GPIO16 (RX)
- Baud Rate: 9600
- Board: ESP32-DevKit v1 (configurable)
- Flow Control: Optional GPIO4 (uncomment if needed)
This project automatically integrates with Home Assistant through the ESPHome API. Once flashed and connected, you'll have access to:
- Solar Production: Panel voltage, current, and power for each string
- Battery: Voltage, current, state of charge, temperature, and charging status
- Grid: Voltage, current, frequency, power, and energy counters
- Load: Consumption data and UPS power information
- Inverter: Temperature, status, and operating parameters
- Work Modes: Selling First, Zero Export to Load, Zero Export to CT
- Battery Management: Charging current limits, cut-off voltages
- Time-of-Use: Programmable charging/selling schedules
- Power Limits: Maximum selling and charging power settings
- Generator: Control and monitoring (if connected)
- Automatic Safe Mode: Transitions to safe parameters when Home Assistant connection is lost
- Connection Monitoring: Real-time status of communication links
- Parameter Validation: Ensures all settings remain within safe operating ranges
- Emergency Access: Fallback WiFi hotspot for emergency configuration
The system includes comprehensive safety mechanisms:
- Connection Monitoring: Continuously monitors connection to Home Assistant
- Safe Mode Transition: Automatically applies safe operating parameters when disconnected for more than 10 minutes
- Parameter Validation: All settings are validated against safe operating ranges
- Fallback Access: Emergency WiFi hotspot with configurable password
- Hardware Protection: Modbus communication timeouts and error handling
- Solar panel performance (voltage, current, power per string)
- Battery status (SoC, voltage, current, temperature)
- Grid parameters (voltage, frequency, power flow)
- Load consumption (per phase and total)
- Inverter health (temperature, relay status)
- Daily/total energy production and consumption
- Battery charging/discharging cycles
- Grid import/export statistics
- System efficiency calculations
-
No Communication with Inverter:
- Check RS485 wiring (A+/B- connections)
- Verify Modbus address matches inverter settings
- Ensure correct baud rate (19200)
- Check modbus_inverter_address in configuration
-
WiFi Connection Issues:
- Verify SSID and password in configuration
- Check WiFi signal strength at ESP32 location
- Use fallback hotspot for emergency access
- Check router firewall settings
-
Home Assistant Integration Problems:
- Verify API key matches between configuration and Home Assistant
- Check ESPHome add-on logs for connection errors
- Ensure ESPHome add-on is running and accessible
- Verify network connectivity between devices
-
Sensor Reading Issues:
- Check ESPHome device logs for Modbus errors
- Verify inverter is powered and responsive
- Check for electromagnetic interference near RS485 cables
- Ensure proper grounding of RS485 converter
Enable verbose logging by uncommenting in pv_inverter.yaml
:
logger:
level: VERBOSE
Then check logs in ESPHome dashboard or Home Assistant ESPHome integration.
The configuration automatically updates packages from this repository every 12 hours. To force an update:
- In ESPHome dashboard, click "CLEAN BUILD FILES" on your device
- Click "INSTALL" to rebuild with latest packages
Contributions are welcome! Areas where help is needed:
- New Inverter Support: Modbus register mappings for other brands
- Feature Enhancements: Additional monitoring capabilities
- Documentation: Translations, setup guides
- Testing: Validation with different hardware configurations
- Fork the repository
- Create a feature branch (
git checkout -b feature/new-inverter-support
) - Make your changes with proper testing
- Update documentation as needed
- Submit a pull request with detailed description
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Copyright 2025 Lewa-Reka <lewareka.yt@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
This project uses ESPHome and related components. Please refer to the NOTICE file for additional license information.
Contributions are welcome! Please ensure all contributed code follows the Apache 2.0 license requirements.
- Solarman Stick Logger by David Rapan and pilipphenkel for inspirations
- ESPHome Team for the excellent home automation platform
- Home Assistant Community for continuous support and inspiration
- All contributors and testers who helped improve this integration
- GitHub Issues: Report bugs or request features
- Discussions: GitHub Discussions for questions and community support
- Home Assistant Community: ESPHome section for general ESPHome help
- HA-Solarman - Alternative WiFi stick integration
- ESPHome Official Docs - ESPHome documentation