-
Again changes made to previous “BLYNK” sketch
add lines to “Settings.h”
/*-------------------------------Virtual Pins---------------------------------*/
#define vPIN_MONITOR V61
#define vPIN_POWER V62
#define vPIN_ENERGY V63
#define vPIN_TIME V64
#define vPIN_WASHER_ON_OFF V65
add lines to “mqtt_publish.h”
//=============================================TAB 3============================================
//---------------------------------------------WASHER-------------------------------------------
BLYNK_WRITE(vPIN_WASHER_ON_OFF) { // WASHER ON/OFF
if (param.asInt()) {
client.publish("Washer/cmnd/POWER","1");
} else {
client.publish("Washer/cmnd/POWER","0");
}
}
add lines to “mqtt_subscribe.h”
#define InTOPIC_11 "Washer/tele/SENSOR"
#define InTOPIC_12 "Washer/stat/POWER"
~
client.subscribe(InTOPIC_11);
client.subscribe(InTOPIC_12);
~
//========================================= TAB 3 =====================================
//------------------------------WASHER--------SENSOR---------------------------------------
//MQT: Washer/tele/SENSOR =
//{"Time":"2019-07-02T02:02:30","ENERGY":{"TotalStartTime":"2019-06-30T04:31:57",
//"Total":0.337,"Yesterday":0.117,"Today":0.000,"Period":0,"Power":0,
//"ApparentPower":0,"ReactivePower":0,"Factor":0.00,"Voltage":234,"Current":0.000}}
}else if (String(topic) == InTOPIC_11) { // Washer/tele/SENSOR
StaticJsonBuffer<350> jsonBuffer;
JsonObject& root = jsonBuffer.parseObject((char*)payload);
float vol = root["ENERGY"]["Voltage"];
float cur = root["ENERGY"]["Current"];
float power = root["ENERGY"]["Power"];
float apow = root["ENERGY"]["ApparentPower"];
float rpow = root["ENERGY"]["ReactivePower"];
float pf = root["ENERGY"]["Factor"];
float today = root["ENERGY"]["Today"];
float yesterday = root["ENERGY"]["Yesterday"];
float total = root["ENERGY"]["Total"];
float period = root["ENERGY"]["Period"];
const char* StartTime = root["ENERGY"]["TotalStartTime"];
const char* Time = root["Time"];
Blynk.setProperty (vPIN_MONITOR, "label",String("\xF0\x9F\x94\x8C")+"Voltage"+" "+String("\xE2\x9A\xA1")+"Current"+" "+String("\xF0\x9F\x94\x8B")+"Power");
Blynk.virtualWrite(vPIN_MONITOR, (String (vol,1)+" V "+String (cur,3)+" A "+String(power,1)+" W "));
Blynk.setProperty (vPIN_POWER, "label",String(String("\xE2\x9A\xA1")+"Power Factor"+" "+String("\xE2\x9A\xA1")+"Apparent Power"+" "+String("\xE2\x9A\xA1")+"Reactive Power"));
Blynk.virtualWrite(vPIN_POWER, (String (pf,2)+" "+String (apow,1)+" VA "+String (rpow,1)+" VAr "));
Blynk.setProperty (vPIN_ENERGY, "label",String("\xE2\x9A\xA1")+"ENERGY Today"+" "+String("\xE2\x9A\xA1")+"ENERGY Yesterday"+" "+String("\xE2\x9A\xA1")+"ENERGY Total");
Blynk.virtualWrite(vPIN_ENERGY, (String (today,3)+" "+String (yesterday,3)+" "+String(total,3)+" kWh "));
Blynk.setProperty (vPIN_TIME, "label",String("\xE2\x8C\x9A")+"Time"+" "+String("\xE2\x9A\xA1")+"TotalStartTime"+" "+String("\xE2\x9A\xA1")+"Period"+" ");
Blynk.virtualWrite(vPIN_TIME, (String (Time)+" "+String (StartTime)+" "+String (period,1)+" "));
//------------------------------WASHER--------POWER------------------------------------------
}else if (String(topic) == InTOPIC_12) { // Washer/stat/POWER
StaticJsonBuffer<250> jsonBuffer;
JsonObject& root = jsonBuffer.parseObject((char*)payload);
if ((char)payload[1] == 'N') {
Blynk.virtualWrite(vPIN_WASHER_ON_OFF,1);
}else{
Blynk.virtualWrite(vPIN_WASHER_ON_OFF,0);
}
}
}
//=========================================================================================
- (again) same results was accomplished before for Sonoff S31 using Node-Red
- In “BLYNK” app. many buttons can be added as:
- VoltageHigh & VoltageLow threshold value.
- CurrentHigh & CurrentLow threshold value.
- MaxPower, MaxPowerHold & MaxPowerWindow how to stay over MaxPower before power off.
- PowerHigh & PowerLow to send an MQTT telemetry message.
- EnergyReset1, EnergyReset2 & EnergyReset3 to set or reset Energy Values.