ESP-01 soldered wire to its analog pin reset problem

Hello,

I am using an ESP-01 to which i have soldered a thin wire to its analog pin. The wire is then used to read from a current sensor ACS712 analog output via a potential divider using 100 and 400 Ohms resistors to convert from 5 V to 1 V, since the analog pin of the ESP-01 has only a range of 0 -1 V.

But on the Serial Monitor in Arduino IDE, i see only 2 values and then there is an error Soft WDT reset, and this output repeats indefinitely. Is that a hardware or software issue? Is the soldering somehow causing a short or maybe i need to add some extra components to be able to tap into the ESP-01 analog pin?

This is my Serial Monitor output:

Vpp/V: 0.000 Vrms/V: 0.000 Irms/A: 0.000
Vpp/V: 0.000 Vrms/V: 0.000 Irms/A: 0.000

Soft WDT reset

>>>stack>>>

ctx: cont
sp: 3ffffd50 end: 3fffffc0 offset: 01b0
3fffff00:  40230469 00000004 000017b6 00000004  
3fffff10:  4023070f 00000004 000017b6 00000400  
3fffff20:  3ffee37c 00000004 000017b6 00000000  
3fffff30:  40229aee 00000000 00001eba 3ffee37c  
3fffff40:  00000000 00000000 4bc6a7f0 00000000  
3fffff50:  00000000 00000400 40223fac 00000400  
3fffff60:  4020221b e26e0986 3ffee300 40201494  
3fffff70:  00000400 000017b6 00000400 40201080  
3fffff80:  3fffdad0 00000000 3ffee33c 4020111c  
3fffff90:  3fffdad0 00000000 3ffee33c 3ffee37c  
3fffffa0:  3fffdad0 00000000 3ffee33c 40201d18  
3fffffb0:  feefeffe feefeffe 3ffe84e4 40100bc9  
<<<stack<<<

 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 1384, room 16 
tail 8
chksum 0x2d
csum 0x2d
vbc204a9b
~ld
Vpp/V: 0.000 Vrms/V: 0.000 Irms/A: 0.000
Vpp/V: 0.000 Vrms/V: 0.000 Irms/A: 0.000

Soft WDT reset

>>>stack>>>

ctx: cont
sp: 3ffffd70 end: 3fffffc0 offset: 01b0
3fffff20:  402308b5 00000004 00000000 40229bc6  
3fffff30:  40229c24 00000000 000017b4 00000400  
3fffff40:  07ff07ff 07ff07ff 07ff07ff 07ff07ff  
3fffff50:  00000000 00000400 40223fac 00000400  
3fffff60:  4020221b 084591ae 3ffee300 40201494  
3fffff70:  00000400 000017b4 00000400 40201080  
3fffff80:  3fffdad0 00000000 3ffee33c 4020111c  
3fffff90:  3fffdad0 00000000 3ffee33c 3ffee37c  
3fffffa0:  3fffdad0 00000000 3ffee33c 40201d18  
3fffffb0:  feefeffe feefeffe 3ffe84e4 40100bc9  
<<<stack<<<

 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 1384, room 16 
tail 8
chksum 0x2d
csum 0x2d
vbc204a9b
~ld
Vpp/V: 5.000 Vrms/V: 1.768 Irms/A: 17.675
Vpp/V: 5.000 Vrms/V: 1.768 Irms/A: 17.675

I unplugged the analog wire and on the Serial Monitor, i see this:

Vpp/V: 0.000 Vrms/V: 0.000 Irms/A: 0.000
Vpp/V: 0.000 Vrms/V: 0.000 Irms/A: 0.000

But after i hold the analog wire between my fingers, i get this change:

Vpp/V: 5.000 Vrms/V: 1.768 Irms/A: 17.675
Vpp/V: 5.000 Vrms/V: 1.768 Irms/A: 17.675

So, it seems like the analog pin is detecting some change.

If You apply a multimeter, what voltage does the ACS712 send out? What voltage does the multimeter read from the divider?

Railroader:
If You apply a multimeter, what voltage does the ACS712 send out? What voltage does the multimeter read from the divider?

I actually disconnected the ACS712 current sensor to simplify the error diagnostic process. I touched the analog wire and it registers some value. I uploaded this simple sketch to check the analog values detected which should be between 0 and 1024:

const int analogInPin = A0;  // ESP8266 Analog Pin ADC0 = A0

int analogValue = 0;  // value read from the analog pin

void setup() {
  // initialize serial communication at 115200
  Serial.begin(115200);
}

void loop() {
  // read the analog in value
  analogValue = analogRead(analogInPin);
  
  // print the readings in the Serial Monitor
  Serial.print("ESP-01 analog pin value = ");
  Serial.println(analogValue);

  delay(1000);
}

This is the Serial Monitor output:

ESP-01 analog pin value = 1024
ESP-01 analog pin value = 1024
ESP-01 analog pin value = 1024
ESP-01 analog pin value = 0
ESP-01 analog pin value = 0
ESP-01 analog pin value = 1024
ESP-01 analog pin value = 1024
ESP-01 analog pin value = 0
ESP-01 analog pin value = 0
ESP-01 analog pin value = 0
ESP-01 analog pin value = 1024
ESP-01 analog pin value = 1024
ESP-01 analog pin value = 1024
ESP-01 analog pin value = 1024
ESP-01 analog pin value = 0
ESP-01 analog pin value = 0
ESP-01 analog pin value = 0
ESP-01 analog pin value = 0
ESP-01 analog pin value = 1024
ESP-01 analog pin value = 1024
ESP-01 analog pin value = 1024

The value is always 1024 and when i touch the wire, it changes to 0. I think this proves that the soldering to the analog pin is good and working. So, maybe i need to set up a potentiometer?

If You disconnect a wire connected to an analog input You will read just anything. Of course You need a voltage source to any input.

I built a potential divider with R2 = 100 Ohms and R1 = 400 Ohms, so that 5 V gets converted to 1 V. So, assuming that VCC pin input voltage on the ACS712 current sensor is 5 V (it’s connected to the 5V pin on the Arduino UNO) then when there is no load connected to the ACS712, it should give an output of 2.5 V for AC current sensing which is equivalent to 1024/2 = 512. But on the Serial Monitor, i’m getting a value of 350. I guess the voltage supplied from the Arduino UNO to the ACS712 module is not exactly 5 V, but in fact, probably much less. In the ACS712 datasheet, it says: 5.0 V, single supply operation. So, i think i cannot power it with 3.3 V like the ESP-01 and any lower than 5 V would not give reliable results. BTW, i am also powering the ESP-01 from the 3.3 V pin of the UNO which is itself plugged via USB port to my PC. The problem is that i don’t have a working multimeter to check the UNO’s voltage output. :frowning:

I am trying to measure AC current using the ACS712 20A model. I doubt that there is a mistake in my sketch but here it is for completion’s sake:

const int ACS_pin = A0;
const int mVperAmp = 100; // Output sensitivity in mV per Amp
// Use scale factor: 185 for 5A module, 100 for 20A module and 66 for 30A module

float VPP = 0.0; // peak-to-peak voltage
float VRMS = 0.0;  // RMS voltage
float IRMS = 0.0; // RMS current

float VRMSoffset = 0.0; //0.025; // set quiescent Vrms output voltage
//voltage at an output terminal with reference to a common terminal, normally ground,
//when no signal is applied to the input.

void setup() {
  Serial.begin(115200);
}

void loop() {
  VPP = getVPP(); // find peak-to-peak voltage
  VRMS = ((VPP / 2.0) * 0.707) - VRMSoffset; // divide by 2 to get peak voltage. 1 ÷ √(2) is 0.707
  IRMS = (VRMS * 1000.0) / mVperAmp; // first, multiply by 1000 to convert to mV

  Serial.print("Vpp/V: ");
  Serial.print(VPP, 3); // print to 3 decimal places
  Serial.print("\tVrms/V: ");
  Serial.print(VRMS, 3);  // print to 3 decimal places
  Serial.print("\tIrms/A: ");
  Serial.println(IRMS, 3);  // print to 3 decimal places
}

// function to measure peak-to-peak voltage
float getVPP()  // continously sampling and logging max and min values
{
  float result;
  int readValue; // value from the sensor
  int maxValue = 0; // to store max value, initialised at lowest value.
  int minValue = 1024; // to store min value, initialised at highest value.


  uint32_t start_time = millis();
  while ((millis() - start_time) < 3000) // sample for 3000 ms or 3 secs
  {
    readValue = analogRead(ACS_pin);
    // check if a new maxValue
    if (readValue > maxValue)
    {
      // record the maximum sensor value
      maxValue = readValue;
    }
    if (readValue < minValue)
    {
      // record the minimum sensor value
      minValue = readValue;
    }
  }

  // subtract min from max and convert range to volts
  result = ((maxValue - minValue) * 5.0) / 1024.0;
  return result;
}

After i upload the sketch above to the ESP-01, i get the error as described in my first post.

Attach some diagram. Shakespeare type diagrams only tell the things You are thinking about, not the things You are not thinking about.
You assume some voltage to be 5 volt. Did You measure and confirm that? Serial output can show almost anything depending on the real source.
Touching a proper voltage divider like 100/400 Ohm would hardly be affected by the touch of a finger assuming that 100 Ohm is connected to the controller ground.

Railroader:
Attach some diagram. Shakespeare type diagrams only tell the things You are thinking about, not the things You are not thinking about.
You assume some voltage to be 5 volt. Did You measure and confirm that? Serial output can show almost anything depending on the real source.
Touching a proper voltage divider like 100/400 Ohm would hardly be affected by the touch of a finger assuming that 100 Ohm is connected to the controller ground.

Here is the voltage divider that i'm using (Vin is the output from the ACS712 and Vout is the connection to the ADC pin of the ESP-01):
esp01adcpotentialdivider.png
I will try to find a working multimeter to check the voltage input and output of the ACS712.

esp01adcpotentialdivider.png

Hi;

I built a potential divider with R2 = 100 Ohms and R1 = 400 Ohms, so that 5 V gets converted to 1 V.
So, assuming that VCC pin input voltage on the ACS712 current sensor is 5 V (it's connected to the 5V pin on the Arduino UNO).
When there is no load connected to the ACS712, it should give an output of 2.5 V for AC current sensing which is equivalent to 1024/2 = 512.
But on the Serial Monitor, i'm getting a value of 350.
I guess the voltage supplied from the Arduino UNO to the ACS712 module is not exactly 5 V, but in fact, probably much less.
In the ACS712 datasheet, it says: 5.0 V, single supply operation.
So, i think i cannot power it with 3.3 V like the ESP-01 and any lower than 5 V would not give reliable results.
BTW, i am also powering the ESP-01 from the 3.3 V pin of the UNO which is itself plugged via USB port to my PC.
The problem is that i don't have a working multimeter to check the UNO's voltage output. :frowning:

esp01adcpotentialdivider.png
You will need to get a DMM.
What voltage do you get at Vout.
You need to actually measured Vin and Vout to check that you are measuring correctly?

Try 4000 Ohms and 1000 Ohms.
Put a 0.1uF capacitor from the analog input to gnd.

Tom... :slight_smile:

We - or I - have a saying here.

If you do not have a multimeter (and frankly, I only consider digital multimeters nowadays, analog ones were always painful), then carefully put all your Arduino and electronic bits in a box, put it up on the shelf and take up knitting until you get the multimeter. :grinning:

Going price for a multimeter adequate to do most of what you need to do with Arduinox - is $5.

Also - buy two. That allows you to verify what is happening to both sides of a problem, for example voltage and current to a device. Also to check the battery of each other. :sunglasses:

The esp8266 uses the same ADC to evaluate the strength of the WiFi signal. Use of analogRead in every loop disturbs the ADC and the WiFi power measurements are inaccurate, the driver evaluates the WiFi signal wrong. If as weak, then it drives up the RF TX power, which leads to higher Vcc power consumption, until the powering fails into brown out, which leads to crash.

Even if your sketch doesn't connect to WiFi, the esp8266 will try to connect to last remembered WiFi, if you didn't disable auto-connect.

Try 10000 over 1000

You should get readings

If you put a pot in seriies with the 1000 you should be able to vary the readings

[ add]
Vcc 10k ohms. To ADC in to 1k ohms to ground.
Should be half a volt so should put you in the middle of the ADC.

Your drawing doesn't show the whole schematic.
Grounds tied together etc.....

I take it the bottom of the divider is connected to both the 8266 and the sensor ...

DryRun:

Soft WDT reset

I see the discussion moved away from this issue quickly - did you solve it?

This error is usually a case of poor programming - specifically blocking code, no allowing the background processes to run for more than iirc 250 ms.

wvmarle:
I see the discussion moved away from this issue quickly - did you solve it?

This error is usually a case of poor programming - specifically blocking code, no allowing the background processes to run for more than iirc 250 ms.

and brown-out

OK, i have a new multimeter ordered but until it arrives, i have replaced the ACS712 current sensor with a potentiometer to simulate the sensor and set up a new voltage divider with 100 Ohms and 220 Ohms. Here are the relevant connections:

And this is my setup, where i am using the Arduino UNO to power the ESP-01 with 3.3 V and also, for its serial-to-USB converter:
ESP01ADCpotsetup.jpg

I am using the same sketch as in my post #2. The Serial Monitor output looks like the A0 pin reading is working when the potentiometer is varied from minimum to maximum and back to minimum:

13:01:17.362 -> ESP-01 analog sensor value = 0
13:01:18.388 -> ESP-01 analog sensor value = 0
13:01:19.381 -> ESP-01 analog sensor value = 0
13:01:20.375 -> ESP-01 analog sensor value = 1
13:01:21.368 -> ESP-01 analog sensor value = 15
13:01:22.361 -> ESP-01 analog sensor value = 20
13:01:23.387 -> ESP-01 analog sensor value = 28
13:01:24.380 -> ESP-01 analog sensor value = 38
13:01:25.376 -> ESP-01 analog sensor value = 46
13:01:26.370 -> ESP-01 analog sensor value = 60
13:01:27.396 -> ESP-01 analog sensor value = 77
13:01:28.389 -> ESP-01 analog sensor value = 198
13:01:29.383 -> ESP-01 analog sensor value = 977
13:01:30.376 -> ESP-01 analog sensor value = 1024
13:01:31.369 -> ESP-01 analog sensor value = 1024
13:01:32.395 -> ESP-01 analog sensor value = 973
13:01:33.388 -> ESP-01 analog sensor value = 892
13:01:34.381 -> ESP-01 analog sensor value = 277
13:01:35.374 -> ESP-01 analog sensor value = 125
13:01:36.400 -> ESP-01 analog sensor value = 80
13:01:37.393 -> ESP-01 analog sensor value = 41
13:01:38.386 -> ESP-01 analog sensor value = 22
13:01:39.380 -> ESP-01 analog sensor value = 13
13:01:40.373 -> ESP-01 analog sensor value = 0
13:01:41.366 -> ESP-01 analog sensor value = 0

Juraj:
The esp8266 uses the same ADC to evaluate the strength of the WiFi signal. Use of analogRead in every loop disturbs the ADC and the WiFi power measurements are inaccurate, the driver evaluates the WiFi signal wrong. If as weak, then it drives up the RF TX power, which leads to higher Vcc power consumption, until the powering fails into brown out, which leads to crash.

Even if your sketch doesn't connect to WiFi, the esp8266 will try to connect to last remembered WiFi, if you didn't disable auto-connect.

That was super helpful, as i researched and found this: analogRead forces WiFi to disconnect · Issue #1634 · esp8266/Arduino · GitHub and reading through the comments, i came across a developer who put in some fantastic work for this specific issue: GitHub - krzychb/EspScopeA0: On-line wave-forms of ESP8266's A0 in a web browser using web sockets. I am testing his Alfa sketch: EspScopeA0/Alfa at master · krzychb/EspScopeA0 · GitHub
My objective is to read analog values using the ESP-01 and use its Wi-Fi functionality to display the live sensor readings on a web page accessible via IP on the local network.

ESP01ADCpotsetup.jpg

Juraj:
and brown-out

Indeed. In my experience ESP-01’s are sensitive to power supply layout issues and with the ESP-01 getting power from a couple of long test leads like that, it’s frankly surprising it works as well as it does.

Some people have had luck with soldering a low ESR capacitor across the power pins, but it’s best to have it on carrier board with the regulator and bypass capacitors close to the pins.

I would recommend strongly that anyone starting with ESP8266 use one of the ESP boards with integral voltage regulator like the NodeMCU boards. The ESP-01 is a subsystem module designed to be mounted in a socket on a larger board which provides robust power. As a standalone board it’s not very reliable.

MrMark:
The ESP-01 is a subsystem module designed to be mounted in a socket on a larger board which provides robust power. As a standalone board it's not very reliable.

These are very useful as a start when using a "USB charger" for power.