DPS3005 PSU Module and MODBUS RTU Python & Arduino

DPS3005 Communication- version, Esp8266

I recently came across a DPS3005 PSU Module with PC control option , i have used similar modules before in a bench power supply and was impressed with the results . With the launch of a new version that included PC control i decided to order one ! (Banggood.com)

A few weeks later it arrived …

in the box was a

  1. DPS3005 Module
  2. Manual
  3. Usb serial Adaptor
  4. Bluetooth Module
  5. link lead (not pictured)

The PC / bluetooth was not mentioned in the supplied instructions and the pc software (windows 7+ only) was available from the sellers listing and also Manufacturers Youtube Channel. I decided not to install and see if i was able to control from a MCU such as an Arduino

Investigating The Interface

I started by investigating the interface by first connecting the Bluetooth and USB serial adapter to the unit and simply seeing if there was any data flowing on the com ports. This did not prove very successfully at all and wasn’t even able to pair the Bluetooth adapter with any device i tried. Though without a button on the bluetooth module i couldnt see a way of even putting it in pair mode !

Without giving up and i decided to look on the manufacture’s download link and found a interface datasheet, all in Chinese . Using google translate i was able to see the command set and the interface was basically listed as Modbus Rtu, rs232,9600 baud and slave address 1.

I have no experience with modbus at all and had to do a bit of research to understand this very basics .

The following functions were listed as supported in the datasheet:
0x03Read data from one or more registers
0x06 – Write a single register
0x10Write multiple registers

basic Functions extacted from datasheet , needed for examples below
Voltage set – Register 0x00
Current set – Register 0x01
Voltage measured – Register 0x02
Current measured – Register 0x03

power on – Register 0x04

Loads more see manufactures datasheet for more info…

Luckly there are a wide range of software libraries available for different platforms to help communicate with Modbus Rtu devices. So i didn’t need to deal with the raw data on the serial port .

Python Testing

Rather than jumping straight in and connecting to an arduino i decided to use the supplied USB serial adaptor and python to see if i could work out the basics using the infomation exactracted above.

Below is a very simple example how i was able read the units measured voltage. One issue i did notice i had to increase the default timeout for it to work !

# DPS3005 MODBUS Example By Luke (www.ls-homeprojects.co.uk) 
# Free to use this code how you like but please link my site
# Requires minimalmodbus library from: https://github.com/pyhys/minimalmodbus


import minimalmodbus


instrument = minimalmodbus.Instrument('COM4', 1) # port name, slave address (in decimal)
instrument.serial.port          # this is the serial port name
instrument.serial.baudrate = 9600   # Baud rate 9600 as listed in doc
instrument.serial.bytesize = 8
instrument.serial.timeout = 0.5     # This had to be increased from the default setting else it did not work !




instrument.mode = minimalmodbus.MODE_RTU  #RTU mode 






print instrument.read_register(2, 2)   #read a range of 16-bit registers starting at register 2 to 3 (measured voltage and current)

Arduino Testing

After confirming it worked using python and the measured voltage was successfully displayed i decided to move onto arduino. I noticed that it used a 3.3v logic level and rather than using level shifter i opted just to try and use a ESP82266 running arduino. This made it really easy to hook up just three wires gnd, TX and RX. A software serial port was used to talk to the dps3005 psu module allowing the native (USB) serial port free to monitoring everything.

UPDATE: due to a few questions about the pinout, i have marked the pin out of my DPS3005 on the picture below

I would suggest a simple check with a multimeter across vcc (bluetooth pwr) and GND to prove are in the same place as my finding first !

Note , the supplied link lead wire colours did not match the PCB marking on my unit and was completely reversed . I may have just had a defect cable in my case but can confirm the PCB Marking on the DPS3005 module and usb serial convertor were correct.

/*

// DPS3005 MODBUS Example By Luke (www.ls-homeprojects.co.uk)
// Free to use this code how you like but please link my site

// Credit to Doc Walker of ModbusMaster for making a great Arduino Library https://github.com/4-20ma/ModbusMaster
*/


#include <ESP8266WiFi.h>
#include <ModbusMaster.h>
#include <SoftwareSerial.h>


#define SERIAL_RX     D5  // PIN Mapping for ESP8266 NODE MCU Only! pin for SoftwareSerial RX 
#define SERIAL_TX     D6  // PIN Mapping for ESP8266 NODE MCU Only! pin for SoftwareSerial TX
SoftwareSerial mySerial(SERIAL_RX, SERIAL_TX); 




ModbusMaster node;		// instantiate ModbusMaster object
float voltage = 0.0;
float current = 0.0;

void setup()
{
  
	Serial.begin(9600);

	mySerial.begin(9600);     //start software serial connected to dps3005 
	pinMode(SERIAL_RX, INPUT);
	pinMode(SERIAL_TX, OUTPUT);


  // communicate with Modbus slave ID 1 over Serial (port 0)
	node.begin(1,mySerial);
}


void loop()
{
 
  uint8_t j, result;

  
  
  
	//********Example of sending cmds***********
	node.writeSingleRegister(0, 0x96); //set 1.5v
	node.writeSingleRegister(1, 0x1F4); //set 500ma
	node.writeSingleRegister(9, 1); //set power on !  
 
	delay(2000);



  
  //*******Example of reading data*****************
  
 result = node.readHoldingRegisters(2, 2);  // slave: read a range of 16-bit registers starting at register 2 to 3 (measured voltage and current)  
  
  
 if (result == node.ku8MBSuccess)		// only do something with data if read is successful
  {
 


	voltage =  ((float)node.getResponseBuffer(0) / 100 ); // get voltage from response buffer and convert to float
	current =  ((float)node.getResponseBuffer(1) / 100 ); // get current from response buffer and convert to float




  Serial.println("");

	Serial.print ("Voltage: ");
	Serial.print (voltage);
	Serial.println ("V  ");
	
	Serial.println("");

	Serial.print ("Current: : ");
	Serial.print (current);
	Serial.println ("A  ");
	
	delay(2000);


    
  }

}

Im very pleased how easy it was to get control of these great psu modules. Next.. im planning to making a new bench psu with a web interface using a esp8266.

COMMENTS

Raffaele

Hi Luke,

Thank you for this info. I am looking forward to read more about your progress with this PSU. Unfortunately I do not get a connection using the Windows Software (DPS3005 V1.3). But I was able to pair the BT module from Windows 10 using the pin 1234. The device showed up as “RuiDengDPS” and i just needed to press the “pair” button and to enter the pin.

Good luck.

Raffaele Biscosi

Hi Luke,

thank you for sharing your findings. Especially mentioning the datasheet and suggesting to use google translate was very helpful. I was amazed how well that works.

I was thinking about writing some kind of http based API instead of a web frontend for a start. Just enough to set voltage and current limits and to control the output. I would also like to control two supplies with one esp8266 so that one could build a +/-30V PS with it. It should also be no problem to have a small subroutine for charging single LiPo cells with different parameters. How about working together on this?

Raffaele

    Luke

    Hi Raffaele,

    Sorry for the very long reply, good to hear you found my post uselful! Recently i havent had as much time to do projects as liked, but had been working on a web interface using web sockets. Like yourself i was planning to have the ability to control two DPS3005 psu modules and have it mostly working with a few bugs to iron out. Will look at adding a basic http based API as well.

    How far have you got with your project ?

    Luke

      Raffaele Biscosi

      Hi Luke,

      thanks for you answer. I was also quite busy because of my job lately and preferred spending leisure time family and friends. Hope to find some time during the upcoming winter season.

      Raffaele

Mai Mariarti

“This made it really easy to hook up just three wires gnd, TX and RX. A software serial port was used to talk to the dps3005 psu module”
Really? What is the pin-outs?
Red is obvious 3.3V, the rest? Is green the ground or black? This is what happens when noobs write articles!

    Luke

    Hi Mai, if you read my post again you will notice that i have said that the colours of the wires we not right in my case but i used the labels (tx, rx, gnd) next to the socket on DPS3005 PCB or on the supplied usb to serial adaptor pcb. I had even highlight this in red text in quote marks underneath. Hope this helps . If your still stuck im happy to take some more pictures .

lambcutlet

Luke,
I borrowed your python code messed around with it for a few weeks and came up with this
have a look here ‘https://github.com/lambcutlet/DPS5005_pyGUI’

tolisn

Which ESP8266 did you use ? Do you have a link to the item ?

    Luke

    Hi , tolisn
    The ESP8266 used was a board called “node MCU” a google search will easily find one or on ebay or Amazon.
    On ebay

    Hope that helps

    Luke

Sam

Hi Luke,
I’m currently trying to setup wired communication between the device and my computer and I’m struggling with getting the computer to recognize the COM port. Basically, when i connect it, it recognizes it as a regular USB device and I can’t setup my serial communication code with it. I’ve installed that “CH341SER” file which seems to be the required driver. Did you experience this issue at all?
Thank you!

    Luke

    Hi Sam,
    I cant remember having an issue with the usb serial adaptor but did not have any luck with the bluetooth adaptor .
    What os are you using ?
    Have you checked other Usb to serial adaptors such as an arduino load Com port drivers ?

    Will have a look at mine when i get a chance .

    Hope that helps
    Luke

Markel Robregado

I am trying to do the same but using TI MCU. But instead connect to the cable going to the UART to USB board. What does U T R G pin means at the UART to USB board?

    Luke

    Hi Markel,
    I’m not sure to be honest it’s been a while since I’ve worked on this project. You could have a different Uart to usb board to me. Maybe post a picture of the pins . Cheers Luke

Markel Robregado

Hi Luke,
Thanks for your reply. It’s not clear which three wires gnd, TX and RX of DPS3005 you connect to ESP82266. Here is link to the picture of my UART to USB board. At the moment I am connecting a logic analyzer to it trying to capture the UART communication between DPS3005 and DPS PC Software. https://drive.google.com/file/d/1pL4NFrPacQs0hbDBFB06mILWGqwBj34T/view?usp=sharing

    Luke

    Markel,
    No worries thanks for taking a picture of USB to serial, i can confirm its the exact same as mine. Although I have just noticed that the pinout was only marked on the bluetooth adaptor and not the usb to serial so this explains why i had a lot of wiring questions ! I have just updated my post with a picture with the pinout. As i mentioned underneeth the picture i would suggest you first check the vcc and gnd are in the same place as mine to be totally sure its connected the same as mine. Please report back if its correct . Good luck with your project !
    cheers Luke

Markel Robregado

Hi Luke, I confirmed it is correct. I am getting good logic analyzer capture. I realized the pinout markings U T R G is actually V T R G. VCC, Tx, Rx, Gnd. Thanks.

Markel Robregado

Hi Luke, I tried your exact code at NodeMCU I just bought. Only the Voltage is written. The current remains 0.000 A. Any ideas why that happens?

Nitek

Thx for this great post! Did I get it correctly that VCC on the is 3.3V? It should be possible to power the ESP using this, right?

    Luke

    Hi , Sorry It was a while ago I can’t remember what vcc is to be honest at a guess it would be 3.3v. Would suggest measuring to be sure. I never used it, I powered the esp separately as wasn’t sure of the current rating and as it was originally designed only for a Bluetooth adapter . Done a quick search on a similar Bluetooth adapter and it’s current rating is only 30ma so a lot less than esp8266 so maybe a safer option to power esp separately (remember to link Gnds ) . Hope that helps . Luke

      Nitek

      Thx for the quick reply. Seems like the current rating might indeed be an issue.

        Luke

        No worries , you could always try it at the risk of damaging your DPS3005 but maybe better to play it safe like me . One other suggestion I had is if you searched web for schematic diagram or reverse engineered the circuit and see what 3.3v voltage regulator but these take time !
        Good luck with your project

        Luke

Franci

Thank you so much for this. A few years ago when this module came out I was thinking that this should be possible because they were selling Usb/serial adapter for it.
I am very happy because now I can attach some buttons to arduino and change voltage in less than a second.
Thank you again for your effort and publishing your findings.

Gene's Green Machine

Hey Luke – just a shout out for giving me the “Eureka!!” moment I needed to integrate my pedal generator with Zwift. Your DPSxxxx code on Arduino delivered just what I needed to get the project completed. Check it out:https://www.instructables.com/Zwift-Capable-Pedal-Generator/

    Luke

    Hi Gene, thanks for the comment and. It’s really great to hear my post helped you with your project! .Your project looks amazing great work !

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.