Hallo Blynker
my project is Blynk controlled DPS5005 with Modbus
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)
/*
// 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);
}
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.
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 …
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.
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);
}
@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
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.