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

  Рет қаралды 71,543

G6EJD - David

G6EJD - David

Күн бұрын

Пікірлер: 149
@kransurfing
@kransurfing 3 ай бұрын
Thank you for your careful attention to detail and plentiful amount of examples, akin to that of official learning materials!! Great job
@deangreenhough3479
@deangreenhough3479 5 жыл бұрын
Always a pleasure and always worth the time to absorb your technical notes and YES I do find them very useful 😀🏴󠁧󠁢󠁥󠁮󠁧󠁿
@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.
@iotsolutionslk
@iotsolutionslk 3 жыл бұрын
Excellent presentation with examples. Really appreciate mentioning the safety precautions.
@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
@rudyhenderson5002
@rudyhenderson5002 2 жыл бұрын
Outstanding presentation with very helpful references. Good job!
@AbuSous2000PR
@AbuSous2000PR 5 жыл бұрын
I appreciate your efforts This takes a lot of time to prepare and tp produce
@paulz8750
@paulz8750 Жыл бұрын
Really appreciate you making this which is extremely useful.
@xThirdOpsx
@xThirdOpsx Жыл бұрын
Golden content, exactly what I was looking for. Thanks a lot!
@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.
@embeddedprogrammer6276
@embeddedprogrammer6276 4 жыл бұрын
Excellent video. Thanks for the links to the calculator.
@souzamce
@souzamce 4 жыл бұрын
Thank you very much. It was a pretty good class.
@pd8559
@pd8559 3 жыл бұрын
Excellent coverage of all the details, but wouldn't expect any less of a HAM operator 🤣
@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
@dehoffe
@dehoffe 5 жыл бұрын
Thank you, very nice video and information. Excatly what i was looking for.
@uweri_3851
@uweri_3851 5 жыл бұрын
like allways....best of class
@billglass5160
@billglass5160 8 ай бұрын
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 8 ай бұрын
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 8 ай бұрын
@@G6EJD Sorry, I called it the precision when I really meant to say the repeatability of the measurements. 10x better with the Nano.
@Try58
@Try58 Жыл бұрын
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 Жыл бұрын
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.
@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.
@usmanumer9871
@usmanumer9871 3 жыл бұрын
easy to understand . best tutorial
@MrI8igmac
@MrI8igmac 2 ай бұрын
Im working with esp32 for the first time. I purchased 3.7v 850mah lipo 5 pack. If i understand a fully charged 3.7v lipo will actually read 4.2v. Im starting to realize the dangers of working with batteries and i dont want to burn up my boards. So i read about voltage devider circuit monitor the voltage of my battery supply and this will be important knowing an estimate flight time. This devider circuit is how i should power my board safely?
@G6EJD
@G6EJD 2 ай бұрын
Yes a fully charged LiPo has a battery voltage of 4.2v and is discharged at about 3.6v, they always quote the nominal cell voltages, which can be confusing. Most ESP32 development boards have a battery management chip fitted which handles battery charging and discharging. It only allows charging when the cell voltage drops to 3.8v, well actually whatever value has been set by the board designer via a series resistor fitted to the battery management chip. Also most development boards fit a simple voltage divider whose input is connected to the battery input terminal, so that when the battery is connected the battery voltage (off charge by virtue of no 5v USB input) can be monitored. Simulating the voltage divider for fitting to a board without a fitted battery monitor is quite easIly achieved. The risk of burning your board is very low as the battery feeds a battery manager chip and then voltage regulator.
@MrI8igmac
@MrI8igmac 2 ай бұрын
Ok so. My motors can handle 5v so it would be safe to have the wiring for the motors directly to the batter then power the esp32s3 from a voltage devider circuit.
@G6EJD
@G6EJD 2 ай бұрын
@@MrI8igmac you can’t successfully power the ESP32 via a voltage divider as the series impedance would be too high leading to huge voltage reductions which in-turn would make the ESP32 processor operation fail, what would happen is the ESP32 brown-out detectors would trigger snd keep resetting the ESP32. Only a voltage divider using very low values of say less that 10R would enable successful operation but it would quickly flatten the supply battery. BUT none of that is required if you use a development board with a Vin pin that is connected directly to the on-board voltage regulator or even the battery input pin as most regulators can handle an input voltage of up to typically 6v, sometimes more depending on the regulator type.
@djatiecitra
@djatiecitra Жыл бұрын
Thank you for the explanation.
@deenotableeg4804
@deenotableeg4804 2 ай бұрын
Good work ❤
@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
@billmckinzie
@billmckinzie 4 жыл бұрын
Great work sir.
@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
@Cordic45
@Cordic45 4 жыл бұрын
SHIT WOH MAKE THIS VIDEO!!?????? OMG THIS SECTION IS GOD DAMNES GOOOOOOOOOOOOOOOOOD
@dougbas3980
@dougbas3980 9 ай бұрын
Well done.
@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.
@reiya6563
@reiya6563 Жыл бұрын
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 Жыл бұрын
Try adcvalue * 3.3 / 4095 * 0.5/0.3;
@quaternion-pi
@quaternion-pi 5 жыл бұрын
Great practical examples. 73 - K6CCA
@aclam9839
@aclam9839 5 жыл бұрын
But still enjoy your very informative posts
@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?
@0124akash
@0124akash 6 ай бұрын
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 6 ай бұрын
When there’s an ADC built in why bother it just adds cost and complexity of design
@0124akash
@0124akash 6 ай бұрын
@@G6EJD because accuracy sir.
@G6EJD
@G6EJD 6 ай бұрын
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 6 ай бұрын
​@@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.
@Edmorbus
@Edmorbus Жыл бұрын
Thanks for sharing
@erichertsens
@erichertsens Жыл бұрын
Thanks, appreciated 👍
@GuyGreggo
@GuyGreggo 5 жыл бұрын
Thanks, very helpful.
@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.
@0124akash
@0124akash Жыл бұрын
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 Жыл бұрын
Your voltage divider is loading the circuit
@0124akash
@0124akash Жыл бұрын
@@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 Жыл бұрын
@@0124akash none that I’m aware of
@celsofranceschi6591
@celsofranceschi6591 3 жыл бұрын
How write this code in esphome?
@nirornkong416
@nirornkong416 3 жыл бұрын
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 3 жыл бұрын
It depends on the sensor your using, what type is it? You need to know it’s output characteristics
@nirornkong416
@nirornkong416 3 жыл бұрын
@@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 3 жыл бұрын
@@G6EJD May I have your Facebook or Instagram account?
@G6EJD
@G6EJD 3 жыл бұрын
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 3 жыл бұрын
@@G6EJD Represent range 0-14 sir.
@MPElectronique
@MPElectronique 5 жыл бұрын
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 5 жыл бұрын
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 5 жыл бұрын
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 5 жыл бұрын
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 5 жыл бұрын
@@G6EJD = 1,3466 v which is far away from 4,20v. Im really messes up... :(
@G6EJD
@G6EJD 5 жыл бұрын
What board type?
@0124akash
@0124akash 2 жыл бұрын
Sir, can I measure same time dc and ac voltage using esp32 ?
@G6EJD
@G6EJD 2 жыл бұрын
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.
@allasayegh1411
@allasayegh1411 2 жыл бұрын
super useful ... thanks a lot
@tycstahX
@tycstahX 5 жыл бұрын
Love this channel!
@tycstahX
@tycstahX 5 жыл бұрын
Let's go fry some esp32s... ;)
@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
@muhammadadib6632
@muhammadadib6632 Жыл бұрын
Sir can use for 48vdc?
@G6EJD
@G6EJD Жыл бұрын
Yes, but be careful anything over 30v DC is considered dangerous
@futi2868
@futi2868 4 жыл бұрын
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 4 жыл бұрын
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 4 жыл бұрын
​@@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
@halsmypal
@halsmypal 4 жыл бұрын
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 4 жыл бұрын
Just finished watching your tech note 069 and found my answer: adjust attenuation values, I guess to 11db.
@G6EJD
@G6EJD 4 жыл бұрын
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 4 жыл бұрын
I also provided an improved accuracy function.
@G6EJD
@G6EJD 4 жыл бұрын
github.com/G6EJD/ESP32-ADC-Accuracy-Improvement-function
@halsmypal
@halsmypal 4 жыл бұрын
@@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?
@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
@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.
@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
@18770299
@18770299 Жыл бұрын
Great! Thanks
@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.
@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
@kosa2004
@kosa2004 5 жыл бұрын
Pairing it with a LCD Display it would be a great voltmeter.
@G6EJD
@G6EJD 5 жыл бұрын
Yes, but I’ve never seen an LCD display you can buy
@kosa2004
@kosa2004 5 жыл бұрын
G6EJD I ment was a lcd display connected to the esp modile to display the voltage. For a simple setup.
@G6EJD
@G6EJD 5 жыл бұрын
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
@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
@MrDante195
@MrDante195 4 жыл бұрын
Awesome.video
@AgentFire0
@AgentFire0 4 жыл бұрын
Thanks.
@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.
@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.
If Barbie came to life! 💝
00:37
Meow-some! Reacts
Рет қаралды 77 МЛН
❌Разве такое возможно? #story
01:00
Кэри Найс
Рет қаралды 3,6 МЛН
Чёрная ДЫРА 🕳️ | WICSUR #shorts
00:49
Бискас
Рет қаралды 6 МЛН
ROLLING DOWN
00:20
Natan por Aí
Рет қаралды 11 МЛН
Measure DC Voltage and Current with Arduino
37:29
DroneBot Workshop
Рет қаралды 199 М.
Monitoring Voltage with ESPHome, D1 Mini ADC, and Home Assistant
23:07
Using Analog input of ESP32 read Potentiometer DC voltage
13:48
Tech Note 131 - ESP32/8266 Reducing Battery Load Hints & Tips
5:59
G6EJD - David
Рет қаралды 18 М.
I tried the Cheapest Arduino Alternative (that Nobody heard of)
13:31
Constant Voltage or Current Supply with ARDUINO
18:02
Electronoobs
Рет қаралды 70 М.
На что способен ваш компьютер?
0:34
when foldable cellphones follow the trend#shorts
0:11
amazing populer
Рет қаралды 15 МЛН