BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Blynk controlled DPS5005

Hallo Blynker
my project is Blynk controlled DPS5005 with Modbus :cool:
We can :
1-Set V
2-Set A
3-ON OFF
4-Reading Volt Amber Watt
5-Temperature inside the box in C
6- History Chart
we need
1-Esp32 Devbord
2- DPS5005 50V 5A Communication Function
3-Mini Micro JST GH1.25mm 4pin you can use module cabel if you want
4-LM2596S-ADJ Adjustable DC-DC Power Module to power ESP32 from input Voltage
Video:

**

schematic:

**
TX DPS5005 To RX0 in ESP32
RX DPS5005 To TX0 in ESP32
sorry for all photos in one upload (new users Limitation):hushed:


code:

     /*
         // DPS5005 with Blynk By Hussein Daj(www.hussein-solutions.de)
        // Credit to 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
        */
        //Built-in Temperature sensor حساس الحرارة الداخلي ضمن الكنتورلر
        #ifdef __cplusplus
        extern "C" {
        #endif
        uint8_t temprature_sens_read();
        #ifdef __cplusplus
        }
        #endif

        #define BLYNK_PRINT Serial
        #include <ModbusMaster.h> // ModbusMaster
        #include <WiFi.h>
        #include <WiFiClient.h>
        #include <BlynkSimpleEsp32.h>
        uint8_t temprature_sens_read();
        ModbusMaster node;    // instantiate ModbusMaster object
        float voltage = 0.0;
        float current = 0.0;
        float power = 0.0;
        float SetV = 0;
        float SetA = 0;
        bool on=0;
        char auth[] = "blynk code"; //الكود الخاص بمشروع بلنك
        char ssid[] = "your ssid";//اسم شبكة الواير ليس
        char pass[] = "ssid password";//كلمة السر
        BlynkTimer timer;
        void myTimerEvent()
        {
           Read();
          Blynk.virtualWrite(V0,voltage); //out V
          Blynk.virtualWrite(V1,current); //out A
          Blynk.virtualWrite(V9,SetV); //SetV
          Blynk.virtualWrite(V8,SetA); //SetA
          Blynk.virtualWrite(V5,on); //on off state
          Blynk.virtualWrite(V2,power); //on off state
          int Temp=((temprature_sens_read() - 32 ) / 1.8);
          Blynk.virtualWrite(V3,Temp);
         }

        void setup()
        {
         Serial.begin(9600);
           timer.setInterval(1000L, myTimerEvent);
          Blynk.begin(auth, ssid, pass);
          node.begin(1,Serial);
          
        }


        void loop()
        {
          Blynk.run();
          timer.run(); // Initiates BlynkTimer
        }
        //Read Data   
        void Read(){
           uint8_t j, result;
            result = node.readHoldingRegisters(0, 10);  // slave: read a range of 16-bit registers starting at register 0 to 10   
         if (result == node.ku8MBSuccess)   // only do something with data if read is successful
          {
           voltage =  ((float)node.getResponseBuffer(2) / 100 ); // get voltage from response buffer and convert to float
          current =  ((float)node.getResponseBuffer(3) / 1000 ); // get current from response buffer and convert to float  
          power =  ((float)node.getResponseBuffer(4) / 100 ); // get power from response buffer and convert to float  
           SetV =  ((float)node.getResponseBuffer(0) / 100 ); // get SetV from response buffer and convert to float
           SetA =  ((float)node.getResponseBuffer(1) / 1000 ); // get SetA from response buffer and convert to float
              on =  ((bool)node.getResponseBuffer(9) ); // Status on or off

        }
           }
        //Write Data 
        BLYNK_WRITE(V5) //on off
        {
          int pinValue = param.asInt(); // assigning incoming value from pin V5 to a variable
           node.writeSingleRegister(9, pinValue); //set power on !  
           
        }

        BLYNK_WRITE(V6) //Set V
        {
          int pinValue = param.asFloat(); // assigning incoming value from pin V5 to a variable
          node.writeSingleRegister(0, pinValue*10);  
        }
        BLYNK_WRITE(V7) //Set A
        {
          int pinValue = param.asFloat(); // assigning incoming value from pin V5 to a variable
        node.writeSingleRegister(1, pinValue*100); 
        }

Blynk:
http://tinyurl.com/y8m6aywx

8 Likes

Very nice Project for the popular Bench power supply , and more nice to see more Arabs are going into such technology i have cached your Arabic comments in the project code.

greetings from EGYPT.

3 Likes

Hi, I have tested the project with a DPS3005, but I can not get it to work.
Could you explain a bit how to configure blynk virtual ports and the selection of volts and amps?
I only get temperature data, but my dps I think it has no temperature …

Hallo @emi2
temperature data from ESP32 not from DPS3005
are you sure Serial between ESP32 and DSP is
TX ---- >RX
RX------>TX

and GND in ESP with GND in DPS3005 :eyeglasses:

i check DPS3005 is the same DPS5005 Buffer
so it the same code for more deltils you can read communication protocol for this device is specifically MODBUS RTU
http://www.mediafire.com/file/8qq84gdemedde6j/DPS3005_CNC_Communication__Protocol_V1.2.docx

greetings

Thank you very much, sometimes you look 100 times and you do not see it …

It works for me. A very good code.

greetings

1 Like

Thanks

Hi Hussein
thanks for your great project.

I have a pb the link to the blink does not work: http://tinyurl.com/y8m6aywx
Would you please check or do I make a mistake?

thanks

@Dx266
it is work
you must open it from your mobile browser
Best regards

Thanks Hussein for your help. One more question: how many credits is required for your blynk app?

thanks a lot

@Dx266
2700 credits
but you can delet chart so you save 900 credits
regards

Thanks very much Hussein.
can I ask you a favor? Would you mind saving your project without the charts? You cannot even open it on the free version (2000credits) to modify it and I cannot buy credit with my pro phone… Again thanks a lot.

you don,t need to copy my project
create new one and use same virtual pin like this photo and chose what you want

Hello, does it also work on a ESP8266?

I tried it with your code and a example blynk, but in my way it desn’t
thanks a lot so far for your work.

Hello, I have adapted it for ESP8266 - Wemos D1 mini, because it is smaller and cheaper. For the temperature I use a DHT11.

I have also added the update by OTA.

This is the modified code:

 /*
        // DPS5005 with Blynk By Hussein Daj(www.hussein-solutions.de)
        // Credit to Luke 8)
        // 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
        */

        #define BLYNK_PRINT Serial
        #include <ArduinoOTA.h>
        #include <ModbusMaster.h>   // ModbusMaster
        #include <SoftwareSerial.h> // Software Serial Library so we can use other Pins for communication with DPS5005 module
        #include <ESP8266WiFi.h>
        #include <BlynkSimpleEsp8266.h>
        #include <DHT.h>

        #define DHTPIN D4     // what digital pin we're connected to pin 2
        #define DHTTYPE DHT11   // DHT 11

        DHT dht(DHTPIN, DHTTYPE);

        static const int RXPin = D6, TXPin = D7;             // DPMS3005 module to pins 4 and 3 ESP8266
        
        SoftwareSerial ss(RXPin, TXPin);                     // The serial connection to the DPS3005 device
        
        ModbusMaster node;    // instantiate ModbusMaster object
        float voltage = 0.0;
        float current = 0.0;
        float power = 0.0;
        float SetV = 0;
        float SetA = 0;
        bool on=0;
        char auth[] = "blynk code"; //الكود الخاص بمشروع بلنك
        char ssid[] = "your ssid";//اسم شبكة الواير ليس
        char pass[] = "ssid password";//كلمة السر
        BlynkTimer timer;
        void myTimerEvent()
        {
           Read();
          //float t = dht.readTemperature(true); // Read temperature as Fahrenheit (isFahrenheit = true)
          float t = dht.readTemperature(); // Read temperature as Celsius (the default)
          Blynk.virtualWrite(V0,voltage); //out V
          Blynk.virtualWrite(V1,current); //out A
          Blynk.virtualWrite(V9,SetV); //SetV
          Blynk.virtualWrite(V8,SetA); //SetA
          Blynk.virtualWrite(V5,on); //on off state
          Blynk.virtualWrite(V2,power); //on off state
          Blynk.virtualWrite(V3,t);
         }

        void setup()
        {
          Serial.begin(9600);
          WiFi.mode(WIFI_STA);
          timer.setInterval(1000L, myTimerEvent);
          Blynk.begin(auth, ssid, pass);
          dht.begin();
          ss.begin(9600);           // Set Software Serial Comm Speed to 9600   
          node.begin(1,ss); 
          while (Blynk.connect() == false) {}
          ArduinoOTA.setHostname("DPS5005"); // OPTIONAL NAME FOR OTA
          ArduinoOTA.begin();
          
        }


        void loop()
        {
          Blynk.run();
          ArduinoOTA.handle();
          timer.run(); // Initiates BlynkTimer
        }
        //Read Data   
        void Read(){
           uint8_t j, result;
            result = node.readHoldingRegisters(0, 10);  // slave: read a range of 16-bit registers starting at register 0 to 10   
         if (result == node.ku8MBSuccess)   // only do something with data if read is successful
          {
           voltage =  ((float)node.getResponseBuffer(2) / 100 ); // get voltage from response buffer and convert to float
           current =  ((float)node.getResponseBuffer(3) / 1000 ); // get current from response buffer and convert to float  
           power =  ((float)node.getResponseBuffer(4) / 100 ); // get power from response buffer and convert to float  
           SetV =  ((float)node.getResponseBuffer(0) / 100 ); // get SetV from response buffer and convert to float
           SetA =  ((float)node.getResponseBuffer(1) / 1000 ); // get SetA from response buffer and convert to float
           on =  ((bool)node.getResponseBuffer(9) ); // Status on or off

        }
           }
        //Write Data 
        BLYNK_WRITE(V5) //on off
        {
          int pinValue = param.asInt(); // assigning incoming value from pin V5 to a variable
           node.writeSingleRegister(9, pinValue); //set power on !  
           
        }

        BLYNK_WRITE(V6) //Set V
        {
          int pinValue = param.asFloat(); // assigning incoming value from pin V5 to a variable
          node.writeSingleRegister(0, pinValue*10);  
        }
        BLYNK_WRITE(V7) //Set A
        {
          int pinValue = param.asFloat(); // assigning incoming value from pin V5 to a variable
        node.writeSingleRegister(1, pinValue*100); 
        }
1 Like

That’s how I got it, I’m fear of the slider and voltage.

@emi2 very nice work and thanks for your reply
but which pins do you connect the RX and TX from the module? to D6 and D7 or to TX RX or GPIO3/4 on the esp8266

RXPin = D6, TXPin = D7; // DPMS3005 module to pins 4 and 3 ESP8266
thanks a lot

Hello, in the forums I read that in the ESP8266 the TX and the RX give problems, so I use the softwareserial to choose other pins.

The pins I use are RXPin = D6, TXPin = D7 using Wemos D1 mini in the Arduino IDE.

What kind of problems? :face_with_raised_eyebrow:

Actually, I don’t remember well, I think there were communication problems when using the rx tx and the usb serial monitor of the Wemos. But I have not checked it.
Anyway, I made the work easy, copy the configuration from other projects to communicate with DPS5005.
Surely it can be simplified by removing SoftwareSerial and using rx tx, since the usb is not used here.

1 Like

Ah, yes! but only when it’s serial port is actively occupied by another node! It is the same as with UNO.

1 Like