Notifications
Clear all

Analog to Digital Converters Overload???

57 Posts
4 Users
35 Likes
3,997 Views
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1900
Topic starter  

Hardware challenged... I am. 🙄Β 

Have a question about analog to digital converters.Β  If specific model is important, I'm interested in the one on the A0 pin of an ESP8266.Β Β 

  1. I will be powering a WeMos ESP8266 with a 18650 battery shield.Β  When plugged up, it'll be supplying 5V to the WeMos 5V pin.Β  The WeMos uses some converter to 3.3V for the ESP8266's use.Β Β 
  2. The battery shield uses some converter of its own to maintain 5V output even though the 18650 goes from 4.1V to 3V as it discharges.
  3. Because of (#2) using the ESP8266 feature of ADC_MODE(ADC_VCC); to measure supply line voltage isn't really telling me the state of the battery.

What I want to ask if this should work AND not damage the WeMos...

  1. Can I run a wire from the positive 18650 battery terminal to the A0 pin and measure the battery voltage?Β Β 
  2. I know the A0 pin measures up to the 3.3V.Β  If the battery is fresh at 4.1V... does that fry the A2D or does an analogRead() just get the max value until the battery dips below 3.3V?
  3. If it does damage the A2D, should I use a voltage divider to convert 4.1 down to 3.3?Β Β 
  4. For #3... I know how to calculate the resistanceΒ ratio, but I don't know how to figure what range... 10, 100, 100... 10K of resistors.Β  My logic says lower ones will draw more power (draining the battery faster).Β  How high should I go?

Thank you for any help you can give.

VBR

Inq

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
Quote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6939
 

I think you answered your own question, ANY voltage divider is going to drain (waste) power. As you know the amount you waste is directly proportional to the size of the resistors.

I am wondering if you need to constantly monitor the state of charge of the battery or can you get away with checking it periodically.

BTW, I have a decent sized battery bank in my RV and it does NOT use that method at all, it uses a shunt. That may be another area of investigation. You input the battery specs, basically it's capacity and it keeps track telling you hours left at current consumption rate, number of AH left and so on.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1900
Topic starter  

OK, Let's take that one step at a time.

First - Can I run a wire from the positive 18650 battery terminal to the A0 pin and measure the battery voltage?... Electrically, is this a problem to power through the shield AND measure the voltage directly from the same battery on the shield?

powering

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6939
 

@inq I don't know for sure, like I said, most RVers, boaters, and solar homes measures battery life/health/DOD/SOC, call it what you will with a shunt. Determining that with voltage only is not very accurate.Β 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1900
Topic starter  
Posted by: @zander

Determining that with voltage only is not very accurate.Β 

I understand.Β  In my boat, I use quite a sophisticated (bought) unit for my LiIon battery bank (32kWh).Β  Β This question is just for a toy robot not much bigger than a coffee mug.Β  I need a demonstrator/test-bed for my next addition to the InqPortal library.Β 

The WeMos A0 pin is already there... the positive battery terminal is already there... one wire and I plug-r-up when it reaches 3.0V.

Β 

For this 1st question - I guess I could drain a cell down to 3.3V and just try it.Β  It'll either work or not.Β  I was just hoping a hardware expert could say... "it won't work, because of ... Xxxx xxx xxxx."Β  Β (Some deep electronic hardware / circuitry aspect.)

In my mechanical based brain... this dual +power connection feels kind of like, "Picking yourself up by your boot straps."

VBR,

Inq

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
ReplyQuote
Inst-Tech
(@inst-tech)
Member
Joined: 2 years ago
Posts: 554
 

@inq IF the ESP8266 is a 3.3VΒ  I/O device, than, no, a direct wiring to the A0 input of the ADC is not advisable. In the matter of the shunt, it is a very low resistance that is measuring the current by developing a voltage drop across it, albeit in very low millivolts, but it is a very high precision resistor. here's a link to a very basic Shunt operation; https://eepower.com/resistor-guide/resistor-applications/shunt-resistor/#

In general, measuring the voltage drop of the battery is not a very accurate way to determine battery capacity. With out knowing what the current load is, as the position of the resistor in the circuit can give you inaccurate readings because of the common mode voltage that can be produced.

Using a Shunt would give much better results, be the problem there would be the ESP8266 is a 10 bit ADC, and therefore has a resolution of 3.3/1024 = 3.22 mV per count, so you'd have to choose a shunt that will give you the mV range that you need for the current load required.

regards,

LouisR

LouisR


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6939
 

@inq Yes, but they do make teeny tiny shunts too. However, I just saw a few days ago a Pico project for measuring the voltage of its own power supply (18650). Of course I ordered one and a few more goodies so let me see what I can find real quick.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6939
 

@inq Check this out. It may work, it is arduino capable as well as RPI

https://www.waveshare.com/wiki/Current/Power_Monitor_HAT

Β 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6939
 

@inq WOW, I just noticed the 32kWh reference, are you welding? Mine is 7.2kWh and I run everything except AC, fireplace, dryer which I can get by without when off grid. I have 6 x 190W panels which is close to the max I can get on my roof.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1900
Topic starter  

@inst-tech, @zander,

I understand that shunts are the way to go if I REALLY want an accurate and definitive answer.Β  I do use them where I need to...Β  The boat has several built-in to the power management system for the LiFePO4 battery.Β  An investment like that deserves using shunts... a robot made with $10 worth of components and 50Β’ worth of 3D printed plastic... not so much.

My only purpose for pursuing this idea...

  • Curiosity in experimenting - That curiosity is worth something... but not blowing out the WeMos.
  • It's free for the price of a wire - If I don't blow-out the WeMos
  • Just to keep the LiIon cell from being drawn down into area that permanently damages it (< 2.0V).Β  I plan for the robot to let me know when it goes below 3.0V.

VBR,

Inq

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6939
 

@inst-tech Good article re shunts. I often comment to folks doing a solar install and a lot of them just can't grasp that ALL the current has to go through the shunt to make sense of the system. I tell them only one wire on battery negative to the shunt, all other including frame is to the other side of the shunt.

I have a question you may know the answer to. I have always thought the master battery disconnect should go on the positive terminal (or as close as possible) but I have seen quite a few commenters say it should go on the negative. If that is in fact correct, what then is the order, battery, disconnect, shunt, load? Or does the disconnect go elsewhere?

My reasoning is that if I touch any positive wire after the cutoff in my scenario I am touching nothing so to speak but in the negative leg scenario I am touching HOT and even though there is no path to ground, I am energized and who knows what can happen. Any thoughts?

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
Inst-Tech reacted
ReplyQuote
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1900
Topic starter  
Posted by: @zander

@inq WOW, I just noticed the 32kWh reference, are you welding? Mine is 7.2kWh and I run everything except AC, fireplace, dryer which I can get by without when off grid. I have 6 x 190W panels which is close to the max I can get on my roof.

Fat-fingered the decimal place.Β  That's why bridges fall down, rockets fall out of the sky.Β  Good thing, I'm retired.Β  😆Β 

I can't correct my post above.

I looked through my Battery Build notes... 3.6 kWh.

Β 

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6939
 

@inq I understand. I don't know how tolerant a 3V pin is.

The reason for my mentioning the shunt is that if you use a voltage divider, you might drain your battery very quickly depending on how you configure it.

Why not put it on a switch, or if really ambitious a semi-conductor switch and a timer running on the board that briefly enables the pin. Maybe a 10% duty cycle is all you really need.

Instead of a switch, would a resistor in series with the A0 pin do the job, you only need to drop about .9V at max IIRC.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
Inst-Tech reacted
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6939
 

@inq Ok, that's a little on the small size then but maybe not if you are close to the equator. Half my load is the residential refrigerator. It is one of the modern digital inverter types, but still consumes 1.5kWh's per day. For boondocking under normal (no furnace) conditions and no sun I can probably last 5 to 7 days.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1900
Topic starter  

Caution to the wind...

powering
  • I first hooked upΒ just the WeMos to the battery shield.
  • I used my bench power supply set to 3V and powered the A0 pin just to confirm my Sketch was reporting correctly.Β Β 
  • Got 966 =>Β  966/1024*3.3V = 3.11VΒ  (4% error)
  • So I know my Sketch reads voltage OK.
  • The battery I found in my pile was registering 3.61V.
  • Before I thought about what I was doing I connected it to theΒ WeMos A0 pin as illustrated above.
  • As expected since 3.61 is above 3.3V, I got 1024 on the Sketch reading.
  • And as luck would have it, I didn't release the Smoke.

So the next question on the table it:

Should I try with a fresh LiIon cell at 4.2V?????

I'd rather not destroy the WeMos.Β  Does any hardware savvy members know if the A0 pin can tolerate almost 1 extra volt?Β  Again... it doesn't matter if it reports 1024 as it will for anything above 3.3V.Β  I only care about the voltage readings as it approaches 3.0V.

I'm hoping it has a high resistance like an ohm meter and just tolerates the 4.2V.

VBR,

Inq

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
ReplyQuote
Page 1 / 4