Skip to content

ESP32 web-with MQTT

Latest

Choose a tag to compare

@mjpalmowski mjpalmowski released this 04 Jun 20:14
f0a84dc

There is one .BIN files in this realease,

A Web surface to control R48xx modules via CAN BUS,

New in this release:

MQTT credentials can be set in the WebApp directly, no need to get into the YAML. (mini update v099, fixed MQTT reconnect bug, no longer wiping credentials after 3 unsuccessful retries, now it retries every 5 minutes to reconnect to MQTT if it loses MQTT connection thanks @kr0815 for raising the issue)

But I have Homeassitant: you can use this .BIN file, just make sure that you have Mosquitto broker Add-on installed, the device will be auto-discovered and is visible as a device in the MQTT integration.

  1. Install the Mosquitto Broker Add-on:
    Go to your Home Assistant frontend.
    Navigate to Supervisor > Add-on Store.
    Search for and install the Mosquitto broker add-on.
    Start the add-on and ensure it's configured to start on boot.
  2. Configure the MQTT Integration:
    Go to your Home Assistant frontend.
    Navigate to Settings > Devices & Services.
    Select Add Integration and then choose MQTT.
    Follow the on-screen instructions to connect to the Mosquitto broker.

By default HA uses your HA user credentials to allow access to your broker.

What is Homeassistant?, I just want the new Web-App: Download the Web-App .BIN here

Here is the YAML if you would like to compile your own or to activate MQTT yourself or use the API

and upload it to an ESP32 WROOM32 dev board using this link:
https://web.esphome.io/

Screenshot 2025-06-04 211617

Make sure you have the following connected:

tx_pin: GPIO19==tx of the CAN tranceiver board
rx_pin: GPIO21==rx of the CAN tranceiver board

Once the firmware is on the ESP32, it will reboot and after 3 minutes it will
create a hotspot, now connect your PC/Phone to the hotspot "R48xx-off-grid"
12345678
once connected to the hotspot open your browser and go to
192.168.4.1
enter you wifi credentials, the esp reboots, the hotspot dissapears and stays gone if it can connect to your wifi, now you can find the web app at:
http://r48xx-off-grid.local/

connect the CAN-H to CAN-H and CAN-L to CAN-L , plug in your R48xxGx rectifier and happy charging :)

This release should be compatible with most Huawei R48xxxxx rectifier boards, it supports a single board.

Screenshot 2025-06-04 205431

R48xx Off-Grid MQTT Topic Reference

All entities publish their availability (online/offline) to r48xx-off-grid/status

Switches use: send on or off to command topic

Friendly name State topic Command topic
Soft Charge Enable r48xx-off-grid/switch/soft_charge_enable/state r48xx-off-grid/switch/soft_charge_enable/command

Buttons use: send PRESS to command topic

Friendly name Command topic
001 Can On Button r48xx-off-grid/button/001_can_on_button/command
002 Can Off Button r48xx-off-grid/button/002_can_off_button/command
18 Setup This Charger r48xx-off-grid/button/18_setup_this_charger_/command
Fan Auto Mode Button r48xx-off-grid/button/fan_auto_mode_button/command
Fan Full Speed Button r48xx-off-grid/button/fan_full_speed_button/command
Soft Charge 15s LFP Defaults r48xx-off-grid/button/soft_charge_15s_lfp_defaults/command
Soft Charge 16s LFP Defaults r48xx-off-grid/button/soft_charge_16s_lfp_defaults/command
Soft Charge Load r48xx-off-grid/button/soft_charge_____load/command
Soft Charge Save r48xx-off-grid/button/soft_charge_____save/command
Wh Meter Reset r48xx-off-grid/button/wh_meter_reset/command

Numbers use: send a number 50.4 to command topic

Friendly name State topic Command topic
10 Set Voltage Limit r48xx-off-grid/number/10_set_voltage_limit/state r48xx-off-grid/number/10_set_voltage_limit/command
11 Set Fallback Voltage Limit r48xx-off-grid/number/11_set_fallback_voltage_limit/state r48xx-off-grid/number/11_set_fallback_voltage_limit/command
12 Set Dc Current Limit r48xx-off-grid/number/12_set_dc_current_limit/state r48xx-off-grid/number/12_set_dc_current_limit/command
13 Set Fallback Dc Current Limit r48xx-off-grid/number/13_set_fallback_dc_current_limit/state r48xx-off-grid/number/13_set_fallback_dc_current_limit/command
14 Set Ac Current Limit r48xx-off-grid/number/14_set_ac_current_limit/state r48xx-off-grid/number/14_set_ac_current_limit/command
Fan Minimum Speed r48xx-off-grid/number/fan_minimum_speed/state r48xx-off-grid/number/fan_minimum_speed/command
Stage Reset Voltage r48xx-off-grid/number/stage_reset_voltage/state r48xx-off-grid/number/stage_reset_voltage/command
Stage Threshold 1 r48xx-off-grid/number/stage_threshold_1/state r48xx-off-grid/number/stage_threshold_1/command
Stage Current 1 r48xx-off-grid/number/stage_current_1/state r48xx-off-grid/number/stage_current_1/command
Stage Threshold 2 r48xx-off-grid/number/stage_threshold_2/state r48xx-off-grid/number/stage_threshold_2/command
Stage Current 2 r48xx-off-grid/number/stage_current_2/state r48xx-off-grid/number/stage_current_2/command
Stage Threshold 3 r48xx-off-grid/number/stage_threshold_3/state r48xx-off-grid/number/stage_threshold_3/command
Stage Current 3 r48xx-off-grid/number/stage_current_3/state r48xx-off-grid/number/stage_current_3/command
Stage Threshold 4 Balance r48xx-off-grid/number/stage_threshold_4_balance/state r48xx-off-grid/number/stage_threshold_4_balance/command
Stage Current 4 Balance r48xx-off-grid/number/stage_current_4_balance/state r48xx-off-grid/number/stage_current_4_balance/command
Stage Time Balance r48xx-off-grid/number/stage_time_balance/state r48xx-off-grid/number/stage_time_balance/command
Set Current Hour r48xx-off-grid/number/set_current_hour/state r48xx-off-grid/number/set_current_hour/command
Set Current Minute r48xx-off-grid/number/set_current_minute/state r48xx-off-grid/number/set_current_minute/command
Set On Hour r48xx-off-grid/number/set_on_hour/state r48xx-off-grid/number/set_on_hour/command
Set On Minute r48xx-off-grid/number/set_on_minute/state r48xx-off-grid/number/set_on_minute/command
Set Off Hour r48xx-off-grid/number/set_off_hour/state r48xx-off-grid/number/set_off_hour/command
Set Off Minute r48xx-off-grid/number/set_off_minute/state r48xx-off-grid/number/set_off_minute/command

Sensors

Read-only telemetry is published to the topics below (one per bullet):

  • 003 Power Stater48xx-off-grid/sensor/003_power_state/state
  • 01 Input Ac Powerr48xx-off-grid/sensor/01_input_ac_power/state
  • 02 Input Grid Ac Frequencyr48xx-off-grid/sensor/02_input_grid_ac_frequency/state
  • 03 Input Ac Currentr48xx-off-grid/sensor/03_input_ac_current/state
  • 04 Input Ac Grid Voltager48xx-off-grid/sensor/04_input_ac_grid_voltage/state
  • 05 Output Dc Powerr48xx-off-grid/sensor/05_output_dc_power/state
  • 06 Output Dc Currentr48xx-off-grid/sensor/06_output_dc_current/state
  • 06a Output Dc Current Altr48xx-off-grid/sensor/06a_output_dc_current_alt/state
  • 07 Output Dc Voltager48xx-off-grid/sensor/07_output_dc_voltage/state
  • 08 Output Temperaturer48xx-off-grid/sensor/08_output_temperature/state
  • 09 Max Output Dc Currentr48xx-off-grid/sensor/09_max_output_dc_current/state
  • 19 Scaling Factorr48xx-off-grid/sensor/19_scaling_factor/state
  • Fan Rpmr48xx-off-grid/sensor/fan_rpm/state
  • Info Barcoder48xx-off-grid/sensor/info__barcode/state
  • Info Board Typer48xx-off-grid/sensor/info__board_type/state
  • Info Descriptionr48xx-off-grid/sensor/info__description/state
  • Info Item Numberr48xx-off-grid/sensor/info__item_number/state
  • Info Manufacturing Dater48xx-off-grid/sensor/info__manufacturing_date/state
  • Info Max Current Capabilityr48xx-off-grid/sensor/info__max_current_capability/state
  • Info Operating Hoursr48xx-off-grid/sensor/info__operating_hours/state
  • Input Temperaturer48xx-off-grid/sensor/input_temperature/state
  • Local Time (Off-Grid)r48xx-off-grid/sensor/local_time__off-grid_/state
  • Minutes Until Next Onr48xx-off-grid/sensor/minutes_until_next_on/state
  • Minutes Until Next Offr48xx-off-grid/sensor/minutes_until_next_off/state
  • Wh Meter Consumed Whr48xx-off-grid/sensor/wh_meter_consumed_wh/state