void setup() {
Serial.begin(115200);
}
void loop() {
int rawI = analogRead(34); // التيار
int rawV = analogRead(35); // الجهد
float voltI = rawI * 3.3 / 4095.0;
float voltV = rawV * 3.3 / 4095.0;
float current = voltI / 3.3 * 20.0; // 0-20 A
float voltage = voltV / 3.3 * 250.0; // 0-250 V
float power = current * voltage; // واط
Serial.print("I = ");
Serial.print(current, 2);
Serial.print(" A V = ");
Serial.print(voltage, 1);
Serial.print(" V P = ");
Serial.print(power, 1);
Serial.println(" W");
delay(500);
}Loading
esp32-devkit-c-v4
esp32-devkit-c-v4