ESP8266 A0 Pin reading
Posted: Thu Jun 15, 2023 8:14 pm
I'm trying to read the current using a ACS712 5A model, but when I go to trying to get the values the ADC doesn't change unless I remove the pin entirely.I'm not sure why maybe something is wired wrong. This is a quick schematic using KiCad I have the development board, but this is the closing thing I had at the moment to make somewhat of a fritzing. There's also a multimeter in series with this circuit. I'm assuming my load is the LED and resistor. I'm trying to read the current flowing in the system any help is appreciated.
Code: Select all
void setup() {
Serial.begin(115200); //Start Serial Monitor to display current read value on Serial monitor
}
void loop() {
int sampSize = 500;
float AcsValue = 0.0, Samples = 0.0, AvgAcs = 0.0, AcsValueF = 0.0;
for (int x = 0; x < sampSize; x++) { //Get 150 samples
AcsValue = analogRead(A0); //Read current sensor values
Serial.println(AcsValue);
Samples += AcsValue; //Add samples together
// delay(3); // let ADC settle before following sample 3ms
}
AvgAcs = Samples / sampSize; //Taking Average of SampleMs
AcsValueF = (((AvgAcs / 1023.0) * 4096)) / 185;
// AcsValueF = (((AvgAcs / 1023.0) * 4.096) - 2.048) * 0.100;
// Serial.println(AcsValueF); //Print the read current on Serial monitor
}