I am new in this world and i have never used an esp32-s3 so i dont know if im doing good with my ADC or why this sensor is not reading well.
My code is this one:
float sensitivity = 0.066;
void setup() {
Serial.begin(9600);
}
void loop () {
float I = getCurrent(200);
if (I <= 0) {
Serial.print("Current: ");
Serial.print("0.00");
Serial.println("A");
delay(1000);
} else {
Serial.print("Current: ");
Serial.print(I);
Serial.println("A");
delay(1000);
}
}
float getCurrent (int numSamples)
{
float sensorVoltage;
float current = 0;
for (int i = 0; i < numSamples; i++)
{
sensorVoltage = analogRead(A0) * (5.0 / 4095.0);
current = current + ((sensorVoltage - 2.5) / sensitivity) / 2;
}
current = current / numSamples;
return current;
}
Juraj
2
esp32 is a 3.3 V board so the read ADC value is for 3.3 V. so 3.3 / 4095.0.
use a voltage divider to reduce the input from 0 to 5 V to 0 to 3.3 V.
jim-p
3
You did not read the advice about posting code, please do
Also please supply a schematic/wiring diagram of how you have the ESP and sensor connected
kmin
4
ACS712 is available with many different Amp ratings and have different outputs (mV/A)