CAN-BUS-control-R4875G1-with-ESPHome-and-MQTT
Control one or more R4875G1 R4875G5 R4830G2 R4850G2 R4850S1 and adjust Current and Voltage Parameters on HUAWAI R4875G…
git clone https://github.com/mjpalmowski/CAN-BUS-control-R4875G1-with-ESPHome-and-MQTT.gitmjpalmowski/CAN-BUS-control-R4875G1-with-ESPHome-and-MQTTProject Overview
Up-cycling industrial equipment provides a sustainable way to reuse highly reliable components. Mobile-network cell-tower gear is built for 24 × 7 operation in harsh environments, so it is compact, efficient and remarkably resilient.
This project centres on the Huawei R4875G1 48 V Rectifier Module. Designed to power base-station loads and battery banks, it can be trimmed from 45 V to 58 V and happily tolerates a “dirty” AC generator or weak grid. The module is 97 % efficient, delivers up to 4 kW, includes short-circuit and surge protection, speaks CAN bus, and boasts an MTBF of 500 000 h.
A well-designed and powerful battery charger.
The ESPHome firmware presented here runs on an ESP32 development board linked to the rectifier through a VP230 (SN65HVD230) CAN-bus transceiver.
Key Features
NEW: MQTT support in web-app, see latest release.
Supported Hardware
- R4875G
- R4850G
- R4830G
Parallel Operation (up to three r48xx units, one ESP32 controller)
- Join CAN-H lines
- Join CAN-L lines
- Wire DC outputs in parallel
Supported Sensors
- Power State — ON / Hibernate / Error
- AC Power In
- DC Power Out
- Grid Frequency
- Input Current
- Output Current
- Input Grid Voltage
- Output Voltage
- Set Maximum Output Current
- Set Maximum Output Voltage
- Output Temperature
- FAN RPM (model-dependent)
- Total Operating Hours
Configuration Settings
- CAN Voltage Set
- CAN Amp Set
- Fallback Amp Set
- Fallback Voltage Set
- Simple Daily Charge Timer
- CAN Max AC Amp Set (model-dependent)
- Cooling-Fan PWM Control (model-dependent)
- Low / High Voltage Set (auto wake / hibernate)
Control Buttons
- CAN ON (wake-up)
- CAN OFF (hibernate)
- Fan Full Speed
- Fan Auto Mode
Additional Features
- Over-temperature Shutdown — YAML-configurable, no Home Assistant required
- Daily kWh Energy Meter supplied DC energy
- Board-Type Auto-Detect
- Manufacturing-Date Auto-Detect
- Serial-Number Auto-Detect
- Scaling-Factor Auto-Set
🔋 Soft-Charge (balance charging)
- Charger tapers max current smoothly to avoid high-current BMS trips
- Balance phase current and duration are adjustable
- Auto-hibernate once balancing completes
| Conventional charging of an unbalanced pack | Soft-Charge of an unbalanced pack |
|---|---|
| Full current right up to 100 % SOC → repeated disconnects | Current tapers, e.g. 25 A → 15 A → 10 A → 2 A |
| Cells get only minutes of balance time | Final stage at e.g. 0.5 A for up to 300 min |
| Bad vibes & stress to BMS and Battery | Safely restore pack balance |
The voltages in the "soft-charge" section act as triggers that reduce the charge current when the battery approaches full capacity.
The actual final charge voltage is set here: "10 Set Voltage Limit".
For example, if you set 54.75V as your "Set Voltage Limit", the charger will work towards that voltage at the configured current (12 Set DC Current Limit).
As the output voltage approaches the steep end of the voltage curve, it triggers the "soft-charge" algorithm at the specified voltages to gradually reduce the charge current.
The final trigger also starts a timer, allowing you to define how long the battery should remain in the balancing phase. Once that period has elapsed, the charger switches off.
It is important to note that drawing power from the battery during soft charge is not ideal. While it won’t damage the battery, it is recommended to disable soft-charge if the battery is in use while charging.
For optimal results, perform soft charging when the battery is not under load.
Use Cases
Ideal for 15 s/16 s LiFePO₄ and 14 s NMC home battery systems, generator-backed solar, fast e-bike charging, marine DC systems and even clean-supply HAM-radio amplifiers. Turn your ESS into a double conversion UPS and achieve true zero grid backfeed. Eliminate the need for a transfer switch. Here is Node-RED flow that modulates R48XX charge power depending on surplus solar power. The R4875G can also accept high voltage DC (~400VDC) as input voltage, so could be used to feed a 48V inverter from a high voltage traction battery. The project could also be used as a starting point for an EVSE-facing onboard charger.
Commercial products such as the EG4 Chargeverter are essentially two telecom rectifiers in a box—this project offers an open, automation-friendly alternative.
Hardware Setup
Bill of materials
| Item | Notes |
|---|---|
| ESP32-WROOM dev board | On-board CAN controller |
| VP230 (SN65HVD230) CAN-bus transceiver | 3.3 V logic |
| R4875G1/G5 edge connector | Available via AliExpress |
| 8 AWG silicone DC leads | 40 A continuous |
| 16 A-rated AC leads | 230 V single-phase |
| CAN bus twisted pair | White = CAN-L, Black = CAN-H |
Powering the ESP32
Supply via USB or a 60 V → 5 V buck regulator if the battery is permanently connected.
Quick Start
Flash the latest pre-compiled .bin from the releases page using the ESPHome web-flasher, power up, and follow the on-device wizard.
Manual Pad-Jump Start (without adapter board)
- Pin 1 → Pin 5
- Pin 1 → Pins 11 & 12 (connect Pin 11 and Pin 12 to DC-)
- Pin 9 ↔ Pin 10 connecting these two pins enables the full 75 A limit (otherwise limited to 53 A)
Software Configuration
Create a new ESPHome device in Home Assistant (or use standalone web control). Uncomment the mqtt:, api: or webserver: blocks as required. Multi-unit and three-phase YAML examples are provided in the repo.
Latest YAML sample: v0.98.YAML
2x R4875G1 YAML sample: R48xx_autoSet_fullFanCTRL_AC_currentCTRL.YAML
The easy way: Ready-compiled .BIN file and instructions on how to upload to the ESP32 are here.
If you are totally off-grid, no wifi, no cellular connection, no internet, use this version.
If you are developing a portable or on-board fast-charger, this version is also suitable.
MQTT Topics
Click to expand topic listings
Text Sensors
r48xx-off-grid/sensor/003_power_state/state — Charger ON/OFF/Error
can-bus01/text_sensor/charger_power_state2/state
Sensors
can-bus01/sensor/ac_power_in/state — AC Power In
can-bus01/sensor/dc_power_out/state — DC Power Out
…and many more, see full list in repository
Numbers
can-bus01/number/can_voltage_set/state — Voltage Set
can-bus01/number/can_amp_set/state — Current Set
etc.
Buttons (send the string PRESS to command topic)
can-bus01/button/001_can_on_button/command — Wake-up
can-bus01/button/002_can_off_button/command — Hibernate
can-bus01/button/fan_full_speed_button/command — Fan 100 %
Number Commands
can-bus01/number/10_set_voltage_limit/command — 49 – 58 V
can-bus01/number/14_set_ac_current_limit/command — 0 – 21 A
etc.
Additional Resources
- Huawei R4875G1 CAN protocol spreadsheet
- Beyond Logic review of Huawei rectifiers
- DIY Solar Forum discussion
- Full user-manual PDFs for R4875G1/G5, R4850G2, R4830G2 are linked in the repository.
more like this
PowerDisplayESPHome
A small display for ESPHome and Home Assistant to retrieve the current house consumption and energy price via a sensor…




