Riden RD6006 DC power supply HA support (wifi)

Hi, recently I bought RD6006 power supply with wifi option and discovered that the official app for wifi control is totally useless :smiley: So I dig deeper on how can I control this power supply and discovered that this power supply uses Modbus (on the serial port communication). This project helped me with registers description:
https://github.com/Baldanos/rd6006

*EDIT: This method (rest of this post) is OBSOLETE NOW !!! *

As Esphome can decode modbus now, I updated the method of communication to use simply ESP8266 with esphome. It is much easier to use. See post with updated code below

Rest of the original post follows:

The power supply has 3 options for communication: You set desired mode in menu

  1. USB (front USB port). It has some serial to USB bridge inside
  2. Wifi - it communicates over UART with wifi module (ESP8266) connected to the pinheader inside the machine
  3. TTL. It uses the same pinheader as wifi module but sends raw data directly. (With wifi mode it communicates and configures the ESP8266). This option is for RS485 module but they don’t sell this yet. This TTL is what I want!

So I took the original wifi board and used heat gun to desolder the original ESP8266 chip. ( I stored it in case I will ever want to revert to original wifi solution. If you know you don’t want original wifi solution, just flash it with ESP-link firmware directly and you don’t need to solder anything)
I then took another ESP board and flashed it with ESP-link, desoldered the ESP module and soldered this one in place of the original to the power supply.

I had to do small modification to the wifi board - I snipped one pin from the pinheader (EN-Enable) so it does not make contact with the power supply and soldered 1k resistor between EN and 3.3V. It is done because the PS enables wifi module only in “wifi mode” but I need it to run in “TTL mode” as well.

I configured the ESP-link to 9600bps serial baud and of course put credentials for my local wifi network.ESPlink got IP 192.168.50.60 which we use later in HA config

Ok, now lets get to the HASS config:
////See my post below for updated config - there was change in modbus integration in home assistant so the configuration is different now

First we need to configure modbus in general:
configuration.yaml:

modbus:
  name: hub1
  type: rtuovertcp
  host: 192.168.50.60
  port: 23

then we create multiple sensors to read values. Here I read input voltage, output set voltage+current and actual readback voltage and current. Also very important switch to enable/disable output
also configuration.yaml:

sensor:
  - platform: modbus
    scan_interval: 10
    registers:
      - name: RD6006_voltage_input
        hub: hub1
        unit_of_measurement: V
        slave: 1
        register: 14
        scale: 0.01
        precision: 2

      - name: RD6006_voltage_set
        hub: hub1
        unit_of_measurement: V
        slave: 1
        register: 8
        scale: 0.01
        precision: 2
        
      - name: RD6006_voltage_output
        hub: hub1
        unit_of_measurement: V
        slave: 1
        register: 10
        scale: 0.01
        precision: 2
        
      - name: RD6006_current_set
        hub: hub1
        unit_of_measurement: A
        slave: 1
        register: 9
        scale: 0.001
        precision: 3
        
      - name: RD6006_current_output
        hub: hub1
        unit_of_measurement: A
        slave: 1
        register: 11
        scale: 0.001
        precision: 3

switch:
  - platform: modbus
    registers:
      - name: RD6006_output
        hub: hub1
        slave: 1
        register: 18
        command_on: 1
        command_off: 0

Also create input number sliders/input boxes:

input_number:
    rd_voltage:
        name: RD6006 voltage config
        initial: 0
        min: 0
        max: 60
        step: 0.01
        mode: box
    rd_current:
        name: RD6006 current config
        initial: 0
        min: 0
        max: 6.2
        step: 0.001
        mode: box

Now lets switch to automations.yaml to be able to configure the voltage and current:

- id: rdvoltsettings
  alias: RD 6006 Voltage settings
  trigger:
    platform: state
    entity_id:  input_number.rd_voltage
  action:
  - service: modbus.write_register
    data_template:
      hub: hub1
      unit: 1
      address: 8
      value: '{{ states.input_number.rd_voltage.state | multiply (100) | int }}'


- id: rdampssettings
  alias: RD 6006 Current settings
  trigger:
    platform: state
    entity_id:  input_number.rd_current
  action:
  - service: modbus.write_register
    data_template:
      hub: hub1
      unit: 1
      address: 9
      value: '{{ states.input_number.rd_current.state | multiply (1000) | int }}'

Now I had working readout, switch on/off but was not able to configure output voltage/current. It took me some time but I discovered somebody else had similar issues of modbus.write_register writing multiple registers at once. So when I configured voltage it “overflowed” to next register (output current).

More info on this here:
https://community.home-assistant.io/t/modbus-integer-write-out/11989/7

Long story short: I donwloaded all files from https://github.com/home-assistant/home-assistant/tree/dev/homeassistant/components/modbus , put them to \config\custom_components\modbus\ and modified init.py Line 75
from:

 vol.Required(ATTR_VALUE): vol.Any(
            cv.positive_int, vol.All(cv.ensure_list, [cv.positive_int])
        ),

to:

        vol.Required(ATTR_VALUE): vol.Any(cv.positive_int),

Now it is working fine. If you want you could easily add more settings/sensors to your config (temperature, brightness settings, CC/CV indicator…) . Just see https://github.com/Baldanos/rd6006/blob/f04b2637193a02121c461e1f2512837dded6db83/registers.md for all the registers

Here is my very basic setup:

rd_control_voltage

The only drawback is that there is no option to disable modbus communication - the sensors are read every X seconds. And the power supply locks controls (buttons) for few seconds while it communicates. It is pretty bad if you want to use it only directly without any remote commands. So the easiest solution that occured to me is to change baudrate in the power supply to some other than standard 9600 so it won’t be able to communicate. And later if you want to enable communication again, just set it back to 9600. Or you can set different baudrate in ESP-link. This could be maybe done with some script from HA. Hmm… :nerd_face:

Future project (as this is simple UART) - add communication over 433MHz LoRa wireless link to achieve long range transmissions and be independent on the wifi. I already have some modules and it is working. Module is connected directly (USB-serial bridge) to rPi running HA (and modbus hub is configured to serial mode) . But I need to make it more integrated - for example I need separate DC/DC 5V supply as the 5V rail in RD6006 does not have enough current capability. And some proper antenna mount to the back of the RD6006

7 Likes

Well done. But may I ask: WHY!?! What’s the benefit? I have the device as well, but…

Well I did this because the official wifi control app was totally useless and terrible. (if you have the device you know what I am talking about)

If you are questioning why somebody needs remote control for power supply? Well I can think of multiple reasons. Maybe not so much if you use this power supply in the “lab supply mode*” on your desk but if you are using it more like “industrial”. For example I use it for charing car battery and other various types of batteries. I like I can see the current from my computer/phone as I charge them in garage. And as a bonus I have nice graph how the current is dropping as the battery is more and more charged.

Or I used this for testing water circulation pump - I had simple automation that monitored water temperature and if it dropped and the day time was right it briefly turned the pump on…etc…etc…Sure this is not the ideal device for permanent installation but for development and debugging it is great!
Or maybe another reason - for example I want to test how my laser pointer looks few kilometers away. But I don’t want to have it on all the time. So I wire the power supply instead of batteries and use my phone to remotely switch it on when I am few kilometers away. Sure you can have arduino with relay but this in nicely versatile device.

*Even in the lab supply mode it can be useful for some testing - like switch on, wait 5 seconds, switch off. Or do some more advanced stuff like switch on at 5V, increase to 8V, decrease to 5V etc etc…It can be interconnected to other devices (thermometer…) like for example if you are trying to find some bug in electronic design of some device you want to power cycle it X times but if the temperature exceeds something then wait X minutes before another test etc etc…sky is the limit :wink:

1 Like

Thanks for write-up @Atlantis! I successfully used this to switch over to ESP-link as the native approach is very unreliable.

Have you figured out how to unlock the “local” controls without manually changing the baud rate? I tried to use esp-link’s MQTT option to send a message to change the baud rate, but was not able to get it to work.

THIS POST IS OBSOLETE ASWELL - here the modbus is still processed inside the HA. NOT ESPhome which is much better idea. Look further down for more info

Hi, followup update.
At home assistant version core-2021.6.0 there was change in modbus integration’s configuration that forced new style of configuration. Now the modbus config is more unified together. Also the “hack” of using custom components is no longer needed.

(If you are wondering why I have “type:serial” - I have USB-serial converter plugged directly to rPi. And this serial converter is connected to wireless module at 433MHz. And there is another 433MHz module at the power supply.
New config for RD6006 is as follows:

modbus:
  - name: hub1
    delay: 2
    type: serial
    baudrate: 9600
    timeout: 10
    method: rtu
    parity: N
    port: /dev/ttyUSB0
    stopbits: 1
    bytesize: 8
    close_comm_on_error: true
    switches:
      - name: RD6006_output
        address: 18
        slave: 1
        command_on: 1
        command_off: 0
        verify:

            
    sensors:
      - name: RD6006_voltage_output
        scan_interval: 120
        slave: 1
        address: 10
        scale: 0.01
        precision: 2
        unit_of_measurement: V
      - name: RD6006_current_output
        scan_interval: 120
        slave: 1
        address: 11
        scale: 0.001
        precision: 3
        unit_of_measurement: A
      - name: RD6006_capacity
        scan_interval: 120
        slave: 1
        address: 38
        count: 2
        scale: 0.001
        precision: 3
        unit_of_measurement: Ah

The only issue I have now is that the “switch” does not read back the actual status of the power supply. So when I use physical button on the power supply to turn off, the change won’t propagat to home assistant.

Another useful discovery I made is there is unofficial firmware for these power supplies! The main advantage is the buttons won’t lock while remotely communicating with the power supply + it has many more added features. More info and manual how to flash in this thread :slight_smile:
https://www.eevblog.com/forum/testgear/custom-firmware-reference-document-for-riden-rd60xx-power-supplies/

and this thread RuiDeng Riden RD6006 DC power supply - Page 25

For those of you who do not want to reinvent a bicycle they offer a rs485 board which is to be fitted instead of WiFi board for 10$ shipment included and you can use direct Modbus access no problem. The feature is available for RD6006 and RD6018 models at the moment.

Enjoy!

I want to flash esp-link but I can’t get it to flash, just

A fatal error occurred: Failed to connect to Espressif device: Timed out waiting for packet header

Do I have to do something with the EN pin? I would prefer to not have to de-solder/swap the ESP12F like @Atlantis

EDIT: Never mind, You have to ground R6 (inner side towards connector, not towards edge of board) and reset (R5), then you can let go of both, bit finicky but its fairly safe, with esptool.py --connect-attempts 0 helps a lot.

Highly recommend anyone trying this back up the stock image first esptool.py --connect-attempts 0 -p /dev/ttyUSB0 -b230400 read_flash 0x0 0x400000 original_fw_4m.bin

And this is what I used to flash it esptool.py --connect-attempts 0 --port /dev/ttyUSB0 --baud 115200 write_flash -fs 32m -ff 80m 0x00000 boot_v1.7.bin 0x1000 user1.bin 0x3FC000 esp_init_data_default.bin 0x3FE000 blank.bin

EDIT2: What should I set for pins in the UI

Since I really wanted wireless functionality, I started going the ESPHome route and flashed the WiFi module that comes with the RD6006-w. It can now chat modbus and talk to Home Assistant:

I really like the functionality ESPHome brings by abstracting away all the logic, it needs some more functionality though, so feel free to chip in.

1 Like

Good job. I was thinking about re-writing this whole control into ESPhome since I saw in ESPhome’s changelog they added modbus support. Processing this whole modbus logic directly in ESP module inside the power supply is definetly better than transmitting raw messages over the network

Sadly the modbus was not available at the time of my forst post into this topic :roll_eyes:

1 Like

First I strongly recommend using the alternative firmware @wildekek mentioned in his github post (or in my post few posts above). It has many nice features. Specially one that is strongly needed for remote control: you can avoid locking local keypad while it communicates - it means you can plot graphs of voltage/current… and still be able to locally control the power supply.

Second nice feature is to enable wifi module with “TTL settings” - it means you don’t have to do any hardware hacks with snipping enable pin and soldering it to 3.3V. You just set in the menu communication option “TTL with EN” and the wifi module will work.

I finally got myself to re-flash all my RD6006 supplies to ESPhome (as I mentioned in original post, I started with this project in the time when esphome couldn’t decode modbus directly so the decoding was done in home assistant and raw serial protocol was transmitted)

But I struggled with one problem - the modbus controller updates itself only once per minute. Which is quite bad if you are switching the power supply ON and waiting for current/voltage readout…

EDIT: just put “update_interval: 10s” under modbus_controller

modbus_controller:
  - id: ...
...
    update_interval: 10s

I couldn’t find command to change the update time so I dug bit deeper
1. Download esphome files (whole zip file) from github https://github.com/esphome/esphome
2. Locate file \esphome-dev\esphome\components\modbus_controller_init_.py
3. Open the file and locate line 110 with content .extend(cv.polling_component_schema("60s"))
4. change the 60s to “your desired update interval” - I set it to 10s for now
5. save file
6. Now take the whole esphome-dev\esphome\components\modbus_controller\ folder and copy it into your machine where the esphome lives. In my case it was \\ip_of_my_home_assistant\config\esphome\components\ (if the folder “components” does not exist yet → create it)
7. sanity check: your folder structure looks now like this: config\esphome\components\modbus_controller\__init__.py
8. Almost done!
9. Now open your config file for your RD6006 board and place there a command to use your edited files instead of default ones:

</s> <s>external_components:</s> <s> - source:</s> <s> type: local</s> <s> path: components</s> <s> components: [ modbus_controller ]</s> <s>
…And done, recompile and reupload your config to ESP and now it updates every 10seconds.

If anybody has better/cleaner idea how to change the update time please post it here. I honestly couldn’t find one…

Hi, this project is exactly what i was looking for so long: To make the Riden RD6006 fully/automatically controllable via “Home Assistant” or in my case “iobroker” makes it the perfect regulated/adaptive solar-charger for my small 600W grid-tied balcony solar plant. The Riden will only charge the amps in the battery which i do not use otherways.

This solution seems to fit perfectly for my needs, if i get this working: In germany, when my solar panels generate more electricity than i need for my own you gift that energy for free to your local power company. - You get nothing for the produced energy in exchange (from the power company), so of course a bad deal if i am not at home and 400-500W are gifted to the power company the whole day (when the sun is shining).

I installed a shelly 3EM power meter months ago, which tells me exactly how much energy i produce that i do not use and gift to the energy company (The overall power consumption will drop to negative value at the shelly 3EM). - So i was looking for a battery charger which i can automatically feed with that negative wattage value (i overproduce), which will adopt the charging speed / amperage to whatever i have left over. - I also have a 2,4 kwH lifepo4 24V battery, which i can charge with 29,2V and up to 20A. - But normaly it will be the range 29,2V and 2A up to 6A, because my solar panels are not producing that much energy ro reach 20A. (Yes, it is unfortunaltely an AC-storage and not a more efficient DC-one, because i am a tennant at a flat and not allowed to drill holes / put new DC-power cables all over the place) - The battery safety is managed by the battery-integrated BMS (battery-management-system), so the safety is not handled by the Riden power supply, this is the job from the BMS of the lifepo4 battery. - The Riden has only deliver the power defined by iobroker / home assistant / Shelly 3EM.

I copied your last “optimized” code to my ESPHOME config in home assistant 8.5, but there is an error message that modbus requires component “uart”. - When i add a line “uart:” it wants baud_rate and RX and TX pins from me, if i add that too nearly all modbus entries from your last comment go to error state !? - I edited a lot but not get a working config, but i have to admit that i am not that familar with esphome at all ( I have an Espressif ESP-01 with esphome freshly setup which should perfectly replace the whole wifi module which came with the Riden, i guess!? (I have also some Wemos D1 Mini, but they do not have the connector pins which will fit to the riden socket: The Espressif ESP-01 module has these pins.) When i got the modbus script above working, I only have to flash the modded Riden firmware which makes me enable the “TTL with EN” mod, so i don’t have to cut off the EN pin and put in a resistor !?).

But at the moment my main problem is, that your modbus yaml code example above does not to work anymore / there are a lot of errors in the YAML, with latest ESPHOME / Home Assistant 8.5 version.

So, if someone can give me hint how to get the above code running again, this will help me a lot.

In my case the final solution will be a iobroker blockly script which will read the values from the shelly 3em all 10 seconds and control the charge amperage of the Riden RD6006 to whatever it needs to get the best charging speed with the left-over solar energy (Will add a negative 50W safety buffer, to make sure the battery will never be charged from the grid, only from solar power).

1 Like

Hi, sorry about the mess. I forget to mark the post you find as obsolete aswell - that was still back in the time when modbus was decoded in HA, just different way due to update. That is why it is not working. Go more down the thread, you will find post from @wildekek and his github. Sorry I am on phone now so won’t post my exact config I use

Hi, after hours and hours of try and error i have now everything up and running in “HomeAssistant” with my Riden RD6006 and the “wildekek” esphome script. - Unfortunately I am not a “HomeAssistant”-server user, instead my whole smart home is managed by “iobroker” and i have just installed the HomeAssistant server to try the wildekek script.

It would be great if i would be able to use the Riden RD6006 esphome-connection directly with iobroker instead of “HomeAssistant” because it seems a bit odd to just have to run a whole homeassistant server just for the single purpose of be able to control the riden RD6006 power supply.

But i guess i perhaps have to ask in the iobroker forums for that, or does somebody have a hint how to reach that goal, having the wildekek esphome RD6006 in iobroker without an homeassistant server at all !?

Well if you only want remote config, you can just enable ESPhome’s internal webserver and just connect to the IP address using web-browser. It tried this and it works. On the other hand ESP8266 might not be powerful enough to be reliable over longer time - You can try how it behaves…
[Web Server Component — ESPHome]

As i want to use the Riden RD6006 as a smart solar charger for my 2,4kwh lifepo4 24V battery, i want a fully automated “current”-setting of the RD6006 by iobroker. - So i can set a static charge voltage of 29,2V and adapt the charging current to whatever energy value i have left unused from my generated solar power. - So a manual setting method is not useful, but as soon as there is a way to set current by MQTT or HTTP url, or whatever automated, we have a solution.

Meantime i did some more hours of try and error, and yesterday i get the “ESPHOME”-adapter also running inside iobroker and can connect to the Riden RD6006 wildekek esp. - But i see only some “static” values and i am far away of setting the current from within iobroker :frowning:

When i first add the wildekek-esp to iobroker there was an error message saying:

Cannot read properties of undefined (reading 'deserializeBinary') 

The ESP was added to iobroker and i see some objects, but no real values from the Riden RD6006 inside iobroker:

And in the log files of the ESPHOME-adapter inside iobroker i see the error:

esphome.0

	2022-09-14 22:20:47.978	error	ESPHome client 172.16.50.58 TypeError: Cannot read properties of undefined (reading 'deserializeBinary')

esphome.0

	2022-09-14 22:20:47.960	error	ESPHome client 172.16.50.58 TypeError: Cannot read properties of undefined (reading 'deserializeBinary')

esphome.0

	2022-09-14 22:20:44.934	warn	Client 172.16.50.58 Timeout, connection Lost, will reconnect automatically when device is available!

esphome.0

	2022-09-14 22:20:39.945	error	ESPHome client 172.16.50.58 TypeError: Cannot read properties of undefined (reading 'deserializeBinary')

esphome.0

	2022-09-14 22:20:39.940	error	ESPHome client 172.16.50.58 TypeError: Cannot read properties of undefined (reading 'deserializeBinary')

I posted this problem in the iobroker community forums, too. - But as they do not know the wildekek esphome YAML it seems there is no one able to assist with that kind of problem.

Edit: It seems the iobroker esphome adapter does not support the type “number” in the YAML script. - As soon as the ESPHOME adapter for iobroker sees a “number”-type in the YAML it crashes. - So if there is a way to have a wildekek-kind of yaml script which doesn’t use the type “number”, only the types BinarySensor, Climate, Sensor, TextSensor or Switch the iobroker ESPHOME adapter will run fine. - Don’t know if there is a way to do anything with the RD6006 without the “number”-type in the YAML !?

I have a RD6006P and have built upon the work of @wildekek to make use of the 5 digit resolution and have built in other features that someone might find useful.

Thank you for that solution
I’ll appreciate if you can extend description of the flashing process which already present but not enough for the users unfamiliar to “raw” esp8266 (like me). Spend a day in google/blogs/stackoverflow but can’t even read the stock firmware from wifi module using FT232RL FTDI USB to TTL :face_with_hand_over_mouth:

Hi @4eversr ,

I have the same plan as you and want to use an RD6024 as controllable lifepo4 charger. I measure household Wattage with Shelly 3EM and have it integrated in Home Assistant. So I also need the RD6024 to be integrated in HA so that I can charge the battery with surplus energy.
Do you know if the methods describe here do also work for RD6024 instead of RD6006? And you said you spent hours and hours to get it work. Could you please describe what exactly you did? I am an absolute ESP beginner, never integrated ESP in HA or flashed something. And to be honest, with all the obsolete posts from @Atlantis, I have no plan what exactly are the steps to get the RD6024 integrated in HA.
Please, can you or anyone give a new clean overview, or even better a detailed description? I would really appreciate it a lot! :pray:

I just updated my repo and hope the instructions are a bit clearer. Also made it easy to update the Riden itself to the infamous UniSoft firmware.

2 Likes

Just updated my repo to support the following models:

  • RD6006: :white_check_mark: Supported and tested. Just download the latest release and off you go.
  • RD6018: :white_check_mark: Supported and tested. Download the latest release candidate.
  • RD6006P::question: Needs testing: check out the latest release candidate and share your results here
  • RD6012: :question: Needs testing: check out the latest release candidate and share your results here
  • RD6024: :stop_sign: Not properly supported, as there is no Unisoft firmware yet.