Skip to content
Solarteur edited this page Nov 29, 2024 · 100 revisions

Huawei R4850G2 power supply

Using the Huawei AC charger in combination with the CMT2300A radio board (for HMT- HMS- Inverters) is supported as of the latest Firmware (stand: Sep.2024)
Please Note: Due to the fact that the ESP32 has only two SPI available, ONLY TWO OF THREE (NRF24, CMT23000, MC2515) modules can run simultanously.
The OpenDTU-OnBattery checks presence of the modules and allocates SPI to them in fixed sequence:

  1. NRF24
  2. CMT2300
  3. HuaweiCAN (MC2515)

If the OpenDTU-OnBattery finds a PIN definition in the config, it assigns one of the two available SPI.
If all three modules are present, the OpenDTU-OnBattery will allocate the first two with an SPI and the third will be denied, without hanging up.
If you have all three modules "present" on your PCB board, you need to disable one of them: Change your Pin-Out configuration and define with -1 the pins of the module you want to have disabled.


The Huawei Rxxxx lineup is a series of industrial grade power rectifier modules for professional usage. Their naming scheme is pretty straightforward:

  • R -> Rectifier
  • first two digits, e.g. 48 -> nominal voltage
  • next two digits, e.g. 50 -> maximum current
  • single letter -> Model line? There is at least G and N, from what I could find
  • last digit -> Generation number, e.g. 2

The R4850G2 model in particular became a favorite of some internet communities (like this one :-)) due to its high efficiency, the flexible (and really high current) CAN controllable output as well as the availability and price point (currently ~70-90€ for used units and around 120-150€ for new "old stock" ones from Aliexpress or Ebay/Kleinanzeigen). Only real downside is the internal cooling fan, which is temperature/load controlled, but still somewhat noisy (so, like most server room equipment, belongs to a rack in a separate room).

Warning: This power supply can output over 50A at most voltages, which will most definitely be a lot more than most batteries can handle! So double check your settings. Also, even though the output side is relatively low voltage, these are serious currents, so make sure that

  1. you understand, what you are doing
  2. appropriate circuit breakers, wiring and connectors are used
  3. the input side is also capable of delivering the corresponding AC power over numerous hours (a C13/C14 connector is only good for <10A!)
  4. enough air circulation/heat dissipation is possible
  5. additional measures are present to detect a malfunction, e.g. external monitoring (remember, this is all home-brew stuff, which might fail, hang or simply not work as expected anytime soon)

This being said, the Huawei unit itself was meant to work in network environments 24/7 for many many years, so it features high quality internal components, many internal monitoring circuits and several official certifications. In my opinion, this makes it a way better and safer option than most, if not any of the generic china-made power supplies available.

Operation modes

openDTU-onBattery supports three operation modes for the Huawei PSU:

  1. Fully manual - In this mode the PSU needs to be turned on/off externally using MQTT and voltage and current limits need to be provided. See MQTT Documentation for details on these commands

  2. Manual with auto power on / off - In this mode the PSU is turned on when a current limit > 1A is set. If the current limit is < 1A for some time the PSU is turned off. Current and voltage limits need to be provided externally using MQTT. See MQTT Documentation for details on these commands.

  3. Automatic - In this mode the PSU power is controlled by the Power Meter and information provided in the web-interface. If excess power is present the PSU is turned on. The voltage limit is set as per web-interface and the current limit is set so that the maximum PSU output power equals the Power Meter value. Minium and maximum PSU power levels as configured in the web-interface are respected in this process. The PSU is turned off if the output current is limited and the output power drops below the minimum power level. This will disable automatic mode until the battery is discharged below the start voltage level (set in the web-interface). This mode can be enabled using the web-interface and MQTT. See MQTT Documentation

CANbus communication with OpenDTU

For OpenDTU communication, a MCP2515/TJA1050 CAN shield is needed. This CAN bus operates at 125kbit/s.

Please note: Using the Huawei AC charger in combination with the CMT2300A radio board (for HMT- and HMS-inverters) is supported as of Firmware Version 2024.09.11

Please note that the smaller/cheaper 4-pin shields (SN65HVD230) used for Pylontech battery communication will not work!

MCP2515 CAN-Bus-Modul 2 - Copy

Since the ESP generally operates at 3.3V power level, these boards also need to be modified in order to output a 5V signal. This can be done by cutting through a circuit path at the back of the board, as documented in this discussion (more details here).
Please be careful not to scratch the surrounding area, otherwise you risk a short circuit to ground.

Umbau RICHTIG

Very IMPORTANT for users with ESP32-S3 boards: At its default form, the 5V Pin of the ESP32-S3 board is for Input current ONLY!
There is a Solder Bridge marked IN-OUT near PINs 11-12 which you must close, if you want to have 5V OUTPUT!
For more information: Important info for those intending to use the 5V as Output

If doing the modifications above is too complicated, with a little more money you can buy a ready made version with two voltage inputs, the Joy-IT SBC-CAN01 (available at AMAZON, Conrad, Reichelt and other online shops).
There are two versions of the Joy-IT SBC-CAN01 on the market, one has 8MHz clock and the other 16MHz clock. You have to manually select the MHz speed of your board in the setup menu.

Solved 8-16MHz

Why does it make a difference whether it clocks at 16 instead of 8MHz? It directly affects the baud rate. The MCP2515 chip only knows relative timing, i.e., its input clock. If that clock doubles while all else is the same, then it "speaks" at double the speed. The prescaler needs to be adjusted (doubled) for the 16MHz model. Probably the CAN driver can already be configured (be told what the quarz frequency is) such that the correct prescaler is set. Probably 8MHz is hardcoded somewhere in OpenDTU-OnBattery.

The pictures show a 16MHz quarz and a 8MHz quarz. There should either be an integer followed by M on the quarz (first picture), or a floating point number, which is in MHz as well (second picture).

a - Copy 8MHz A

After connecting the 5 pins to the ESPs GPIO, the mapping needs to be set. Easiest way is using a pin_mapping.json like this (updated to default values Oct.2023):

[
    {
        "name": "Huawei+Battery",
        "nrf24": {
            "miso": 19,
            "mosi": 23,
            "clk": 18,
            "irq": 16,
            "en": 4,
            "cs": 5
        },
        "huawei": {
            "miso": 12,
            "mosi": 13,
            "clk": 26,
            "irq": 25,
            "power": 33,
            "cs": 15
        },
        "victron": {
            "rx": 22,
            "tx": 21
        },
        "eth": {
            "enabled": false
        },
        "battery": {
            "rx": 27,
            "tx": 14
        }
    }
]

Note: Even if you do not plan to use it, the huawei.power needs to be set to an unused GPIO pin, otherwise communication won't work.
Also, the terminating resistor (jumper next to the CANH/CANL output) needs to be set.
The physical connection to the power supply CAN terminal can be done using simple twisted wire ("Klingeldraht"), as long as the distance isn't too long.

Wiring_ESP32_HUWAI ONLY - 5V3 3V

As mentioned previously the Joy-IT SBC-CAN01 has two power inputs, VCC1 and VCC The manual shows a voltage differentiation when connecting the board to a RaspberryPi vs Arduino

Difference Arduino Raspberry - Copy

  • VCC1 is the power of the board and the CAN controller (always 5V).
  • VCC is Input/Output power of the Boards.
  1. Since the RaspberryPi uses a 3.3V-basierter SoC, it should handle only 3.3V on its Pins (MISO, MOSI, etc.).
  2. Arduino-Boards on the other side, work with 5V logic.
  3. Subsequently, the ESP32 board should imitate the RaspberryPi configuration. Tests have shown that, temporarily VCC can work with 5V, althouhg it is not advisable long term.

Starting/Stopping the Huawei AC PSU

Turn PSU on - No Precharge

So, the easiest way is:
You can do a solution yourself but, there are ready-made "connectors" to plug into the back of the R4850. There are two versions, only difference is the AC connection, here is an example
Huawei R4850 Connector
Connect to start

Note: If you use a connector mentioned above, you will also need one male and one female JST SM 2Pin connector for "Slot detect" und "CAN", here is an example:
Huawei R4850 JST SM 2PIN

bf4ed's short and precise explanation:

Example bf3ed - Copy

  • Big Blue cable minus (-48V) goes to COM (COMmon)

  • Small Blue and small orange cables SlotDetect1 and SlotDetect2 go to NO (Normally Open)

This of course makes the fan keep turning and it is noisy... (the guy who designed this fan should be barred from entering Paradise... On the other side this is an industrial 24/7 system not designed for home use so do not complain).


With OpenDTU-OnBattery you have the possibility to make use of the "Power GPIO" to turn OFF the HUAWEI when it is not used and turn it ON when there is enough solar power.

OpenDTU-OnBattery uses the Power GPIO as follows:
Power is LOW when Huawei has to be active/ON
Power is HIGH when Huawei has to be inactive/OFF

It will be further discussed below but, keep in mind if you use a relais with High/Low trigger and NC (normally closed)/ NO (normally open):
You need to set your relais to HIGH TRIGGER and connect your HUAWEI cable to the relais at NC NORMALLY CLOSED

There are at least three possibilities to use "Power GPIO" with:

  • The easiest option was mentionned by members Solarteur, Knopers1 and Andreas70: The use of an Optocoupler!
    As there are no serious currents when connecting the minus 48V with SlotDetect1 and SlotDetect, you can use a simple 1,70EUR Optocoupler (3V-5V).
    Input-side: "Input+" connect to +3,3V or +5V. The "Input-" connects to "Power GPIO". This way it works as LOW TRIGGER.
    Output-side: connect "Slot detect" to "OUT" and "Huawei -48V" to "GND", "VCC" stays unused.

Anleitung Optokoppler setup Wiki

  • Second option is to use a mechanical relay 3.3V or 5V
    Although there is no confirmed proof yet, there is risk, if the mechanical relay draws too much power from the ESP32 while closing, the sudden draw of power may cause problems to your ESP32.

Relais 3 3V   5V - High-Low Trigger

Relay NO (Normally Open) / NC (Normally Closed) / High/low level trigger

CaCu15 was kind enough to write some explanations:
It is important whether you connect the two SlotDetect lines to NC or NO.
This decides how the relay establishes a connection:

  1. If you connect them to NC (normally closed), then there is a connection between COM (-48V) and the two SlotDetects when there is NO voltage at the signal PIN. If then the ESP applies a voltage to the SignalPIN, then the relay switches and then COM (-48V) is no longer connected to the SlotDetects.

  2. If you connect the SlotDetect to NO (normally open), then it is the other way round: If there is no voltage at the SignalPIN, then there is no connection between COM (-48V) and the SlotDetects. Only if the ESP applies a voltage at the SignalPIN, then the relay switches and establishes a connection.

This behavior is controlled by a jumper at many relays - in the pictures above, this is the case for the red relay: The jumper "High//Low Level Trigger Selection" controls when the relay closes.
"High" means that the relay closes (i.e. makes a connection from COM to NC) when there is a voltage difference between signal and GND/Minus.

  • A third option is to use a Solid State Relais (S.S.R.) as the later has no mechanical parts thus draws less power.
    Solid State Relais S S R  ist besser - Copy

The Solid State Relais is definitively better than using a mechanical relais.

WARNING: The relay in the picture above has HIGH TRIGGER and no NC/NO capability and is for illustrative purposes only!
You need to a relay that is either: LOW TRIGGER! Alternatively, you can use a HIGH TRIGGER which you can set to NC (normally closed) so that, when it receives the HIGH TRIGGER from the Power GPIO, it will OPEN (stopping the HUAWEI)

Here is an example of a LOW TRIGGER module:
Solid State Relais S S R  LOW LEVEL Triggeer

Trigger Modul des niedrigen Niveaus:
0-1.5VDC Relais ist eingeschaltet ist (auf)
3-5VDC Relais ist aus (aus)





IMPORTANT: The example below shows an older ESP32 Version with 4MB Flash memory and mechanical relais. Since the second quarter of 2024 we strongly recommend to new users to procure the new version ESP32-S3 which has 8/16/32 MB Flash (many models available) because soon the OpenDTU-OnBattery Firmware will exceed the memory capacity of the normal ESP32 4MB boards. The GPIOs of ESP32-S3 boards can have differences compared to the ESP32 board graphic below. For example, on some ESP32-S3 boards, GPIO 22 and 27 are not available (or used internally). IF you allocate Pins that are not available on your ESP32-S3, your board will *FREEZE* when you activate the corresponding option

Wiring_ESP32_Symbol - Victr1Victr2PylontechHuaweiRelaisCMT2300updRJ45

Other observations:

  • When disconnecting from AC power, the PSU will spin the fan at full speed for several seconds. Don't be afraid!
  • When CAN communication is lost, the warning LED on the front flashes and the PSU will use customizable fallback ("offline") output values, so if you set these to 0 amps, it will stop charging altogether
  • Even if AC power is lost, the CAN communication will be fed from DC if a power source is connected there. This is nice if additional control is present, e.g. using a Tasmota switch to shutdown the PSU during no load scenarios (helps with idle consumption and fan noise at night). Power consumption in this situation (Huawei is switched-off via slot-detect) is around 15W. This means your battery will discharge at approx. 0,35kWh per day.

Blog / Forum references:


Clone this wiki locally