TITLE : Write Programming for Controller
OBJECTIVES :
- Make a coding for controller block which is NodeMCU
METHODOLOGY :
- The coding programming was using Arduino IDE software
- The coding need a combination of current sensor by ACS712 and displayed it on Blynk Application
RESULTS :
- The coding programming
#define
BLYNK_PRINT Serial
#include
<ESP8266WiFi.h>
#include
<BlynkSimpleEsp8266.h>
BlynkTimer
timer;
char
auth[] =
"Aut Token";
char
ssid[] = "WiFi name";
char
pass[] = "WiFi Password";
const
int Sensor_Pin = A0;
int
Sensitivity = 66; // 185mV/A for 5A,
100 mV/A for 20A and 66mV/A for 30A Module
float
Vpp = 0; // peak-peak voltage
float
Vrms = 0; // rms voltage
float
Irms = 0; // rms current
float
Vcc = 5.0; // ADC reference
voltage // voltage at 5V pin
float
Supply_Voltage = 230.0;
float
power = 0; // power in watt
float
Wh =0 ; // Energy in kWh
unsigned
long last_time =0;
unsigned
long current_time =0;
unsigned
long interval = 100;
unsigned
int calibration = 100; // V2 slider
calibrates this
int
pF = 85; // Power Factor
default 85
void
getACS712()
{ // for AC
Vpp = getVPP();
Vrms = (Vpp/2.0) *0.707;
Vrms = Vrms - (calibration / 10000.0); // calibtrate to zero with slider
Irms = (Vrms * 1000)/Sensitivity ;
if((Irms > -0.08) && (Irms <
0.05))
{ //
remove low end chatter
Irms = 0.0;
}
power= (Supply_Voltage * Irms) * (pF /
100.0);
Blynk.virtualWrite(V0, String(power,2));
Blynk.virtualWrite(V1, String(Irms, 2));
}
float
getVPP()
{
float result;
int readValue;
int maxValue = 0;
int minValue = 1024;
uint32_t start_time = millis();
while((millis()-start_time) < 950) //read
every 0.95 Sec
{
readValue = analogRead(Sensor_Pin);
if (readValue > maxValue)
{
maxValue = readValue;
}
if (readValue < minValue)
{
minValue = readValue;
}
}
result = ((maxValue - minValue) * Vcc) /
1024.0;
return result;
}
BLYNK_WRITE(V2) { // calibration slider 50 to 200
calibration = param.asInt();
}
void
setup()
{
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
while (Blynk.connect() == false) {}
timer.setInterval(2000L, getACS712); // get
data every 2s
}
BLYNK_CONNECTED()
{
Blynk.syncAll();
}
void
loop()
{
Blynk.run();
timer.run();
}
ANALYSIS & DISCUSSION:
CONCLUSION:
- The coding was making from different resource and make combination the different resource.
CONCLUSION:
- The coding programming is successfully done.
No comments:
Post a Comment