Hi, recently I bought RD6006 power supply with wifi option and discovered that the official app for wifi control is totally useless 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
- USB (front USB port). It has some serial to USB bridge inside
- Wifi - it communicates over UART with wifi module (ESP8266) connected to the pinheader inside the machine
- 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:
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âŚ
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