I am new to using the device esp32 i want correct code written for Arduino i want convert to esp32 Modula
Code: Select all
int relayPinpv = 23; // relay for phptovolatic panel
int relayPinbattery = 22; // relay for battery
int relayPingrid2 =01; // relay for Neighbors grid
int relayPintg = 19; // relay for tradtional grid
int relayPingen = 23; // relay for generator
float ppv=600 ;
float pbattery=600 ;
float pgrid2 ;
float vtg ;
float pt= 500 ; //load power 500 W
void setup() {
pinMode(relayPinpv, OUTPUT);
pinMode(relayPinbattery, OUTPUT);
pinMode(relayPingrid2, OUTPUT);
pinMode(relayPintg, OUTPUT);
pinMode(relayPingen, OUTPUT);
}
void loop() {
if (ppv>= pt) {
digitalWrite(relayPinpv, HIGH);
digitalWrite(relayPintg, LOW);
digitalWrite(relayPinbattery, LOW);
digitalWrite(relayPingrid2, LOW);
}
else if ((ppv<pt)&&((ppv+pbattery)>= pt))
{
digitalWrite(relayPinpv, HIGH);
digitalWrite(relayPinbattery, HIGH);
digitalWrite(relayPingrid2, LOW);
digitalWrite(relayPintg, LOW);
}
else if ((ppv<pt)&&((ppv+pbattery)<pt)&&((ppv+pbattery+pgrid2)>= pt))
{
digitalWrite(relayPinpv, HIGH);
digitalWrite(relayPinbattery, HIGH);
digitalWrite(relayPingrid2, HIGH);
digitalWrite(relayPintg, LOW);
}
else if (vtg >0) {
digitalWrite(relayPintg, HIGH);
digitalWrite(relayPinpv, LOW);
digitalWrite(relayPinbattery, LOW);
digitalWrite(relayPingrid2, LOW);
}
else {
digitalWrite(relayPingen, HIGH);
digitalWrite(relayPintg, LOW);
digitalWrite(relayPinpv, LOW);
digitalWrite(relayPinbattery, LOW);
digitalWrite(relayPingrid2, LOW);
}
delay(1000);
}