Tech Note 115 - Using the ESP32 ADC for wide range DC voltage measurements

  Переглядів 67,496

G6EJD - David

G6EJD - David

День тому

Using the ESP32 to measure a wide range of DC voltages.
Link to calculator:
www.ohmslawcalculator.com/volt...
Code examples:
github.com/G6EJD/ESP32-DC-Vol...

КОМЕНТАРІ: 143
@deangreenhough3479
@deangreenhough3479 5 років тому
Always a pleasure and always worth the time to absorb your technical notes and YES I do find them very useful 😀🏴󠁧󠁢󠁥󠁮󠁧󠁿
@iotsolutionslk
@iotsolutionslk 2 роки тому
Excellent presentation with examples. Really appreciate mentioning the safety precautions.
@rudyhenderson5002
@rudyhenderson5002 2 роки тому
Outstanding presentation with very helpful references. Good job!
@daverei1211
@daverei1211 2 роки тому
Thank you Dave, very useful. I’ve mostly been using the Parallax Propeller chip over the last 15 years and recently found the ESP32cam, I’ll have to try this on pin 13 to read my water tank level using a psi sensor and a tube.
@G6EJD
@G6EJD 2 роки тому
That will work
@andrewkieran8942
@andrewkieran8942 5 років тому
Thanks Dave, for another great video. I'd like to add that the 'full scale' A/D reading isn't 3.3V but rather the Vdd to the ESP32. Some folks may not realize that the regulator on their development board may be way off from it's specified output voltage. Also, ripple needs to be tamed to get trustworthy A/D values.
@G6EJD
@G6EJD 5 років тому
I do mention that in my opening remarks and it’s a very important point you make, as the maximum value of ADC input is quoted as Vdd - 0.3v according to the data sheet or 3v typically.
@AbuSous2000PR
@AbuSous2000PR 5 років тому
I appreciate your efforts This takes a lot of time to prepare and tp produce
@xThirdOpsx
@xThirdOpsx Рік тому
Golden content, exactly what I was looking for. Thanks a lot!
@embeddedprogrammer6276
@embeddedprogrammer6276 3 роки тому
Excellent video. Thanks for the links to the calculator.
@paulz8750
@paulz8750 Рік тому
Really appreciate you making this which is extremely useful.
@souzamce
@souzamce 4 роки тому
Thank you very much. It was a pretty good class.
@dehoffe
@dehoffe 5 років тому
Thank you, very nice video and information. Excatly what i was looking for.
@g7mks383
@g7mks383 Рік тому
Thanks very clear and well explained. I been struggling with getting reliable readings on a project that is monitoring a 12 volt battery being charged by solar panels remotely over the internet. This explains a lot to a novice programmer like myself and will help. Thanks for your time and effort.
@buzzbuzz7031
@buzzbuzz7031 3 роки тому
Thanks for the great video David! was just wondering if there are other things to be taken into account i.e. resistors power rating? Also, you mentioned how much the input impedance should be, which resistor represents the impedance or both? Thanks!
@G6EJD
@G6EJD 3 роки тому
I mentioned the ESP32 impedance because it affects the calculations, it varies from device to device, but on the whole is relatively high but enough to skew the calculations. Yes power rating of the resistors is a consideration but for all but the highest voltages >50v should be well within a 1/4 watt resistor rating. p=V^2/R
@djatiecitra
@djatiecitra Рік тому
Thank you for the explanation.
@usmanumer9871
@usmanumer9871 3 роки тому
easy to understand . best tutorial
@billmckinzie
@billmckinzie 3 роки тому
Great work sir.
@subratadey
@subratadey 5 років тому
This is really helpful thank you so much... Also wanted to ask if you have any notes on ready AC voltages?
@G6EJD
@G6EJD 5 років тому
When measuring AC voltages there are a couple of approaches that can be used, the first is to downscale the AC voltage using a voltage divider and apply this via a capacitor to a voltage offset usually two equal resistors across the 3.3v rail, this is to allow the ADC to measure the positive and negative swings, then the incoming waveform needs to have a zero detection and then sample the whole waveform to then compute the RMS value from the peak to peak values. It gets complicated! Alternatively, apply the AC of suitable voltage probably downsized by a voltage divider to a diode and capacitor to ground, this will then charge to the peak value from which the RMS value can be found by measuring the now DC by the ADC like any other DC measurements. I’ll try to summarise all this in another technical note, it’s really quite easy to do, but safety is a concern I need to consider.
@subratadey
@subratadey 5 років тому
@@G6EJD Wow! Thank you so much for the detailed overview. I shall try this while I wait for you to prepare a video on this. Really appreciate the effort :) Cheers!!
@G6EJD
@G6EJD 5 років тому
Subrata Dey, all you need to do is feed AC to a diode eg IN4001 and then a capacitor to ground of about 10uF then measure the DC with the ADC
@uweri_3851
@uweri_3851 5 років тому
like allways....best of class
@note380
@note380 4 роки тому
Thank you for this video, would you kindly show how to change the adc ref say to use 1.1V?
@G6EJD
@G6EJD 4 роки тому
The ESP32 ADC reference voltage is already nominally set at the factory to 1.1v although in some earlier devices it can range from 1.0 to 1.2v. You can route the internal reference input to GPIO25 and apply your own, which you’d need to measure accurately and then recalibrate the ADC but the advantages in doing this aren’t that great. What is the problem your trying to solve?
@futi2868
@futi2868 3 роки тому
First of all, your posts are great, many thanks ... What would you recommend for "U> 100V" RMS for high voltage measurements, is it possible to share resources?
@G6EJD
@G6EJD 3 роки тому
Well even at 1/4 watt a simple resistor voltage divider is perfectly safe up to 100v, but augmented with adequate terminal protection. Even up to 220v it’s still quite safe again with appropriate power ratings, what factors were you considering.
@fuatayeri
@fuatayeri 3 роки тому
​@@G6EJD I need to take stable measurements over a wide measuring range of maximum 500V rms. "4kW" PF = 0.99/ 0.97 induction cooker and measuring device required for white goods testing
@rtilt143
@rtilt143 4 роки тому
Thank you for sharing your knowledge and experience. I'm using an Espressif ESP32-WROOM-32D, a bench style DC power supply, R1=100K, R2=14.7K, which should allow for a maximum input voltage of 25.749, assuming a desired V out of 3.3. The readings I'm getting using the provided code are not linear, meaning, they are more accurate when input voltages are closer to the maximum input, and substantially less accurate when input voltages move further away from the max input of 25. Is this the expected behavior? Thanks again for making great videos.
@G6EJD
@G6EJD 4 роки тому
Pleased to hear I’m helping you out. The non-linearity your seeing is not typical, the most linear region of the ADC is between 0.5v and 2.8v and outside of this range you will see non-linearity. Any variation in input impedance is more likely to be the cause, but just less than 100K should provide enough input current to operate the ADC correctly, I assume there are no further attenuation resistors in the circuit. From the parameters you have provided everything should work as expected. You can improve the linearity if the ADC with some mathematics and I produced a function to do this in one of my other TN’s improving ADC linearity.
@rtilt143
@rtilt143 4 роки тому
@@G6EJD Will be sure to read and or watch / learn more about ADC linearity, thanks for the quick reply.
@aclam9839
@aclam9839 5 років тому
But still enjoy your very informative posts
@GuyGreggo
@GuyGreggo 4 роки тому
Thanks, very helpful.
@dougbas3980
@dougbas3980 5 місяців тому
Well done.
@tycstahX
@tycstahX 5 років тому
Love this channel!
@tycstahX
@tycstahX 5 років тому
Let's go fry some esp32s... ;)
@Edmorbus
@Edmorbus Рік тому
Thanks for sharing
@piotrojdana3369
@piotrojdana3369 5 років тому
I have a question about battery, let say we have 4.2V converted by voltage divider to 3.3V. What happens if the battery voltage drop to 3.5V? We will have possibility to read correct voltage via voltage divider? Or rather this method is only for constant power supply? Any feedback appreciated.
@G6EJD
@G6EJD 5 років тому
Piotr Ojdana, the input range will be 0-4.2v and divided down to 0-3.3v. So if the input is 0v the reading will be 0v or if 2.1v the voltage divider output will be 1.65v, it’s just a method of changing the default 0-3.3v to whatever range is required. The ADC reading needs to be scaled to a 4.2v maximum then you will get an accurate voltage reading just like a DVM would do.
@erichertsens
@erichertsens 11 місяців тому
Thanks, appreciated 👍
@billd01rfc
@billd01rfc 4 роки тому
Hi, thnx for the info, very useful - however . . . I consistently see 4095 on the ADC raw output at 3v . . . not 3.3v as you describe. Not a huge issue, I just adjust the V-Diver values accordingly. Thoughts on why this could be? Thnx again for your informative videos. cul billd
@G6EJD
@G6EJD 4 роки тому
Bill, there are a number of reasons, component tolerance associated with the voltage divider, or production variations in the ESP32 and it’s ADC reference voltage and measuring equipment tolerances. Your observations could be due to a combination of all three. The Espressif data sheet shows a maximum ADC reading of Vcc which is 3.3v, I have never seen an ESP32 that can’t read to 3.3v, so assuming yours is a genuine ESP32 then next I would check for DVM accuracy and next that the voltage divider values used are correct. With so many variables it’s near impossible to produce a design solution that compensates for all the tolerance bands. The only solution is to vary the divider as you have already surmised.
@billd01rfc
@billd01rfc 4 роки тому
​@@G6EJD Yes, many variables, and it's not a genuine ESP32 - the cheapest I could find to experiment with . . . Anyway I want to use it to monitor a Solar Cell output and a 3.7v Battery Level, so I've mapped the range in the linear portion, customised the V-Divider, and have a pretty accurate scale for the narrow range I need. Thnx again for your great series of informative videos. billd
@quaternion-pi
@quaternion-pi 5 років тому
Great practical examples. 73 - K6CCA
@allasayegh1411
@allasayegh1411 2 роки тому
super useful ... thanks a lot
@Try58
@Try58 10 місяців тому
May I ask why my esp32 is getting a lot of noise and random peaks values when the ADC input is a DC value? For example, the input is receiving 1.65V (A battery with only a resistor connected to ground and input, nothing else) which should be around 1700, but I'm getting noise of around 1750, 1650 and sometimes peaks of 2300. And it only happens with DC voltage, for AC voltage it read perfect, given an senoidal it will read and plot in the serial plotter perfectly a senoidal.
@G6EJD
@G6EJD 10 місяців тому
Well it will be a function of your ESP32 supply noise, do you have sufficient and good enough smoothing and filtering. You should have a largish smoothing capacitor say 47uF or maybe 10uF and at least 0.1uF ceramic capacitor. The ceramic type is important as unlike larger tantalum capacitors are not inductive, therefore it can filter out transients on the supply. Also in theory the battery should act as a capacitor and its impedance is so low it should not allow any transients, so it proves almost conclusively it must be supply noise. It will still be there when measuring AC but less noticeable. Adding a small 0.1uF capacitor across the ADC to ground will help too. What value series resistor are you using? You can also counteract quantisation noise from the ADC by using a simple averaging technique of taking say 10 readings in succession then dividing the result by 10, which is a common method. The ADC is so fast in most applications the method will be indiscernible in practice.
@reiya6563
@reiya6563 11 місяців тому
I want to test this voltage divider at 5V maximum. Because i have only 10k & 1k resistor, so i use r1 10k & r2 1k ohm. I test the voltage at R2 and the result is around 0.45 V but in esp32, the result is around 0.3V (after i calculate it with adcvalue * (3.3/4095) ). Also i have try to put 0.1uF capacitor but the result was same. Can you help me ?
@G6EJD
@G6EJD 11 місяців тому
Try adcvalue * 3.3 / 4095 * 0.5/0.3;
@CATips
@CATips 4 роки тому
Sir I have using water tank level transmitter for measuring the tank level. The transmitter out is 1 to 5 V variable Means 1V need to set 0% 2V need to set 25% 3V need to set 50% 4V need to set 75% 5V need to set 100% Can you make gauging display via blynk app with modemcu Please make code for me
@pd8559
@pd8559 3 роки тому
Excellent coverage of all the details, but wouldn't expect any less of a HAM operator 🤣
@18770299
@18770299 Рік тому
Great! Thanks
@Cordic45
@Cordic45 4 роки тому
SHIT WOH MAKE THIS VIDEO!!?????? OMG THIS SECTION IS GOD DAMNES GOOOOOOOOOOOOOOOOOD
@0124akash
@0124akash Рік тому
Sir, can I measure same time dc and ac voltage using esp32 ?
@G6EJD
@G6EJD Рік тому
You can measure DC easily, but an AC voltage needs signal processing to convert it to what’s called a Root Mean Square value that is the equivalent of a DC measurement. To do this a full cycle of the AC waveform would need to be sampled over say 256 samples then the RMS calculation performed to give the final reading. Measurement of an AC waveform is complex especially if the waveform is distorted.
@MPElectronique
@MPElectronique 4 роки тому
Hi Dave. I have a 4.2v battery 18650 cell, i want to mesure the voltage with ESP8266 i tried your trick, but i dont really understand the dynamic... what would be the calculation.. i take 320k as R1 + 100k as R2 i have an ADC value of 268... i made the calculation: 268/1024 * 4,2v * (320000 / 100000) = 3,51v .. why i cannot have 4,2 v mesure ?? thanks a lot for your help!!! Marc.
@G6EJD
@G6EJD 4 роки тому
Marc, wired as Vin===320K===ADC input===100K===Gnd gives you a voltage input range of 4.2v or Vin at ADC = Vin * 100/(320+100) in code terms: float voltage = readanalog(A0) / 1023 * 420 / 100; If your using a Wemos D1 mini it already has a 220k-100k voltage divider on-board, so would need some extra series resistance say 100k to make it 320k-100k
@G6EJD
@G6EJD 4 роки тому
So your reading of 328 is giving the correct result for the voltage divider, but I suspect your using a Wemos D1 Mini with an on-board 220k-100k voltage divider which for a 4.2v input AND the addition of a parallel network yields a reading of 342 but exact values depend on the individual ADC reference that do vary. So if using a Wemos D1 Mini just insert a 100K series resistor to the A0 pin where it adds to the on-board voltage divider.
@G6EJD
@G6EJD 4 роки тому
I think to really understand what’s goi g on I need to know the exact board type your using. Also did you measure the cell voltage by independent means like a DVM?
@MPElectronique
@MPElectronique 4 роки тому
@@G6EJD = 1,3466 v which is far away from 4,20v. Im really messes up... :(
@G6EJD
@G6EJD 4 роки тому
What board type?
@aclam9839
@aclam9839 5 років тому
Comment on "accuracy" ... depends heavily on the accuracy/stability of the power supply to the ESP ...... Fell into that hole when making a lithium battery charger !!!
@G6EJD
@G6EJD 5 років тому
Yes it’s all relative but the ADC uses an internal reference so device supply variations have minimal effect on the readings, then there’s the ADC linearity, which is not that good, but can easily be improved to
@nirornkong416
@nirornkong416 2 роки тому
Excuse me!May I ask you something?If we have the voltage value so could you tell me the formula convert from voltage to pH value?Thank you in advance
@G6EJD
@G6EJD 2 роки тому
It depends on the sensor your using, what type is it? You need to know it’s output characteristics
@nirornkong416
@nirornkong416 2 роки тому
@@G6EJD Its output voltage 0~3.0 and I’m using it with esp 32 30pin.I really need this information,because I’m doing my project related to pH sensor and esp32.
@nirornkong416
@nirornkong416 2 роки тому
@@G6EJD May I have your Facebook or Instagram account?
@G6EJD
@G6EJD 2 роки тому
Ok so if the output voltage is 0-3.0 then that represents a pH range of ? 0-7 or 5-7 or?
@nirornkong416
@nirornkong416 2 роки тому
@@G6EJD Represent range 0-14 sir.
@bassbacke
@bassbacke 5 років тому
The 12-bit analog values range from 0-4095. Why devide that by 4096 when the highest possible value is 4095? 4095/4096 is slightly less than one so that multiplied with 3.3 is less the 3.3 (something like 3.2991943359375).
@G6EJD
@G6EJD 5 років тому
Konstantinos Kostis, it is because 0 is a number and there are 4096 values that the ADC can output, it’s a common misconception with binary mathematics.
@bassbacke
@bassbacke 5 років тому
@@G6EJD Yes, there are 2^12=4096 values but they start at 0 (not 1!) and end with 4095 (not 4096!). So much about common misconception with binary mathematics. A 12-bit value can hold 4096 different values but not the value 4096.
@G6EJD
@G6EJD 5 років тому
Konstantinos Kostis, the mathematical solution is to get the fractional results the denominator of which has to be 4096 as there are 4096 possible readings. The solution is to make your denominator 4095. In every ADC example I’ve ever seen the denominator is always the ADC range like in this case 4096. You could also reduce the 3.3v reference by 3.3-3.3x1/4096 to give an answer that more accords with your thinking, but I doubt you’d ever notice the 0.8mV error as the quantisation errors will be much greater.
@celsofranceschi6591
@celsofranceschi6591 3 роки тому
How write this code in esphome?
@AgentFire0
@AgentFire0 3 роки тому
Thanks.
@MrDante195
@MrDante195 3 роки тому
Awesome.video
@0124akash
@0124akash 2 місяці тому
Sir why didn't you use the ADS1115 module. Because accuracy problem found this method. Please make vdo using ADS1115, esp32, LCD16*2 For dc volt meter range is 0-300VDC
@G6EJD
@G6EJD 2 місяці тому
When there’s an ADC built in why bother it just adds cost and complexity of design
@0124akash
@0124akash 2 місяці тому
@@G6EJD because accuracy sir.
@G6EJD
@G6EJD 2 місяці тому
But you can get within 1% accuracy with the in-built ADC, why do you need more, it’s never going to be a scientific instrument? I think you could usefully read into ADC’s and what are the important aspects of them, speed, resolution are important and to a lesser extent linearity, what aspect would a ads1115 improve?
@0124akash
@0124akash 2 місяці тому
​@@G6EJD I will give you test report with code sir. voltage ---- LCD ---- adc 11.00. 11.00. 3007 10.00. 9.90. 2710 9.00. 8.81. 2416 8.00. 7.78. 2120 7.00. 6.72. 1840 6.00. 5.63. 1550 5.00. 4.61. 1263 4.00. 3.55. 972 3.00. 2.50. 683 2.00. 1.45. 400 1.00. .425. 117 This is a voltage comparison chart. I think esp32 adc is not compatible for linear reading.
@kokosikzhd
@kokosikzhd Рік тому
Hi all When I'm trying to divide analog pin value e.g 2.66 to 4096 and so on on formula - the value is much less than 1 2.66÷4,096×16×(8,461÷7,500)= 0.0117220104 Should I use *1000 or not? P.S I'm using Arduino Voltage Sensor which measures up to 25V DC
@G6EJD
@G6EJD Рік тому
The result is integer unless you specify or imply a floating result with 4096.0 or 7500.00
@kokosikzhd
@kokosikzhd Рік тому
@@G6EJD I've used integer, without floating. So do I need to multiply by 1000 ? Comma's in comment was from mobile calc :( In sketch all parts were int. only analogpin was float
@billglass5160
@billglass5160 4 місяці тому
In spite of the better resolution of the ESP32(4096) vs. that of an Arduino Nano(1024), I found a x10 better precision with the Nano. I wanted to measure a lithium battery voltage using the ESP32 with a 5V boost to Vin and found variations of about +-8% using a 76% voltage divider from the battery to input pinD33. For the lithium battery using a 5V boost to power the Nano (pin +5V) and a direct battery connection to pin A0, I found a variation of only about +- 0.8%. Any comments would be appreciated to improve my ESP32 measurements.
@G6EJD
@G6EJD 4 місяці тому
You can obtain the ESP32 internal reference voltage set at manufacture to improve reading accuracy. In general the ESP32 extra resolution should give you better results, but never approaching those of a DVM. To get better results you’d need to use an external ADC. You can also improve the linearity of the ESP32 using g some mathematics and what’s called a polynomial, I have covered both the ADC reference voltage and improving liberation other videos.
@billglass5160
@billglass5160 4 місяці тому
@@G6EJD Sorry, I called it the precision when I really meant to say the repeatability of the measurements. 10x better with the Nano.
@0124akash
@0124akash 9 місяців тому
1-Sir am using this method for dc voltage measurement. ESP32 wroom with I2C 16*2 LCD applied 12.4V display 12.4V If applied 6.7V display 5.9V How to solve this problem sir?
@G6EJD
@G6EJD 9 місяців тому
Your voltage divider is loading the circuit
@0124akash
@0124akash 9 місяців тому
@@G6EJD I will check and give you feedback. With ADC value. Sir one more thing any simulation software available for ESP32 for voltage measurement.
@G6EJD
@G6EJD 9 місяців тому
@@0124akash none that I’m aware of
@muhammadadib6632
@muhammadadib6632 Рік тому
Sir can use for 48vdc?
@G6EJD
@G6EJD Рік тому
Yes, but be careful anything over 30v DC is considered dangerous
@halsmypal
@halsmypal 3 роки тому
It seems the esp32 is unable to distinguish values at the top and bottom of its range (v < 1 and v > 3.2). How can we compensate for this, hopefully without resorting to an external adc?
@halsmypal
@halsmypal 3 роки тому
Just finished watching your tech note 069 and found my answer: adjust attenuation values, I guess to 11db.
@G6EJD
@G6EJD 3 роки тому
Hal, the default ADC range is 0 - 3.2v or actually 0 to Vdd -0.3 according to the data sheet. If you switch on the attenuation then the input range is further constrained to 0 - 1v the only solution is to use two external resistors as voltage dividers.
@G6EJD
@G6EJD 3 роки тому
I also provided an improved accuracy function.
@G6EJD
@G6EJD 3 роки тому
github.com/G6EJD/ESP32-ADC-Accuracy-Improvement-function
@halsmypal
@halsmypal 3 роки тому
@@G6EJD Thank you. I tried your formula but was unable to fix the described behavior. I think this is a physical problem. Here's what happens: I'm using one of the axes of a joystick which I've measured goes from about 260Ω - 4.8kΩ at each end, however, when I connect its vcc pin to the 3.3V pin of the ESP32, the GND pin to the GND of the ESP32, and the signal pin to ADC on pin 34, I see the voltage on the ADC go between 0 and 3.3V, but for about a quarter of the range of the potentiometer, the voltage is stuck at either 3.3V or 0V, similar to the graph in randomnerdtutorials.com/esp32-adc-analog-read-arduino-ide/ "The ADC is non-linear". However, I also read, as you said, that setting the attenuation should eliminate this value clipping at the end of the ranges, but it doesn't seem to be working for me. Are we limited to using the center ranges of potentiometers when using them with the ADC of the ESP32?
@kosa2004
@kosa2004 4 роки тому
Pairing it with a LCD Display it would be a great voltmeter.
@G6EJD
@G6EJD 4 роки тому
Yes, but I’ve never seen an LCD display you can buy
@kosa2004
@kosa2004 4 роки тому
G6EJD I ment was a lcd display connected to the esp modile to display the voltage. For a simple setup.
@G6EJD
@G6EJD 4 роки тому
Ok, I know what you mean an OLED or TFT screen often known (incorrectly) as LCD. I can’t do that as I’m in hospital until at least November ‘19
@kuaqil_
@kuaqil_ 3 роки тому
sorry for the bad questions, what u means with required value/preferred value
@G6EJD
@G6EJD 3 роки тому
No bad questions, I'm pleased you asked. The calculations might say a value of 13.6K is required, but resistors can only be purchased in 'preferred' values, like 10K, 12K, 15K. I put the so-called E-Number range in the video, so if you calculate for 13.6K, then you pick the nearest value in my example here 15K is nearest then you have to go back and recalculate using the new value to know the actual range.
@kuaqil_
@kuaqil_ 3 роки тому
@@G6EJDunderstood, so if i use 3 resistor for voltage divider, the calculation and coding still same?
@G6EJD
@G6EJD 3 роки тому
Yes, and it enables you to get must closer to the required values my examples was 13.6K so we could use 3 resistors in series to make up one resistor using 12K in series with 1K and 680R giving 13.68K
@kuaqil_
@kuaqil_ 3 роки тому
@@G6EJD nice, thnks
@newburypi
@newburypi 5 років тому
Question on ESP32 internal impedance... if the measured internal Z is 200k , wouldn't that Z in parallel with the 27k (from the divider in your 13.8V example) result in 23.8k? It just strikes me that the internal Z should be much higher in order to keep your voltage divider accurate. Also MOS inputs are usually many meg ohms, as I remember.
@G6EJD
@G6EJD 5 років тому
Your right, what I tried to do is simplify the impedance measurement as actually the ESP32 requires a minimum input current to get the ADC to operate. Taken for instance a voltage divider comprised of two 470k resistors the voltage at the junction will be Vin / 2 but the ADC can’t make a reliable measurement, now repeat the test with say 220k values and all works as expected because there is sufficient input current but not enough to skew the voltage divider values. I was going to give an equivalent circuit of the ADC input but the data sheet gives insufficient design disclosure. So perhaps the best way to describe the input impedance is still to use the word impedance rather than resistance and that the impedance is dynamic, certainly not fixed. Therefore in conclusion I’ve estimated the impedance at 200k to reflect the minimum input current requirement for correct operation.
@newburypi
@newburypi 5 років тому
@@G6EJD many thanks for the clarification.
@superconfort
@superconfort 5 років тому
Nice video, but I hear you a sad voice. Your videos are awesome, thanks.
@G6EJD
@G6EJD 5 років тому
A very insightful observation. I will try to be more upbeat when I produce another one, Clearly my current mood is in my voice.
@superconfort
@superconfort 5 років тому
@@G6EJD Man, I hope your life gets as good as you make us feel with your very interesting channel. You really help. Thanks and best of luck from Spain.
@vladhristov2316
@vladhristov2316 5 років тому
Interesting, but I wont consider that "measuring of voltage". It should be classified as measuring of voltage fluctuations, since you know the initial number. Thx for the video, tho!
@G6EJD
@G6EJD 5 років тому
Well the ESP32 can measure a voltage of any value inside the chosen range, so design for 24v and apply 13.8v and that’s what’s gong to be measured. I don’t understand what you mean by fluctuation as the ADC reading is instantaneous.
@G6EJD
@G6EJD 5 років тому
A d once the R1 R2 voltage divider is added the ESP32 can measure an unknown voltage applied to the input , there is no knowledge of an initial value other than to calculate the range maximum that the ESP32 can measure.
@solidfuel0
@solidfuel0 Рік тому
But resistors are not accurate, so I have to do some calibration for each specific set of resistors. 100k could be 999.8 or .9
@G6EJD
@G6EJD Рік тому
And the point your making?
@solidfuel0
@solidfuel0 Рік тому
@@G6EJD that I wish for another solution. In my case I need to measure up to 3.4v I don't know what to to. Does esp32 Internal software calibration take care of voltage divider variance? Yes I'm lost
@G6EJD
@G6EJD Рік тому
@@solidfuel0 the ESP32 can measure up to 3.3v so you will always need a voltage divider, the solution is sine you have to use an external meter to ensure you have a reference, then measure the source violative with the meter and then with the ESP32 and compare, then adjust your ESP32 measured voltage by the ratio of Vmeasured / VESP32 so voltage = analogRead(35) * constant * Vmeasured/VESP32 or simply adjust your source code so that the voltage line is multiplied by either 0.999 if too high or 1.0”1 if too low, repeat until the correct value is obtained, you may need to use eg 0.95 or 1.005 or whatever.
@solidfuel0
@solidfuel0 Рік тому
@@G6EJD i could never get it to measure up to 3.3v even if the vdd is 3.3v.
@G6EJD
@G6EJD Рік тому
@@solidfuel0 you can but it becomes very inaccurate as the input voltage goes over 3.0v see my video about improving the accuracy using a polynomial
@gora6045
@gora6045 Рік тому
With respect to the work you have done - your calculation formula gives incorrect results: float voltage = (float)analogRead(36) / 4096 * 15 * 28205 / 27000; Proof: Example for 15V Voltage Source (VS) 15V Resistance 1 (R1) 100K Resistance 2 (R2) 27K Output Voltage (VOUT) 3.189V (Voltage Divider Calculator) In this case analogRead=3.189V/3.3V*4095=3957 float voltage = 3957 / 4096 * 15 * 28205 / 27000 = 15,14V (not 15V!!!) ---------------------------------------------------------------------- Correct formula for 15V: float voltage = (float)analogRead(36) / 4095 * 15 * 3300 / 3189; Proof: Example #1 for 15V Voltage Source (VS) 15V Resistance 1 (R1) 100K Resistance 2 (R2) 27K Output Voltage (VOUT) 3.189V (Voltage Divider Calculator) In this case analogRead=3.189V/3.3V*4095=3957 float voltage = 3957 / 4095 * 15 * 3300 / 3189 = 14,999V (~15V!!!) Example #2 for 12V Voltage Source (VS) 12V Resistance 1 (R1) 100K Resistance 2 (R2) 27K Output Voltage (VOUT) 2.551V (Voltage Divider Calculator) In this case analogRead=2.551V/3.3V*4095=3166 float voltage = 3166 / 4095 * 15 * 3300 / 3189 = 12,000V (!!!)
@G6EJD
@G6EJD Рік тому
But you have no concept in your mind of the effect of the ESP32 ADC input impedance on the calculations, so you need to brush up on your electrical engineering and think a little bit wider and deeper, because unfortunately you will find your wrong!
@gora6045
@gora6045 Рік тому
@@G6EJD Thank you for the quick response and important advice! Added ESP32 input impedance ~200K to calculations Your calculation formula for 100K and 27K divider: float voltage = (float)analogRead(36) / 4096 * 15 * 28205 / 27000; Check for 15V, 100K and 27K divider, ~200K ESP32 input impedance Voltage Source (VS) 15V Resistance 1 (R1) 100K Resistance 2 (R2) 27K!!200K=23K789 Output Voltage (VOUT) 2.883V (Voltage Divider Calculator) In this case analogRead=2.883V/3.3V*4095=3578 float voltage = 3578 / 4096 * 15 * 28205 / 27000 = 13.688V (not 15V!!!) ---------------------------------------------------------------------- My calculation formula for 100K and 27K divider: float voltage = (float)analogRead(36) / 4095 * 15 * 3300 /2883; Check #1 for 15V, 100K and 27K divider, ~200K ESP32 input impedance Voltage Source (VS) 15V Resistance 1 (R1) 100K Resistance 2 (R2) 27K!!200K=23K789 Output Voltage (VOUT) 2.883V (Voltage Divider Calculator) In this case analogRead=2,883V/3.3V*4095=3578 float voltage = 3578 / 4095 * 15 * 3300 / 2883 = 15.001V (~15V!!!) Check #2 for 12V, 100K and 27K divider, ~200K ESP32 input impedance Voltage Source (VS) 12V Resistance 1 (R1) 100K Resistance 2 (R2) 27K!!200K=23K789 Output Voltage (VOUT) 2.306V (Voltage Divider Calculator) In this case analogRead=2.306V/3.3V*4095=2862 float voltage = 2862 / 4095 * 15 * 3300 / 2883 = 11.999V (~12V!!!)
@G6EJD
@G6EJD Рік тому
@@gora6045 but the input impedance is both non-linear and its equivalent circuit is not a parallel impedance but series.
Using Analog input of ESP32 read Potentiometer DC voltage
13:48
Robojax
Переглядів 28 тис.
ВИРУСНЫЕ ВИДЕО / Мусорка 😂
00:34
Светлый Voiceover
Переглядів 7 млн
Кровосток - разговор с легендами / вДудь
2:12:57
одни дома // EVA mash @TweetvilleCartoon
01:00
EVA mash
Переглядів 483 тис.
Monitoring Voltage with ESPHome, D1 Mini ADC, and Home Assistant
23:07
12 Useful & Interesting ESP32 Projects for Beginners!
9:41
ToP Projects Compilation
Переглядів 563 тис.
Op-Amps  - Using Operational Amplifiers
44:21
DroneBot Workshop
Переглядів 260 тис.
Tech Note 142 - Calibrate a BME280/680 Pressure Sensor or Barometer
3:22
The Cheapest Microcontroller? Getting started with the 10 cent Puya PY32.
21:36
Zach of All Trades
Переглядів 27 тис.
DIY ESP32 AC Power Meter (with Home Assistant/Automation Integration)
10:58
Лучший телефон на андроиде?
0:25
Опросный
Переглядів 87 тис.
Broken Flex Repair #technology #mobilerepair
0:55
ideal institute aligarh
Переглядів 15 млн
Which Phone Unlock Code Will You Choose? 🤔️
0:12
Game9bit
Переглядів 4,8 млн
NOTHING PHONE 2A - НЕОБЫЧЕН ВО ВСЕМ!
30:39
DimaViper
Переглядів 53 тис.
Power AC Coolness with Anker SOLIX F3800
0:27
Anker SOLIX
Переглядів 3,5 млн
МОЙ ПЕРВЫЙ ТЕЛЕФОН - Sony Erricson T280i
18:02
ЗЕ МАККЕРС
Переглядів 58 тис.
Лучший телефон на андроиде?
0:25
Опросный
Переглядів 87 тис.