#340
HTML-код
- Опубликовано: 2 фев 2025
- I often get questions about how to measure voltage with microcontrollers. We will look at this topic, at the quality of built-in and external Analog-to-digital converters, and I will show you some “secrets.”
In this video, we will:
See how ADCs work
Look at how we can determine the quality of ADCs
Compare the ADCs of different microcontrollers with external chips
Learn how to tweak the calculations to get the best out of any ADC
See how we can extend the range of ADCs
Discover some “hidden” things of Microcontrollers and their ADCs
Look at different external boards and their usage
I am a proud Patreon of GreatScott!, Electroboom, Electronoobs, EEVblog, and others.
Links:
ESP32 dev board: s.click.aliexpr...
ESP32 Breakout: s.click.aliexpr...
ADS1115: s.click.aliexpr...
PCF8591: s.click.aliexpr...
AD7705: s.click.aliexpr...
Nice looking ADC (AD7606): s.click.aliexpr...
Voltage reference: s.click.aliexpr...
Voltage Divider: www.ohmslawcalc...
ADC Theory: e2e.ti.com/blo...
DAC Theory: en.wikipedia.o...
The links above usually are affiliate links which support the channel (no additional cost for you).
Supporting Material and Blog Page: www.sensorsiot.org
Github: www.github.com...
My Patreon Page: / andreasspiess
Discord: / discord
If you want to support the channel, please use the links below to start your shopping. No additional charges for you, but I get a commission (of your purchases the next 24 hours) to buy new stuff for the channel
My Amazon.com shop: www.amazon.com...
For Banggood bit.ly/2jAQEf4
For AliExpress: bit.ly/2B0yTLL
For Amazon.de: amzn.to/2r0ZCYI
For Amazon UK: amzn.to/2mxBaJf
For ebay.com: ebay.to/2DuYXBp
www.facebook.c...
/ spiessa
www.instructab...
Please do not try to Email me or invite me on LinkedIn. These communication channels are reserved for my primary job
As an Amazon Associate, I earn from qualifying purchases
The external ADC at 2.5V didn't show 2.4994 as you say as per the reference but 2.4594 at 22:22 in the video.
You are right. My mistake!
ruclips.net/video/AIL36S6NpDA/видео.html awesone project
yup. I felt a little spoofed.
With that inaccuracy it seems that an external ADC isn't really that much better than a software-compensated ESP32 ADC.
However, the precision of an external ADC could be interesting for scaled up projects: you are trading the extra costs for an ADC to skip the individual calibration process of each ESP32 ADC.
@@tigerresearch2665 The external ADC only performs so bad due to his own "correction formula" that very likely only corrects errors on the analog end (aka from V_ref to the PGA inside the ADC). So it shows the correct value at this one point, but not anywhere else. One error that affects the analog end, which I would suspect here: High sampling rate -> low input impedance -> voltage drop Correcting ADC values in code like he does is not something anyone should do. The first step is to correct the hardware/setup!
Let me compare that to a car that constantly steers to the left: Do you just "counter steer" to make it straight... or do you fix your car so it drives straight?
Andreas Spiess So, the conclusion of the Video is wrong?
I am using an ESP32 to monitor the battery voltage on my boat and send an email if it gets too low. I found the measurements very noisy due to occasional glitches. My solution was to take 8 readings and ignore the largest and smallest and average the middle 6. I do this twice and average them. It is quite easy to do in the code as you just have to keep track of the largest and smallest measurements and subtract them from the sum and divide by 6. I found this better than longer averages so that I did not get multiple glitches in my sample period. The result is very stable and quite fast. I very much enjoy your videos I am a retired circuit designer. I designed test equipment for HP (Now Keysight) and things like cable modems in the early days. Now it is a hobby.
Good idea because you can eliminate the far glitches. I did not investigate the distribution of the measured values, but maybe they have a pattern you break with your formula.
I like my Keysight MSOX3045 ;-) Good products!
@@AndreasSpiess The distribution was not Gaussian. It was mostly correct values with a few outliers. It is actually a pretty standard way of filtering. There is even a name for it but I can't find it any longer. I learned it from a statistician who worked for me for a short time.
Would it help to put a cap (as low Pass?) between the divider and gnd.
@@michael_the_chef It has been a long time but I think I measured with a dead stable voltage so the answer would be no.
@@L-36 ok thanks, i am planning to use an ads1115 and an esp32 to monitor a battery Bank of 4
Thanks for this video! I've been puzzling over how to reduce the noise of a voltage reading for a project without losing responsiveness introduced by filtering. Based on your video, I switched over to an external ADC (ADS1115) and it solved the problem. Much appreciated!
Glad I could help!
Same here. I was reading NTC to get temperature from Esp32s3. The result is so non-linear and I've ordered a few ads1115 to test it out.
If you tweak the adc settings in the ESP32 down to 10 bits, and some other changes, the noise and accuracy gets a LOT better, I’m not at my computer at the moment but I will post the code when I get a chance.
Please leave a link on your comment when you do. Thanks
Augustine Nwafor - I posted the code in the comments, it’s here somewhere.
Here is the code of the @@TheDefpom comment:
"Here you go, here is the code to help get the ESP32 ADC to behave better:
// configure ADC for getting battery voltage
pinMode(VoltageSense, INPUT); // Battery Voltage Sense input
analogSetPinAttenuation(VoltageSense, ADC_0db); // set the attenuator for the ADC to allow 1.1V input range
analogSetWidth(11); // set the resolution width to be 2048 instead of the default 4096 to try and reduce noise
analogReadResolution(11); // set the resolution to be 2048 instead of the default 4096 to try and reduce noise"
@@skuashh cool, will try when i have a chance
I never get tired to watch your videos. I like the fact that you put your personal opinion in each fact. I understand better this way. Thank you
Thank you for your nice words!
For a very long time I paid my studies by building accurate DAC's for the growing digital industry. Making them precise is a science! 😊
Sounds neat, were they hand-matched R2R ladders? I always wonder why you can’t just buy R2R resistor networks in single packages, like a SIP10. Though these days I’d be tempted to just use a half-bridge and low-pass filter, like a good-old class-d amp.
@@Scrogan Try www.digikey.com/products/en/resistors/resistor-networks-arrays/50?k=resistor+array&k=&pkeyword=resistor+array&sv=0&pv9=392120&sf=0&FV=-8%7C50&quantity=&ColumnSort=0&page=1&pageSize=100
Yup, I have a esp32 based ph/temp/ec meter I'm doing for hydroponics github.com/physiii/grow
@y2ksw1: I can imagine that this is not trivial!
James Barclay Yes, with my never patented fool proof method nobody ever thought about before. Pure science 😊
Greetings from South Africa Andreas. Well done as usual! I am always surprised how much information you share with great clarity and structure in such a short video clip. When I learnt this stuff (long before internet), choices were fewer and one had to study the data sheets thoroughly (or copy somebody's example from Elektor, EE, ETI etc). Microcontrollers (with built in ADCs) only arrived later and choices were fewer - which was a blessing, because obsolescence took longer. Hobbyists today should be thankful that you share years of experience, crammed into a nutshell...and for free. Love your work and your very structured method of teaching (unlike my ADHD brain which likes to skip around). Best Regards, Allen.
The ADS1115 is my favorite ADC for microcontrollers. I started using it when I moved over to 32bit microcontrollers, but needed a way to read 5V automotive sensors (using a Teensy 3.2). I had 4 sensors (an MPX5700AP pressure sensor, an NTC thermistor, an AEM Wideband oxygen sensor and a 0-100psi oil pressure sensor), the ADS1115 had 4 inputs, it was a match! I didn't have to average values to get a stable reading, like you said, the stability of the ADC is fantastic.
Thank you for sharing your experience. This seems to be a perfect solution.
Hints for those starting out -- for built-in ADCs, throw away the bottom bit as it's most likely useless anyway. You can average samples equal to a power of 2 by adding the integer values and doing a right shift -- for example add up 8 integer ADC samples and right shift 3, a useful trick when your microprocessor doesn't have a divide instruction! What's your signal bandwidth? Adding a single pole RC low pass filter in front of the ADC can help. And do not expect the input impedance of the ADC to be constant.
Good idea. Thanks!
Very interesting video as always, thank you.
Another benefit of using the ADS1115 is that the internal PGA can be configured to read a differential signal, this is very useful for measuring some sensors, although it also results in a slower data acquisition rate.
True!
This trick can also be used in general by the Arduino by using two analog inputs connected to the signal direct and the signal amplified by a fixed op amp.
Awesome. Thank you for the great content! Just my two cents:
1. I've had to learn the hard way, that many (all?) of the ADC that have a MUX only have a single S/H aufter the MUX. This leads to problems, when reading signals on different channels with very different voltages in quick succession. There is quite a bit of "crosstalk". It's really important to make sure that the inputs to such an ADC are low impedance.
2. When I do averaging on a uC, I do 2^n samles (8, 16, 32...1024) samples, add the read values up (make sure to prevent overflow) and just use shift for the division at the end. Especially on uC without an FPU this speeds the averaging up quite a bit.
Good info. Thank you! I would have expected only one S/H, though, because it is usually part of the ADC.
@myselfremadedid you ever find an answer?
At 12.07, I love the way you dodge the 1023/1024 argument!
I had enough discussions about that in my life. So I once used 1023 and once 65536
@@AndreasSpiessWhy was there ever an argument? (1023/1023 =1) Just curious
@@TheRainHarvester Because of the 0
@@AndreasSpiess if you can measure the voltage at the high rail, you divide by 4095 so you get 1* vcc.
Thanks Andreas for this interesting video. I've used ADC lots of times, and never had concerns about the quality of the conversion (noise reduction with average method). In a current project, getting feedback from the servo's potentiometers for a robotic arm, I've used a calibration table, but now I'm going to introduce your formulas. Thanks again, Juan.
It depends on the desired accuracy. I compared, of course, with the data sheet.Calibration tables are good if the ADC is dependable wrong and not stochastically wrong...
Nice video.
Remember to consider the input impedance of the ADC, especially if you use high value resistors for a voltage divider in front.
since the input is in parallel to the low-side resistor of the voltage divider only its value really matters - well actually it is of course the parallel-combination of the upper and lower resistance in the voltage divider...
And for the ATmega328 the input resistance of the ADC-channels is astonishingly high! I tested it with discharging a 1µF capacitor from 5 V to zero through a 100 MΩ resistor - it took about 15 minutes to discharge and the resulting curve indicates an input resistance beyond 1 GΩ.
Uwe Zimmermann
I was going to ask what you used to measure that voltage, but I guess you were just using the ADC itself. I imagine most of the leakage current will be through the protection diodes, if it had none then it would be a real recipe for ESD. Which reminds me of a friend using his atmega ADC for measuring back-emf of a solenoid. Directly on the 12V half-bridge output that was powering the solenoid. With no extra diode or resistors. The arduino got really hot, but somehow the circuit actually worked.
@@uwezimmermann5427 I am not talking Any specific microprocesor. I had an adc in a low power circuit where I wanted to messure the battery voltage, here I used a resistor divider in 10 Mohm Range to avoid draning the battery. In this applikation the messured voltage was wrong due to current flowing into the mcu.
Watched already a lot of videos of your channel and at the beginning it was a lot of „häääää, versteh grad überhaupt nix“ but from one video to the next I start to understand what you are explaining us. Have to say that I am a totally new beginner.
My goal is to measure the 2 12V Solar Batteries in the OFF-Grid garden of my parents in law. Tried a lot with the ADC from the ESP32 itself and as u mentioned it’s readings are just bullshit.
Thank you for introducing the ADS1115 to me. I guess that will fix my measuring problem and can finally bring the project into production.
As I am original from Vorarlberg and worked many years in Kanton SG I love to hear your swiss accent as it remembers me of that great time in my life!
Electronic wise you are my personal hero ;-)
For this purpose you probably could also use a INA226 as suggested by other commenters.
And I am glad you learn something with each video. We all started as beginners in this field.
This is such an important topic. I send a million thanks and encourage this topic.
Getting signals INTO the computer is probably just as important as having the computer to begin with.
This topic makes me consider re-writing all of computer science just to make an analog computer.
You find analog computers if you google. They were used befor the cheap silicon
I like the fact that your opinions/observations are unfiltered. You just tell it like it is. "Subscribed"
Welcome aboard the channel!
Thanks for putting out such high-quality videos regularly!
Glad you like them!
Another great video from a very competent presenter.
Just a point for a possible misconception: there are two other ADC architectures in common use, namely pipelined and sigma-delta. The first tries to keep the number of parallel comparators required in check by converting the output of a comparator stage back to analogue using a DAC, subtracting this output from the original input, and feeding the result to another comparators' stage. Three stages are quite common with typically 4bits per stage; leaving aside the unavoidable latency the conversion takes one clock cycle like the comparators' ADC. This breaks for high resolutions because analog subtractions accumulate too much error. Then sigma-delta comes to the rescue where in fact a control system tries to get its 1 bit output bitstream average as close to the input as possible (its operating principle is not easy to understand in detail though); 24 bits and higher resolutions became possible.
Successive approximation is favoured by the MCU manufacturers for a very simple reason - it requires a single analog comparator and an R-2R DAC - cheap, accurate and reproducible architecture that covers nearly all practical DAC needs. Moreover it can be difficult to find a standalone successive approximation ADC as most are either pipelined (higher sampling rates) or sigma-delta (for high, eg audio, resolution).
Again for a typical maker these are too finer points but I wanted to make sure they are mentioned in the footnote. Thanks again Andreas for your work
Thank you for your explanations. I always learn something from my viewers! As you saw I am more a user and not a specialist in this matter.
23:35 Really freaky video compression artifact at 23:35 -- the RF connectors appear to randomly telescope in and out!
Because they are not soldered in, he just put them on the PCB just to show the board.
It's not a video artifact.
@@shreyaskul Yes, on closer viewing, I think you're right. They seem to be rocking back and forth.
Shreyas is right!
@@AndreasSpiess Hey! Thanks for your comment.
Can you share which IC you have used in your ADC board? That would be great :)
Thanks for this awesome intro to the ADCs!
I'm going to measure voltage of my LiPo cell, so I know when to charge it :)
I do this too for most of my battery operated nodes
I'm amazed every time I see your great videos!!! You are testing stuff that went true testing before manufacture, but you made it better - why isn't Arduino listening??? If Arduino and ESP's had better ADC, the cost would not be that much higher - right? But now we can use your recipe and suggestions! Thank you again Andreas. And wishing your finger to heal FASTER!
I am sure they have their constrraints. Create chips for a few cents with 3 CPUs and Wi-Fi is for sure not easy.
Thank you for the breadth of the experiments to help reinforce the lessons. Seeing how externally sourced ~5v can impact the readings was an "of course!" moment, since I'm used to using a good regulator versus an adjustable power supply for projects. Spotting things like how the radios on the chip may affect the ADC are very good clues. I'll investigate some of the external ADCs, since I'm thinking about a project that will use a mesh radio network and I had planned to use analog inputs as well... thanks again!
Some distance to radios is never a bad thing ;-)
Hi Andreas! Great video as always! One note about the ADS1115 is that it is actually a 15-bit signed differential ADC( AC !!! ), or 16-bit single-ended. Differential
measurements offer more immunity from electromagnetic noise. This is useful when using long signal wires or operating in an electrically noisy environment. I have been using an ADS1115 to measure the amperage of our utility inlet with a sct-013. The fine art of accuracy I've seen is matching the sampling rate of the adc to the frequency of your local provider to sample the highs and lows of the sine wave as accurately as possible (50Hz here in ZA).
You are right with differential measurements.
Concerning 50Hz: You have to synchronize because the ADS1115 is slow. A diode and a RC filter probably would help to get DC out of AC
@@AndreasSpiess on the sct013 each 10A represents 1v. Thus getting Amperage readings are easy and safe with non invasive clamps. Only when it comes to the measurement of voltage, territory gets unsafe. I have opted for a 220v primary, 12v secondary to convert ac to DC proportionally followed with a voltage divider and capacitor. With both voltage and amperage the apparent usage can be calculated to identify power consumption patterns at home. I cannot thank you enough for the extensive and concise research you have given to this community! You inspire us!
Perfect! Thank you for this video! I am working on a project now with analog sensors and i learned everything I needed to!
Glad it helped!
at 9:30 describing SAR, you first say it would take 4000 samples to get the result, this is not SAR. SAR only ever takes the number of clock that = number of bits so a 12 bit ADC SAR would take 12 clocks. BTW, I do love your videos and find them very well presented and prepared, I am just trying to ad to the excelent presentation you have here for new engineers that may miss interpret the info
You are right with the number of 12. There I made a mistake by saying "around 10". The 4000 points was the explanation without SAR.
Great video. One thing to note. If you use an external i2c ADC, you can not set up any sort of interrupt driving timing to collect sames in the background at a given rate since i2c does not work within a ISR. This leads to a bit of work to make sure loop() gets called at a reasonable rate.... Just something to be aware of.
Good to know. Maybe you try a second RTOS task on the ESP32
@@AndreasSpiess This was on the AVR architecture
Here you go, here is the code to help get the ESP32 ADC to behave better:
// configure ADC for getting battery voltage
pinMode(VoltageSense, INPUT); // Battery Voltage Sense input
analogSetPinAttenuation(VoltageSense, ADC_0db); // set the attenuator for the ADC to allow 1.1V input range
analogSetWidth(11); // set the resolution width to be 2048 instead of the default 4096 to try and reduce noise
analogReadResolution(11); // set the resolution to be 2048 instead of the default 4096 to try and reduce noise
Also another trick I found is to add a delay directly before the read, it helps get a more stable reading too! 50ms worked well, but you can’t always do that obviously.
I never tried to reduce the resolution and compare it woth averaging. Good to know. Thanks!
I had to chuckle a little about the example of measuring a 24V Solar panel and then setting the range to 30V (around 13:23 in your video). A solar panel that you would use with 24V batteries in a real-world scenario would normally be a 72-Cell panel, which typically has an open circuit voltage around 45V @25ºC, and quite a bit higher when it gets really cold. I realise it was just an example in your video, but for anyone wanting to really measure a "24V Solar Panel", maybe increase that range in your resistor divider a little :-) As usual, thanks for an interesting Video Andreas - toll!
Reminds me of school and r2r ladder dacs. I get my fix of andreas every sunday. Lovely stuff.
Glad you like the "stuff" !
The ADS1115 is a good choice, BUT with my ESP-32 I had some trouble due to the fact that they was in the same casing and WiFi was enabled/used. The results was overlayed with lots of noise. The method of averageing takes to much time for my project. I need the result ASAP and the ADS1115 is anyway no the fastest. But I was able to solve the issue and I want to share this with you guys: First step was to build (3D Print) to boxes which fit in each other with a small gap. The outside of the small box got covered with a copper film. Afterwards I fit the small box in the big box. Why two boxes? Quit simple : isolation. The copper film I connected to ground. Inside the box I placed the ADS1115. For the cables I made small holes and the cable which is going to the probe is an coaxial. Problem solved. What I want to say by this is, that the interference of the RF signal has not to be underestimated!
Thanks for another great video! In researching my gas sensor project, I came across a method people say improves the accuracy of the readings, though I don't really understand it. You apply this calculation to the reading on the ADC pin: volts = -0.000000000000016 * pow(reading,4) + 0.000000000118171 * pow(reading,3)- 0.000000301211691 * pow(reading,2)+ 0.001109019271794 * reading + 0.034143524634089; (Also note that there is a more efficient way to do this calculation (10x faster), but it yields a slightly different result, so I'm leaving the original one here.)
For some reason the calculation got scrambled when I pasted it in to the comment - apparently having a "+" after a "-" gets interpreted as strike thru... Hopefully you can figure it out.
Unfortunately I am no mathematician. Maybe another viewer can help out.
@@AndreasSpiess I forget how I originally found the calculation, but if you Google "ESP32 ADC Polynomial" you will find a lot of people use it to make the values returned by the ADC more accurate. You noted that the ESP32 wasn't accurate, but apparently it can be improved with this technique. I'm happy with the results I'm getting, but my application doesn't need it to be extremely accurate.
How timely. I'm just trying to do this right now to monitor the voltage on a battery in my mailbox alerter. :). Thank you!
For monitoring a battery the internal ADCs should be ok.
Just got to the end, you covered off some of my earlier comments.. nice :), i will leave them there to hopeful help noobs to the ADC world and as a text reminder. Awesome video keep up the good work
Cool, thanks
You have confirmed my discovery. Thanks! Unfortunate that we have to rely on "small and casual" posts or trial&error methods to correctly use the esp32.
Fortunately, we have Google and the internet to share our learnings ;-)
I recommend using median filter for removing ESP32 ADC glitches, averaging is not good for this kind of noise
The formula @Andreas Spiess is using is not the usual average formula. He uses a so called filter with feed back and I don't know why he is calling it average but that one for sure is not just an average. And the second point when he says "when I use 10 samples or even 100 samples in that formula" .. those are not the actual samples. That number tells how much we should fed back to the initial value so basically to explain it we have an initial x=0.551 and in the loop he is calculating the next x by taking 99 parts of original x value (0.551) and adding 1 part of the new analogRead value thus it basically means we are just drifting to the left or right of the initial value and the amount of drift is expressed in the ratio we are using 1/10, 1/100, 1/1000 and so on parts of the new value mixed back to the initial one. Also this number will be the speed of conversion to the initial value so the higher value we use the slower is the speed and the more analog reads we need to go back to normal and at the same time the less is the chance to affect the final number by the new erroneous reading. Maybe @Andreas Spiess does not fully understand the formula he is using which I doubt but who knows maybe he can explain it in some further videos.
@@valcob6617 This is a simple IIR filter (meaning the response never reaches steady state theoretically), its good for quick & dirty filtering
@@valcob6617 Also the filter is prone to accumulating round off error for high filtering coefficients and my guess is this is why he gets 10% error on ESP32's ADC
Nailed it again. Thank u for your work. You always have what I need. Explained in full. Perfect
Thank you for your kind words!
Great timing. I'm building a flash joule heater, and need to measure the voltage of the supercapacitor before and after the flash... i was just going to use an arduino and not even think about it - because I didn't want to do the research.
Thanks much!
Edit: after watching, an ADS1115 or equiv is what I need.
Hopefully it will work out for you!
Yeah... thought this is a bit less effort.
Welcome to reality :) .
These 2.7v 500F rh2ings don't want to release their energy instantly.
Damn physics...
I didn't know the truth and tricks of ESP8266/ESP32. Another high quality video. Thank you!
You are welcome!
At 22:22 you say 2.499 and conclude a good linearity.
But in the video I read 2.459 which is 40mV off.
Or did I understand the offset correction wrong?
If all we have is an ADC with bad linearity, should we do a multi-point calibration?
You are right. My old eyes did not read the correct value!
I have a similar adc module with just 2 16bit ADCs and 50Mhz sample rate. It's like 40usd on eBay. It would be incredible if you want to make a video about how to read data off these cracy fast parallel lanes. My primary goal was to reduce cost. I thought it would be interesting if we can dump all the ADC data straight into a ram with some hard logic, and read the ram with some cheap slow microcenter. Thus eliminating the need of fpga.
Neat video! I’d have liked it more if you went over the details of successive approximation registers, and how a delta-sigma ADC (or DAC) works, but maybe that’s outside the scope of this video. On the topic of ADCs and DACs, I’d be interested in a video on DSP algorithms being implemented in an arduino, be it for audio or for filtering out narrow-band noise.
Also when you said that SDRs use these very high speed GHz ADCs, I don’t think they actually do. They use lower speed ADCs with mixers and tuneable local oscillators to generate the I and Q signals. Direct sampling SDRs are very rare.
I’d also have mentioned the fact that the ADCs have a finite input impedance, so putting a network of resistors in front of one without buffering it after could cause some systematic error. Well, you often use an instrumentation amplifier there anyhow so maybe it’s not too useful of a tip.
1. This channels is for makers, so the most important decision is what not to show.
2. I define SDR not only as "SDR receivers for the general public". I define them as "digitalize the signal and do the processing in software". So radar and many other applications fit my definition.
3. You are right with the input resistance. If you calibrate the readings I assume you can live witout an instrumentation amplifier for 10 or 12 bit resolution. For more precise applications you are right, of course
Nice explanation on the ADC basics. This can be confusing for beginners and experienced people alike.
The resistor values used when measuring higher voltages(30V) are way to high. With a few meg ohms the ADC's sampling capacitor cant fully charge and your results will be off. As the voltage drops the problem will get worse. You need to either increase the sampling time (not rate) or put a big cap (10-100nf should do) at the junction of the voltage divider. The capacitor will then supply the required charge to charge up the ADC's sampling capacitor. This will obviously mean the sampling RATE will be dependent on the RC values of the voltage divider and the cap.
If you do the same experiment with resistor values in the range of 10 - 100K as the voltage divider , you will get much better results. This is not an issue with the ESP32 , the same will hold true for all ADC's. I use the STM32 a lot and have seen this exact issue. If you have to sample a high impedance source you will have to increase your sampling time. You will also see more noise if you don't add filtering.
This is the reason that fast ADC's usually require some sort of amplifier/buffer stage up front to make sure the sampling cap can be charged fast enough to meet the frequency requirements.
Cheers
Rob
Thank you for your additional information. I wanted to keep the (tiny) resistors on the Wemos. This is why I ended up with such high values. But the current should be the same as in the original Wemos(@30 volts) .
@@AndreasSpiess
The issue is that when the ADC sampling capacitor is switched in at the start of the sampling period it is discharged. The mid point of the divider will drop to 0volts. The cap then charges through the 2meg resistor. Even though the cap is only a few pF it still has a time constant. If the sampling time is short enough the cap will be sampled before it is fully charged and the reading will be off. A big capacitor at the junction of the divider can provide the charge to charge up the ADC cap quickly without significant drop in the voltage at that point.
Cheers
Rob
Hello Andreas! I found your video when searching about adc because i am trying to trick a STM8S003F3 without success.
The STM8S seems to be running at 3,3v and has a 10k linear pot connected to 3,3v VCAP, GND and the variable output to PD3 , which is described as AIN4 and ADC_ETR. It stands for External trigger. From what i understand, the ADC external triggering means it is possible that the ADC only reads on some programmed event. Turns out that when i rotate the POT, even when reading with a digital meter, the voltage values are not linear at all and behaves differently along the POT range. It can read steadily on the starting range, mid range it will fluctuate values and even read 0 and on the end range read some steady values again, higher than on the start range. But the device works correctly. What can be the cause for this? The STM8 adc pin can be programmed to somehow behave like this? Or expecting some pwm signal synchronized with its clock? I don’t have a scope to analyse this in a better way. If i input the POT output to a wemos d1 8266 it will read accordingly to the digital meter, but i cannot put the wemos bypassing that signal to a pwm output back to the STM8, it will not work the same way as if the POT is directly connected to the STM8. Do you have a clue about why this happens?
Thank you
I have no idea. And I never used an STM8. So I am not a big help :-(
@@AndreasSpiess ok. Thanks anyways. Maybe it would be something good to figure out. I gave up on that approach because i don’t own a scope but i really would like to know what’s going on behind the scenes. Cheers!
I recently built up an electronics test setup that utilizes a bunch of sensors in order to create essentially a DIY motor dynomometer. I've yet to finalize the mechanical design but I am using an ADS1115 in order to read an ACS758 current sensor and a voltage divider so I can record and graph the current over time as fast as possible while the motor spins. RPM is read with a cheap light gate style encoder and a 3D printed encoder wheel, so I can control the CPM. Some motors might be geared down to a few hundred RPM, some brushless motors in excess of 30,000RPM. I'm reading currents in excess of 75 amps at peak which is why I'm using a hall sensor and I also want it to work for much smaller motors too, so I wanted a resolution of ~0.05 amps, hence using the external 16 bit ADC. One problem I ran into is sensor drift. I noticed by just sitting there doing nothing over the course of a couple minutes the ADC read values can drive by up to 50. Other than calibrating to 0 at the start ever each test (which is my current workaround) is there any way to try and stabilize this?
These acs hall sensors are not very good at small currents. Maybe you watch my video concerning current measurements.
Hi , about Arduino, i know that you know but is to clarify to others. If you use 5v in your formula and change supply voltage, it is clear that it will not take good values
I usually work with the internal secret method for measure Vcc (you don't need any other analog pin for that). Also you can use low noise ADC sleep mode to measure.
This is what I showed in video #10 ;-)
Thanks Andreas, once again learned alot!
Glad to hear that! Thank you.
Thanks for another fantastic video. Just for curiosity, if I insert a delay(1) between each analogRead(A0), the measurements related to WeMos D1 Mini have more fluctuations than without it. Is this due to the capacitor in the Sample and Hold circuit that discharges faster by inserting delay(1)? It is evident within low serial baud rate. Thanks
3:50 The 2-bit flash converter seems a bit off. For one thing, the 4 comparators detect 5 ranges, yet somehow, this is reduced to 2 bits (4 numbers). Second, with the input signal either in the lowest range, or the highest range, the output will be 1,1. And I don't think the count up from low to high works properly either. Maybe the comprator plus and minus inputs are supposed to be interchanged?
OK, at 4:32, I guess we see that Andreas thinks that indeed the - and + inputs are the opposite of shown in the diagram. As drawn, when the input of a comparator exceeds the reference voltage for that comparator, we will get a zero, because the input is connected to the minus input. That's the opposite of Andreas' verbal description.
I did not llook into the logic of the drawing and maybe I was not precise. I hope, the concept was still understandable.
You say at 6:15 the Arduino (ATMEGA328) uses 5V for its reference and for an Arduino that is the default for sure but not the ATMEGA328. it happens to simply be the default that the Arduino Abstraction layer uses in its IDE. It is fully programmable between an external reference, an internal 1.1V band gap reference and of course VCC. they use VCC because it gives a simple range to the user and matches the most lightly voltage they will use for the external circuits that will be used to feed into it. this is perfectly reasonable but as I said... not the ATMEGA doing it but the Arduino IDE programmer.
You also have to remember that the internal Vcc choice will be different depending on the micro-controller, a 328 based arduino is typically 5V by default (Or more specifically what ever the USB power is and can be close to 4.75 v), A sam based arduino may only be 3V3 (Nominally) etc etc. even the internal references are different between each micro-controller see this for more
www.arduino.cc/en/Reference.AnalogReference
www.arduino.cc/reference/en/language/functions/analog-io/analogreference/
Default to Vcc is for simplicity, not accuracy, if you want accurate, choose an external precision Vref or the internal Band Gap reference and add the required external voltage dividers to match
You are, of course, right. In video #10 I showed how to use the internal reference ;-)
Thank you very much for this video. I got a question regarding the ATmega328p, that I guess is used for Arduino uno now and in your test. When I read the manual for the chip page 211, there is an ADC Noise Canceler. It allows stop of CPU execution while the ADC is active. It will typically prevent interrupts being executed for about 54 or 108 us while the ADC is active. For many applications a 108 us delay for some interrupt is not desireable.
I would think, that your test did not include this Noise canceler process - am I right?
How was the prescaler set - or what was the clock frequency for the ADC in your test?
Do you have any idea on how accuracy is degraded, if you increase ADC clock above 200 kHz?
I just used the "normal" Arduino code. So whatever settings are used there are used in my tests (I even did not know the details you mention).
@@AndreasSpiessThanks. I have read some parts of the hardware description, but I am still not familiar in reading the "normal" Arduino code. My best guess based on what i could understand is, that the noise canceler is not used. The ADC clock is set to 125 kHz. I have seen indication, that the ADC should be able to work quite well up to 1 MHz. One reading takes 13½ clock cycles.
I'm a little confused by the flash converter. The circuit shown at 3:45 seems to have the same output (00) at 1V and 9V. What am I missing?
I did not check the logic gates. They were not so important for teh understanding
@@AndreasSpiess Now that I have given it some thought, there are actually five voltage ranges. Four would only require three comparators with the states being below 1 (00), below 2 (01), below 3 (10) and 3 and up (11).
Very nice video. One consideration though. The serial ADC will always need the same time independent of the measures voltage.
As the comparator can only output "too high" or "too low" it can not detect that it hit the right voltage and finish early. It will always increment to the final / least significant bit.
It can however be accelerated if you choose to reduce accuracy.
Thank you for the additional information!
It's also possible to use a smoothing capacitor on analog values instead of doing too much work in software. I wanted to use a 100K ohm pot going from ground to Vcc and there's not enough current to overcome the internal leakage and you get bad results. Corrected with a 0.1uF capacitor on the pot slider and it removes the error on those internal ADs and you still get the advantage of low current consumption through the 100K pot.
You are right, caps help for outside noise. Unfortunately not for the noise created by the ADCs :-(
@@AndreasSpiess true. I only use the internal A2Ds for basic applications. I just begrudge wasting a lot of current through a pot connected across the power rails. The capacitor method works really well.
Hello,
thanks for the in depth explanation!!
Can you explain where is this
float y = (x * 1023.0 / 331.0) ; coming from? In detail the term 1023.0/331.0 ... min19.45
also in min18.11 I do not understand the 5/497 :(
many thanks for help
I don't understand this either. If x is a digital value, to calculate real voltage we need 1lsb voltage coef. Which is max_voltage/max_resolution. So, the proper formula seems to be: float y = x * 3.09/1023
Nice comprehensive review, one question comes to my mind, is the ESP32-S2 any better than the ESP32?
Notf sure overall, but the esp32s2 has a bit width of 13, compared to the esp32's 12 - which is significant.
I don't think it's shown in the documentation yet? However idf alerts you to this when compiling and it can be seen in the respective header files (of course it works too!).
The same BS :)
@@Sovvyy It's just a marketing. I've tried this to monitor charge of the battery -- it's useless in the same way as regular ESP32 or ESP8266 that ESP32s2 should replace. Use only external battery controllers chips, internal ESP ADC is useless for such sensitive things. And what I hate the most with ESP -- this "filtering" formulas with magic numbers -- you need to adjust it for each and every chip. I never had any 2 chips in ESP32 or ESP8266 lines with the same ADC errors.
I boosted the ADC sample rate of an Arduino UNO at around 30800 SPS for audio purposes, the sound wasn't really great but when I discovered I can use the 1.1V reference, it immediately made it way more accurate! The issue was that the input audio signal was so low it could only be heard in a single bit.
You are right. The usage of the internal reference is shown in video #10
I'm surprised that the 24 bit HX711 ADC was not also covered in this video. It's designed supposedly specifically for load cells but I'm curious if there is something special about it so that it can be used with (and only with) load cells or if it can be used as a general purpose ADC?
I only used it for loac cells.
Great video. Just for feedback, the first adc is called flash adc, flash for lightning speed. Another idea, adc chips are good for generating a binary value for raw signal within specifications, but the limitation often lies within the controller to manipulate the binary value to usable data. Often, the dilemma is within the controller's ability to manipulate double float values. Some controllers can only handle 8 byte floats. So calculating a thermocouple voltage becomes an inaccurate reading because of the float calculation errors. Not just thermocouples, even ntc resistors. So usually for such operations a good math library is needed to overcome these hurdles but capture rate of course would be at a disadvantage.
True. Fortunately, The ESP32 has a floating point engine.
@@AndreasSpiess i'm using the 8266, moved all my heavy load to the STM32F103C8 due to power requirements. I like these ESP devices; however, I'm interested in another solution where they don't offer a flash.
Most modern high-speed ADCs are exclusively pipelined architecture ADC. This architecture does include a lower resolution flash ADCs but it does not need all the extra comparators to make the 12-bits. It gets 12 bits by staging the quantization. Also, the conversion does take a few cycles to compete when compared to a pure flash ADC.
You are right.
@@AndreasSpiess You are exactly right about not being able to do anything serious with the on-chip ADCs. Many people have this misconception. I enjoyed your video.
That was very enlightening, too bad my favorite MC ESP32 yielded such weak (lab) results - still plenty accurate though for many projects. Will look into the ADS1115. Dankeschön !
I also use the internal ADC. If you know what you can expect, it is ok.
The thing I use my ADC for most is monitoring a LiPo battery and solar panel voltage. I don't want to use an external ADC because they are power hungry, and if I am looking a battery voltage, I clearly care about power consumption. I have two related questions about voltage scaling.
Is there a correct way to turn a voltage divider on and off? I only read it once an hour so it would be nice if there were not a few millivolts leaking through it all the time. My thought was to use a 2N4001 between the voltage divider and ground, but of course that doesn't work because it makes the voltage at the pin too high when high impeadance. If I put a transistor above the resisters the BE current distorts the reading.
The other question is there a way to use the range of the ADC over an input voltage range not starting at 0.0 V? The protection circuit on my LiPo cell never allows the voltage to fall below 3.6(?) volts is there a circuit that will map 3.6 to 5.0v over the 0.0 to 1.0 V of the ADC input?
I do not know of a method to switch the divider off.
You always can add a battery to reduce the voltage. But maybe it is easier to use a better ADC and start measuring at 0 volts
To turn the voltage divider on and off in a WeMos D1 Mini, I currently use a logical MOSFET IRLZ44N between the external resistor and A0 pin and it works fine. Just put a small delay in reading Analog pin after turning on the mosfet to stabilize the reading. With the mosfet I'm able to read the voltage once for hour instead of continuously feeding the voltage divider with the battery.
Here's a not so simple circuit to do this. I had to do with what I had in my toolbox, therefor the many inexpensive BJT's...
ibb.co/6yrvdd7
FYI.
Re: ADS1115
It seems to be OK to supply input voltage to the ADS1115 even when it is not supplied with Vcc.
i.e I have a project where I am measuring the voltage of a car battery, using a ADS1115 and a ESP32 , using a voltage divider to reduce max of 16V to 3.3V on the input of the ADS1115
If I remove the supply voltage, the ADS1115 seems to survive even though the input was 3.2V and Vcc was 0V.
Possibly this is because I'm using 4.7k in series as part of the voltage divider, so the current would be limited to about 3.5mA.
In hindsight, I will try using higher values for the voltage divider and use a reservoir capacitor to reduce the effects of the higher impedance input.
e.g. try 47k and 12k as the divider, so that the max current would be only 0.3mA
PS. I just accidently destroyed on channel of ADS1115 by shorting the 4.7k resistor with a solder bridge, hence supplying 16 to one input, but the other inputs still work OK.
So when I rebuild my prototype I will change the voltage divider resistances.
So you were lucky that only one input was destroyed... I try to stay inside the limits of the data sheet.
Maybe the chip has an input protection diode towards VCC and as you write, this protects the chip during power off.
And you are right, you can use higher resistors for the voltage divider.
@@AndreasSpiess
I actually destroyed 2 inputs, because I shorted 2 resistors. However the other 2 inputs still work OK.
Before I replace the module I will do some more testing on the 2 remaining operational inputs to see how much current is taken by the ADC inputs when the battery I am measuring is still connected, but the supply to the ADS1115 is removed, i.e I don't power my entire sensing board.
Like you say, there is probably a protection diode to Vcc on the ADC inputs, but this diode is probably only designed to protect when the supply is removed from the ADS1115 when there is a series resistor connected to the ADC input.
I wonder if someone had a 1.5V battery connected directly to the input of the ADC, whether the input would be destroyed if the ADC was not powered.
I also need to experiment with higher value resistors in the voltage divider, to increase protection, The manufacturer seems to recommend resistor dividers with values around 1k Ohm in total, to prevent measurement error, according to a post on their forum. However the input impedance of the ADC is 3M Ohm, so higher values should not cause significant measurement error and adding a reservoir capacitor will also compensate for the higher resistor values albeit slowing response time.
Thanks for the video, I had a problem with the adc fluctuating reading with my arduino, I never knew that there are imperfections in these microchips.
I wish you also compared an STM32 board like the black pill (STM32f411)
I thought I did this in another video.
Nice video!. When you are in the presence of glitches, one way to improve accuracy is to take a lot of measurements and calculate average. Then compare all samples with the calculated average. Take out all samples outside certain margin. Let say 10%. Then calculate the average again. You can continue to get better results. Also you can use statistic formulas as standard deviation to decide when your result is accurate enough.
I agree you can reduce noise with those methods. Non-linearities will stay and unfortunately, the speed will decrease. But often, this does not matter.
We also have an additional problem with the ESP32: the input-voltage-to-ADC-reading graph is not linear but kind of parabolic. It seems you need to use an external ADC if you need a reasonable degree of accuracy,.
I agree.
So if your running an esp32 from battery and you want to test for low battery how would you do that as you don’t have a stable reference voltage?
Use a separate chip with an internal reference like the ads1115
I would connect a precision voltage reference chip to one analog input and calculate what Vcc would produce the measured value. The number goes up as Vcc goes down. You could also use this value to scale the other three analog inputs. Seems backwards, but it should work.
I beleive you can still use an internal voltage reference on the ESP32 - via `adc1_config_channel_atten(ADC1_CHANNEL_0, ADC_ATTEN_0db);` ... You can see more about the ADC in Espressif's ESP-IDF documentation (which you can use in Arduino code still) at docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/adc.html
Such a good explanation. I was desperate to understand why my reading are so wrong... Thank you Andreas. Would something like below also work?
int adcValue = analogRead(ADC2_PIN); //ADC2_PIN is an Adruino constant for ESP32 build-in internal reference voltage PIN on ADC2 (Analog-to-Digital Converter 2)
float voltage = adcValue * (DEFAULT_VREF / [ADC_RESOLUTION]); //DEFAULT_VREF is am Adruino constant for internal reference voltage value (1100.0)
I do not know what it should enhance. Noise can be "filtered" by averaging many readings, and systematically wrong values by calibration (store the difference to the exact value in EEPROM). All other effects are hard to eliminate (or even not possible)
At around 12:00 you say that the SAR conversion speed in an ATmega is dependent on how fast it reaches the correct value, but this is not true. It will always go through all 13 ADC clock cycles since the binary approximation not only goes stepwise up, but actually brackets in the "correct" value from both sides. The range given in the datasheet reflects that you have the choice of different CPU clock speeds and prescalers for the ADC clock.
you can also easily let the ATmega328 let measure its own supply voltage using the internal bandgap reference: www.sciencetronics.com/greenphotons/?p=1536
You are right. I made a mistake, but after thinking a little, I found it :-)
And video #10 shows how to use the internal reference
Thanks a lot .. A Quick question is there a 100 volt DC voltage Sensor ? or voltage divider is the only way out... Working on a raspberry pi based DC energy monitor wish you have something alike in pipeline... nicely declattered the fact of ADC 👌
The only way to go is a voltage divider in one or another form. Whether you build it yourself or anyone has built it and put it inside a module is the only difference.
The "normal" cheap digital multimeters have a native voltage range of 200 mV - everything above is realized by means of voltage dividers combined into the fixed 10 MΩ input resistance.
Hey Andreas.
In the AD7606 module you saw at the end,
the logic levels are 3,3 or 5 V?
Thank you!
It looks like 3.3 volt (see on the Aliexpress listing)
Great timing! I just got ten sliding potentiometers and was wondering how to measure their values. Found another video that shows how by connecting all the value pins with a diode to a single analog input, the VCC pin on the potentiometers can be muxed using digital outputs one after another. Also thinking of using a GPIO extender chip like the PCF8575 for this, so I could measure about 16 analog values (slowly) using a single analog pin in the Arduino with pins left over. Will be a MIDI controller project, don’t need resolution or speed or accuracy all that much imho.
You can buy analog MUX ICs like the 74HC4067
hey man, your secrets are the best! thanks for all this information . greeting from argentina amigo!
Glad you like them!
I wanna ask in min 14:24. Where does the 964 values comes from ?
I said it in the video.
Están increíbles todos los detalles que enseñó profesor... 👌😎
Gracias!
9:40 I understand that it takes time to find the correct value by halving the distance a couple of times. But would it not be possible to greatly optimize this by starting the next search from the last digitized value?
I assume that this what it would do. Maybe somebody knows this for sure.
What he is showing is a binary search, which is already quite fast. Instead of searching the 2^n possibilities (attempting every bit representation starting from 0, then 1, 2, 3...) using that search it will need at most n attempts (or maybe n+1). If that ADC can read up to 10V, starting from 5V is already looking at the last bit.
@gabest4: True. Specialized ADCs use exactly this method. It works best if you can expect something like a sine wave.
Another great tutorial. I enjoy my time watching your videos. Thanks for making such valuable content. 👍
Glad you enjoy it!
I am wondering why the chip designer for ESP32 didn’t add shield to the ADC part so that the result will not be influenced by the EM coupling.
Over sampling with noise shaping can increase the precision as well as remove the glitches, which was what I was expecting this video to include. But this method is really a simple and convenient way for the purpose, which is what I haven’t thought of.
I do not know the chip designers. But having Wi-Fi on the same chip is for sure a challenge.
I have pH and TDS sensors that I connected to the ESP32, but the values are not stable at all, even though the code is very correct and the sensors are very good and give accurate results on the Arduino, but on the ESP32 they are not accurate and not stable, they change by very high and very low degrees and are not close to reality. Will the ADS1115 help me stabilize the readings of these sensors?
It will be nice if there is updated version of this video. Considering now espresif have many varians (s3, C3, C2, etc)
Maybe an idea...
Hey Andreas, what about splitting the digital and analog star ground connection point? I mean putting one before the other, or vice versa.
I have used the internal ADC of the ATtiny/ATmega in several scientific (aka "serious") projects - and they are up to the task when 10 bit resolution is enough. But you can loose a lot of the potential by not using a good design for the front-end outside the chip. The datasheet of the AVR series recommends to use a 10 µH inductor in series with the AVCC supply pin as well as the mandatory 100 nF decoupling capacitor. Using a star-ground is absolutely necessary if you have parts around which will draw significant current. However, while AVCC and VCC in the ATmega are separated inside the GND-pins are all connected to the same metal-layer going all around the chip. But for everything you have outside the chip, i.e. voltage divider, possibly an opamp, a split GND is almost mandatory.
HI, I am newbie and have a question here may be very stupid... , for the equation that can get the voltage, why is x * 4095/1134, not x * 1134/4095? x not the adc value? Thanks for your answer
Make the calculations yourself with the highest reading of the ADC (4095). You probably get a strange voltage with your calculation.
This was super helpful and timely for me. I've been struggling with how inaccurate the ADC is in the ESP32 trying to get good voltage readings. I'm assuming that I don't need a voltage divider if use the ADS1115 to measure an 18650 Lion and if I power it from the ESP32 it wont cause a current draw when the ESP32 is in sleep mode?
I have learned some useful stuff struggling through this process though, like how to switch on and off a voltage divider using a N and P Channel MOSFET Module (CJMCU-4599 Si4599) so that the divider doesn't constantly drain the battery (thanks Ralph S Bacon). I also looked into using the INA219 board, but the .1 ohm resister creates a constant draw a battery as well. I'm going to give the ADS1115 board a try, I just ordered a few from Amazon. Andreas, thank you so much for presenting this information in such a clear and concise manner. Cheers!
Pay attention with the ADS1115: It cannot measure much above its VCC. So if you connect it to 3.3 you cannot measure 4.2 volts without voltage divider.
@@AndreasSpiess Thanks!
Dear Andreas,
on 12:13 is a little mistake: 5v should be divided by 1024, because 2 power 10 is 1024 quantification level. So, LSB voltage is 4.8mV. Look at source: en.wikipedia.org/wiki/Analog-to-digital_converter
I do no more discuss this matter. Last time I used 1024 and the other fraction complained. Anyway it has no effect if you calibrate to a particular voltage.
Hi folks,
I'm trying to get a voltage sensor to measure over 50V DC on an Arduino microcontroller. Any recommendations?
You can google "voltage divider calculator". Then you can can calculate the two resistors to get the voltage down to the range of your sensor
Hi Andreas, couldn't the vref supplied to an external ADC be monitored by one of the ADC channels from the esp32? Many thanks
And why would you do something like that?
@@AndreasSpiess tô recalculate The actial voltage valuw of The source if theb supply voltage varies
@@Leao16mm Better use a stable reference voltage (which is provided by most ADCs)
VRef is applied to the inverting inputs ( - ) of the operational amplifiers. When an input signal (voltage) is applied to Vin (non Inverting Inputs) ( + ), then the operational amplifiers will turn on accordingly because of the rules of the operational amplifier logic as a comparator. The way you have it, if Vin is zero, then all outputs on the operational amplifier is logic HIGH. So LEDs on the outputs on the Operational Amplifiers would turn off instead of turning on when an input signal is applied to Vin.
Excellent video, thank you!
A related interesting subject for a future video might be how to safely and accurately measure the voltages of a multi-cell battery. After a couple of evenings of googling I have found out that's not trivial.
Thank you for the suggestioon.
Maybe thats what you are looking for lazarduinoads1115.blogspot.com/2020/03/voltmetre-de-precision-avec-arduino.html I have a 4 cells version on trial now facebook.com/photo.php?fbid=10220134681951223&set=pcb.1665059790308923&type=3&theater
The typical manner is to have the most negative connection coupled to ground of your circuit, and then have voltage dividers for each cell. For a 4 cell battery, you could either use four identical voltage dividers, or preferably have four different ones each tuned to voltage ranges for each of the series cells. For simplicity sake, if it were a 4 cell lithium battery, 5v, 10v, 15v and 20v would be good voltage divider ranges to use for monitoring each successive series cell and being the most accurate for each in turn. Being able to measure the individual cells would be nice, but as you suggest, its not trivial, as you would need to somehow keep changing the ground/negative 'reference' when measuring each cell.
I thought it‘s really simple if you use an individual esp8266 for each cell. It‘s even scalable. What is wrong about that?
@@matzke089 That could work, yes, but has disadvantages:
1. Relatively expensive, especially for small batteries.
2. High power consumption, especially for small batteries.
3. Communication between the ESPs will have to be engineered carefully.
4. Generally complex and not elegant. A "brute force" solution, if you will. I like elegance and simplicity (the two usually go together).
I wish you would have released this video a couple of months ago. I struggled to get an ESP32 to read a thermistor, and I ened up having to generate a loop up table and do a linear extrapolation between the data points to get anything close to useful values out of the ADC.
The STM32's have an HAL_ADCEx_Calibration_Start function to improve ADC accuracy. I've used it in the past, but only to read battery voltages where accuracy wasn't really important. Do you have any idea what that is doing(maybe building it's own LUT)?
I never worked with STM32s, so I do not know.
Good Afternoon from south America. Andreas I have a doubt. ADS115 have a max. resolution 860S/s, to 16 bits it's equal to 41280bps (data=16bits+newline=8bits) it's correct this?
If I needed more channels for example 4 channels I would need another other mcu...or Arduino could help me?
I cannot follow. But the resolution is in bits and the speed is in conversions per second, not pits per second. Maybe you consult the data sheet for details.
I was just about to buy an ADS1115, good timing!
I hope you will like it!
Andreas, great video, very clear and useful.
@11:43 you say that the analog reference voltage AREF is not available but it actually appears to be connected to a pin of the header named IOH (I have a genuine Arduino Uno and AREF is marked on the header)
There is another commenter explaining the facts below
Thanks for replying.
@@AndreasSpiess, do you mean
Graham Wideman?
I understood your sentence as "the pin of the microcontroller is not connected" but you meant that "the pin is not connected to an on-board voltage reference". Is that the case?
I just bought a couple thermistors and an LM4040C41 and I'm going to use the Arduino to measure a couple temperatures. It would be nice if you showed how, even with a cheap and cheerful Arduino, it is possible to get fairly accurate measures when the signal is slow and the device (thermistor in my case) can be powered by the reference.
It was Uwe Zimmermann :
"available yes, connected to circuitry on the Arduino: no.
But be careful, if you switch the ADC reference to the internal bandgap reference while connecting another voltage to AREF blows out the internal bandgap reference for good."
Some of the best educational content out there!
Thank you!
Seriously good video. Thanks man! Appreciate your hard work :)
Glad you liked it!
Very nice characterization fod ADC's.
Thank you!
I have used the ADS 1115 recently. One challenge I had was reliably reading zero. If there was negative interference on the input, the output gets driven fully high, rather than the negative reading being ignored. Any solutions? Could I clip the negative somehow? Op amp? I’ve fudged it for now by adding a positive offset and then subtracting it in software. Resolution, range and accuracy comes at a price!
I saw this behavior, too if I grounded the input. When I added a serial resistor it stopped this behavior.
22:24 you say it shows 2.4994, but it's actually showing 2.4594 - which is correct, you or the output?
You are right. My old eyes read a wrong number. My mistake!
Very interesting! I'M currently into synth DIY, so the Ad1115 would be great for CV input, but how about audio rate input for sound processing? Any suggestions?
I never did this, so you have to search the web. I am sure you will find projects.
But AD1115 has only 860 samples per second - not useable for audio
@@jankomuzykant1844 yeah, that's why I asked for alternatives...
Nice video as usual. What is the ADC's name that you shown @23:38 in the video ?
AD7606
Impecable, como siempre Andreas
:-)