Go Down

Topic: Wemos A0 does not read voltage (Read 831 times) previous topic - next topic

srozemuller

I have a Wemos D1 Mini pro where I like to measure the battery lifetime. I've connected the + to the A0 with a 100K resistor.

When I read the A0 without a battery connected it gives the same results as with a connected battery.
The results always are 2 (sometime 1)
But when a connected battery it should give 1023 or something.

Ive did some tests with a multimeter and tells me there is 3.6 volts on the pin. So question is why i don't get raw data but only 2 (sometimes 1)

Code: [Select]
// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  // print out the value you read:
  Serial.println(sensorValue);
  delay(1);        // delay in between reads for stability
}




6v6gt

Maybe look at   ESP.getVcc()  for measuring the battery voltage. This does not use A0.

A series resistor, as you have described, would have no impact on the voltage measured on A0. To do that, you'd need two resistors in the form of a potential divider: one at 0 volts, one at Vcc and the reduced voltage can be measured at the point where the 2 resistors are inter connected.

Wawa

OP already has been told that there is a 220k:100k voltage divider on a Wemos D1 Mini pro.
Only an extra 100k series resistor is needed to increase measuring range from ~3.2volt to ~4.2volt.

Maybe the analogue input of the WeMos is damaged, maybe the battery is not properly connected to A0.
We won't know until we see a clear picture of the setup.
Leo..

6v6gt

OK. Yes. I see it.  https://escapequotes.net/wp-content/uploads/2017/06/esp8266-wemos-d1-mini-pro-schematics.png

Unlike the raw module and some ESP8266 other breakouts, you do not, on the Wemos, get the ADC pin directly but via a voltage divider. On the raw module, the ADC pin tolerates a maximum of 1 volt.

I found another variant of measuring Vcc at http://esp8266.github.io/Arduino/versions/2.0.0/doc/reference.html  (see Analog input) but again, it is of no use if the OP is measuring something the other side of the voltage regulator.

I'd recommend a delay of say 100 instead of 1. Serial.print() is not so useful at 1 line per millisecond. 

srozemuller

#4
May 20, 2018, 04:27 pm Last Edit: May 20, 2018, 04:43 pm by srozemuller
OP already has been told that there is a 220k:100k voltage divider on a Wemos D1 Mini pro.
Only an extra 100k series resistor is needed to increase measuring range from ~3.2volt to ~4.2volt.

Maybe the analogue input of the WeMos is damaged, maybe the battery is not properly connected to A0.
We won't know until we see a clear picture of the setup.
Leo..
Hello Leo, could you explain what you need? I tried to explain the situation a detailed as possible.

OK. Yes. I see it.  https://escapequotes.net/wp-content/uploads/2017/06/esp8266-wemos-d1-mini-pro-schematics.png

Unlike the raw module and some ESP8266 other breakouts, you do not, on the Wemos, get the ADC pin directly but via a voltage divider. On the raw module, the ADC pin tolerates a maximum of 1 volt.

I found another variant of measuring Vcc at http://esp8266.github.io/Arduino/versions/2.0.0/doc/reference.html  (see Analog input) but again, it is of no use if the OP is measuring something the other side of the voltage regulator.

I'd recommend a delay of say 100 instead of 1. Serial.print() is not so useful at 1 line per millisecond. 
I set the delay to 100 but no difference


Is there any way to test the A0 if it is damaged or not.

PaulRB

From what I hear so far, this does sound like a faulty or damaged Wemos. To confirm, connect a pot across 3.3V and ground with the wiper directly to A0. See if you can get any other reading.

srozemuller

From what I hear so far, this does sound like a faulty or damaged Wemos. To confirm, connect a pot across 3.3V and ground with the wiper directly to A0. See if you can get any other reading.
Hello Paul, im very new into this. What is a pot and wiper? Could you explain the wiring.

PaulRB

A pot is a potentiometer, which is a variable resistor. It has 3 terminals. Two at each end of its track and a third called the wiper, which moves along the track when you turn or slide the knob.

The fact that you don't know these terms makes me concerned that you are trying to run before you can walk, and have not gained important experience of the basics before moving on to complex circuits.

srozemuller

#8
May 20, 2018, 07:45 pm Last Edit: May 20, 2018, 08:09 pm by srozemuller
The fact that you don't know these terms makes me concerned that you are trying to run before you can walk, and have not gained important experience of the basics before moving on to complex circuits.
True, as i said, im very new into this and learning. im a quite good programmer but do not have the experience in circuits.

Thank you for your feedback, i also dont have a meter like that. for now maybe the best choice is to buy a new one.

I've just tried the VCC mode. But that show's the internal voltage and is not the same as the powerlevel of the battery. The battery supplies 3.7 volt, the internal volt now is 2.89.

6v6gt

Here is an example which includes a battery voltage monitor. Interestingly, it includes a pinMode() statement for A0.

pinMode(A0, INPUT);

Usually, this would not be necessary but maybe worth a try.
Certainly, based on your attempts to use the VCC mode, the ADC is still working.


PaulRB

it includes a pinMode() statement for A0.
That's a red herring, I'm afraid. None of my sketches that use A0 to read battery voltage do that.

westfw

Quote
A series resistor, as you have described, would have no impact on the voltage measured on A0.
Not ALL microcontroller ADCs have high input impedence, and they CAN be affected by using a series resistor with too high a value.  IIRC, some of the 8bit PICs have an input impedence of ~10k - using a 100k series resistor would be a very bad idea on one of those.

wvmarle

I've just tried the VCC mode. But that show's the internal voltage and is not the same as the powerlevel of the battery. The battery supplies 3.7 volt, the internal volt now is 2.89.
That sounds quite reasonable: there's a voltage regulator on board. I did a quick search on what regulator the WeMOS mini uses, it seems older boards use the AMS1117-3.3 which has a 1.1V minimum dropout; the newer boards have a RT9013 which has a much lower dropout of just 250 mV.

The values you give are consistent with the AMS1117-3.3 regulator of the older boards, which would give a 4V battery output, which is very reasonable for a near-fully charged LiPo.

By the way, are you sure about that 3.7V? That's the nominal value of a LiPo battery but the real output is usually somewhere between 3.2V and 4.2V depending on the charge. Did you measure that with your multimeter?
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

srozemuller

#13
May 21, 2018, 07:44 am Last Edit: May 21, 2018, 07:50 am by srozemuller
By the way, are you sure about that 3.7V? That's the nominal value of a LiPo battery but the real output is usually somewhere between 3.2V and 4.2V depending on the charge. Did you measure that with your multimeter?
I did a measure with the multimeter on the + of the battery and tells me the battery is providing 3.7 volts, this could be fine because the battery isn't fully charged.

Not ALL microcontroller ADCs have high input impedence, and they CAN be affected by using a series resistor with too high a value.  IIRC, some of the 8bit PICs have an input impedence of ~10k - using a 100k series resistor would be a very bad idea on one of those.
So the situation where im in now is not ok? Using a 100k resistor between the + and the A0.


Here is an example which includes a battery voltage monitor. Interestingly, it includes a pinMode() statement for A0.

pinMode(A0, INPUT);

Usually, this would not be necessary but maybe worth a try.
Certainly, based on your attempts to use the VCC mode, the ADC is still working.


I also tried the INPUT way but doesn't make sense. As PaulRB said, the most sketches i saw doesn't have a Pinmode either.


BTW nice to hear the ADC is not broken, so there is something else why the output is always the same.

Another thing i was wondering:
Does a connected USB to the laptop affect the reads? 

PaulRB

I also thought I remembered seeing rt9013 regulators on Wemos mini schematics. But if you check their website now, all current and previous versions of the mini and mini Pro use me6211.

I don't think they ever used ams1117, unless that was the D1 or D1R2 (the Uno size boards).

Maybe you were thinking of the nodeMcu boards?

Go Up