Це відео не доступне.
Перепрошуємо.
#171
Вставка
- Опубліковано 16 сер 2024
- Don't let a flat battery ruin your data gathering! This simple trick shows you how to detect a failing battery.
PCBWay Assembly Service only $30 with Quick Turnaround Time www.pcbway.com
You can read all this and MORE (eg Circuit Diagrams, Sketch) in my GitHub:
github.com/Ral...
So your battery-powered project runs on a buck-boost (or other DC to DC converter) and you need to monitor the voltage of the LiPO rather than the VCC supplied to the Arduino (as shown in video #160).
A simple configuration at the Arduino and a simple potential divider and it's job done! Then you can monitor the voltage of your LiPO (or car battery etc) and *get early warning* when it is on the slippery slope to complete discharge.
Remember, too, that you don't want to run a LiPO (eg an 18650) any lower than 3.0v or you will *permanently damage* the device and it may never fully recover. If your battery has protection circuitry included (18650 batteries WITH protection are slightly longer than unprotected ones) it will automatically shut it down at 3.0 volts anyway.
The sketch is so simple I'm almost embarrassed to upload it - BUT there is a *critical line* of code that is essential this all works without destroying your Arduino's AREF pin so do check it out before connecting anything.
List of all my videos
(Special thanks to Michael Kurt Vogel for compiling this)
bit.ly/UA-camV...
You can read all this and MORE in my GitHub:
github.com/Ral...
=============================
LINKS to products used in the video
=============================
CJMCU-4599 Si4599 N and P Channel 40V (D -S) *MOSFET Expansion Board* Module about $4 for 3 pieces:
www.banggood.c...
DC-DC *Boost Buck Adjustable* Step Up/Step Down Automatic Converter XL6009 Module about $2.67 (or $5 from UK warehouse):
www.banggood.c...
DC-DC 2.5V-15V to 3.3V *Fixed Output* Automatic Buck Boost Step Up Step Down $1.67 each:
www.banggood.c...
0.36 Inch *Digital Voltmeter* DC 0V-100V Three Wires 3 Digit Battery Voltage Panel Meter about $2 each or $1 each in a pack fo 10:
www.banggood.c...
Wemos *18650 UPS/PSU* as used in the video, about $7 for THREE pieces ($3.68 if bought indivually):
www.banggood.c...
Interactive cheat sheet for calculating *potential (resistor) divider* values:
www.ohmslawcalc...
My blog article on what happened to my eye (again):
ralphbacon.blo...
Popular Links
*YIHUA 938D Portable Hot Tweezers* Mini Soldering Station 110V/220V
bit.ly/2M8R0bj
DANIU Heavy Duty *Soldering Solder Iron Tip Cleaner* Steel Wire $3.33 from China, higher price local warehouse
bit.ly/Solderin...
SMD Components Solder *Practice Module Kit* - all components incl QFP chips
bit.ly/SMDPract...
If you like this video please give it a thumbs up, share it and if you're not already subscribed please consider doing so and joining me on my Arduinite journey
My channel and blog are here:
------------------------------------------------------------------
/ ralphbacon
ralphbacon.blog
------------------------------------------------------------------
All fine and good (plus another informative video), just don't put your health and well being at risk. I'm looking forward to many years of your work and can wait a bit for you to get better.
Your concern is greatly appreciated, Dale. It might be that I don't a video every week but we will see how it goes. It certainly takes longer working with just one (misty, slightly blurred) eye, that's for sure!
Cool video, thanks Ralph! For anyone not already aware.....those small voltmeters can be very easily calibrated by hooking up to a voltage reference and turning the tiny pot on the back of each one.
You are correct! I had to look under my microscope and there it was! Very, _very_ small. Tiny, in fact. A very small screwdriver will be required. Thanks for the heads up. Good to hear from you and I'm glad you liked the video.
Ralph, take a little bit of advice from an old MSEE. Rest, and tend to your eyesight. It’s important. I read your blog, and this is nothing to mess about with. (Sorry for ending that sentence with a preposition.)
I value your videos, and I’m still waiting for the one hour video where you build a GPS disciplined clock using an Arduino Uno, and explain the software build as well.
But, I would like your eyesight back firing on all 24 cylinders again. So take some time, mend and stay optimistic. We all are rooting for you, believe me.
Great video. Good advice, and I like the way you set the reference voltage and can shut it down when you need low current mode. Excellent!!
Thank you for your concern and wise words. As it happens I might just do a couple of videos a month for the next month - we'll see how it goes.
Were you serious about the GPS clock? We've covered using GPS in a past video #70. Grabbing the time from that and displaying it any way you want is easy enough - 7-segment LED, 64-LED moving LED matrix... whatever! I don't think you were serious! But correct me if I am wrong.
Thanks for posting, very good to hear from you.
Ralph S Bacon You are most welcome! I expect to continue learning from you for many more years. So take care of those eyes! I know you will, but don’t become discouraged!
So the GPS disciplined clock...
Personally, I think it would be a great project for all your viewers. An ATMega 328P-PU, a GPS receiver/with built in antenna, and an e-Bay Maxium DS 3231 RTC clock module with battery backup, and a display, color LCD or the like. THEN create a PCB and give everyone the gerber and drill files to have it made by JCBPCB and have it built themselves.
The GPS will be on the job all 24 hours, but every hour, the software sends that hourly update to the RTC clock module, and the LCD display. Use a dip switch that tells the software what time zone you’re in and then the software displays the precise time and date. In the time between updates, the software just uses the RTC DS3231 and keeps the display updated every second. It won’t drift much during the hour.
Now for the fun part: split it up over 6-8 months. I know you can do it in your sleep. But for us out here, learning this hardware and software, watching you and building the clock... it is really a great learning tool. Spread it out over time and set a deadline. Finish by 1st week of November, say. Then you can actually teach the hardware build and the software build.
And break it up with some other projects like the Tiny85 or 15 projects also. I find them absolutely fantastic. And show more AVR programming, or another project you fancy.
Nothing that would hamper your healing though. Sounds complex, but, in small bites, I think it would be stellar. Just an idea.
Be safe and take care of yourself!!
God to see you back, I hope your eyes get better
Cool glasses :)
Most of those volt meters can be adjusted for accuracy.
Well explained as usual and good ideers.
Yes, there's a tiny variable resistor on the back. I didn't see it, unsurprisingly! Now I know where it is. Glad you like my glasses. Did you still want a universal timer board (green)? Email me!
Good to see you safe and well again.
Yes, but I'm not at the end of the tunnel quite yet, Ken, but fingers crossed. Thank you for your kind wishes.
To use your opening line “and welcome back!”. Glad to see you back after your surgery. I hope all is going well. As one of my wife’s aunt said when you get to our age it’s patch, patch, patch.
She is correct! I have umpteen pairs of glasses all with a patch on the right eye. No pirate jokes please.
Great to see you back Ralph. You were certainly missed here.
I was just working on a PCB layout that uses the circuit from video #123 but modified a little. I'm using an NPN transistor instead of the N-channel MOSFET. The p-channel can be used on it's own to switch an input voltage on/off or can be used for auto-power off using the NPN. The pcb also has a 3.3v regulator to provide a 3.3v bus and a 5v bus along side an I2C bus. It also includes a header for an NRF24 module. The micro-controller is an Arduino Nano. I've used a dupont jumper to select whether the Nano is powered from the P-channel output or directly from 5v input. I used the separate NPN and P-channel because the cost of the SI4599 using the SMD assembly service is $2.74 USD each which I thought was crazy high and it's not in the 'basic' component selection for SMD assembly.
Great to see you creating custom PCBs - and you have considered a lot of options, nice work, if I may say so. The assembly cost for "non-basic" components is indeed quite high. I think I would have soldered that component myself but I can understand why you would not want to. Yes, the BJT would work in place of the N-channel MOSFET, just not quite as convenient, but it's marginal. Thanks for your good wishes, and thanks for posting.
Great video as always, I can think of many applications for this idea. Please take good care of your eye, I wish you a speedy and full recovery!
Thanks, Bora, always good to hear from you.
Interesting vid. Glad you're getting back into the groove! Look after yourself.
Glad you liked it, although it wasn't really groovy! I will certainly (try and) look after myself. Thanks for posting.
Glad you're getting better. Your video has just stopped me making a mistake on the bord that I am working on . I had 1 mosfet now I see where I have gone wrong. Thanks.
Interesting, Michael, that you're only using 1 MOSFET. In some circumstances just using the P-Channel should work (though not in the original Auto Switch-Off configuration from video #123). The item I was showing was the dual MOSFET but I have others ready to show once I can see to solder them onto DIP boards! The takeaway from this video is that using the dual MOSFET approach is guaranteed to work!
And welcome back Ralph!
Couple of comments.
1) Why did you use a dual mosfet IC to switch off the current through the resistors I use just one N Channel on the low side on my current project?
2)Also a tip for getting the voltage divide accurate as I played around for some time using offset factors to make it accurate but all really needed to do was measure the actual resistance of the two resistors and use that instead and it was bang on correct after that, for example the 5.1k resistor was actually 5010ohms.
Great to have you back mate but the glasses have to go it looked like Christmas at Elton Johns house ;)
Thanks Andrew!
Sorry about the glasses but next week it's either Wizard or Danny La Rue!
Now, I used the dual MOSFET approach for two reasons:
1) we had used that circuit (sort of) in the Auto Switch Off video #123 and I felt it was a good opportunity to reinforce that circuit (even if viewers don't use it as shown here)
2) I had that nice dual MOSFET chip/breakout board hanging around like a bad smell and now was the time I could show everyone how easy it was to use and then put it in my component drawer, off my workbench! I also mentioned some others I have with a 1.8v gate voltage - for future use.
In future I think I must emphasise the fact that the things I show in my videos are mostly demos to highlight a particular feature or component or code example (or all three). As an example, my toothbrush timer project (now used every day, it's great BTW) would never normally be used with a 74HC165 Shift Register and DIP switches! But it was a great opportunity (I thought) to show a way of reading DIP switch values very easily for whatever project might need flexibility like that. Better than a rather sterile breadboard and no practical application, however weird that application I'm using it for appears to be! Right, now I'm off to buy a new electric toothbrush that doesn't even need a separate toothbrush timer!
I'm explaining all this here, not for you Andrew, but for everyone else who might read it and realise why some of the "solutions" to my projects are a little over-engineered. I'm obviously being too subtle about it, ha ha!
On the three wire usage of the Volt meter: that's needed when trying to detect V 4V? Then you can use the two-wire configuration just as well.
That's true, Eric-Jan, the diagram does show that although my one works right down to 2.0V (slightly dim, but useable). And it goes right up to 100V. Oh, and as others have reminded me, it DOES have an adjustment on the back too.
Glad to see you back up and exercising my old grey cells again.
And it exercised my brain cells too, making this very disjointed video, as I had to stop often. But it can only get better!
Hi Ralph, good to have you back.
As an aside to the fet on /off control, have a look at the dedicated LTC2954. Now an Analog Devices part in the same package as the dual fet although you still need a seperate P channel fet. Operates over a wide voltage range and low supply current of 6 micro amps.
Great information, IVo, I shall Google it immediately I've responded to comments here, thanks for the heads up. I lied! I looked immediately, Very interesting.
www.analog.com/media/en/technical-documentation/data-sheets/2954fb.pdf
Great Festive Glasses and good to see the festive season being celebrated.
If invented I would like to send you a couple of bionic eyes with optics that focus between 1mm and one mile, just have to invent them now.
Fantastic vid and thanks for sharing.
Happy Christmas and a Happy New Year.
👍👍👍👍👍
I've applied on your behalf for a patent for those bionic eyes. Just let me now when you have a completed set and we'll complete the paperwork!!! I wish! The consultant told me he couldn't see the back of my eye clearly now because of the cataract introduced by the gas bubble in my eye. It just gets better by the day! Not! But at least I put out a video! Thanks for your kind wishes, and happy you liked my festive sunglasses, great to hear from you.
Great to see you back Ralph! Don't stress about putting videos on every week. I for one have to keep watching your older videos over and over, as I build various projects. As others have said look after your health first. Good on ya mate!!
So it's you, Jimbo, increasing my viewing statistics, single-handedly! I'm glad they are that useful! don't worry, I'm looking after my eyes, just waiting for my sight to come back in that right eye!
@@RalphBacon It's only fair Ralph, as I have gained so much from them and your posts on GitHub. Have a great Christmas to you and yours, and to all of our fellow enthusiasts.
Good to see you back. Please take care of your health.
The voltage divider can be switched on/off way easier than you did. Have a look at the battery sensors of mysensors.org.
They connect the gnd of the voltage divider to a pin of atmega. When output of this pin is set to zero, the voltage divider does its work. When the pin is set to input -without pull up/pull down resistor, the pin just floats. Then there is no voltage drop over the voltage divider. So no power loss.
Yes, that is an alternative way of doing it, Psilin, and we've used that method when switching on actual devices to save power. But I was just experimenting with those dual MOSFET devices in the hope others can see further uses (eg auto switch-off). All good, thanks for the simpler method.
Hi Ralph. Sorry hear your eye is not yet up to snuff. You have my total sympathies since a year ago at my last annual diabetic ophthalmic exam I was told that there were signs of macular degeneration, but at that time I was experiencing no visible symptoms at all. Wind on about 7 months and suddenly, literally overnight, I'd lost all vision, other than colour, vague shapes and sort of outlines in my left eye!! Turns out I have had quite a severe bleed from capillary veins in that eye, probably from a blocked vein.
Roll on a few months, multiple waits for appointments, multiple eye scans and finally treatment by way of an injection into the eye which took almost immediate effect, as the next day vision had improved markedly. It's still blurred but with a much greater level of detail, thank goodness. I have this year's exam tomorrow and another appointment for a further injection early next year so here's hoping for further improvement. Now at least I can ALMOST read my keyboard which previously was just a dark rectangle!
Likewise I hope your eye/s get sorted fully ASAP since even though I have just one reasonable eye I have been trying to do some relatively ordinary soldering (repairs) and have been struggling significantly without stereoscopic vision. So when I say you have my sympathies, you know I mean it. Not a nice thing for anyone to have or endure but especially when doing what you love relies on good if not excellent eyesight. Good luck and best wishes for Christmas and the New Year!
Ouch, now you really have got me cringing in empathy, Bob. I'm so glad you've said it is getting better, we understand each other's condition and what it means only too well. I hope your eye continues to improve with further medication. As I've said before, next year 2020 is also the result we will both get from our eyesight tests, right? 20/20 vision. Fingers crossed.
Stereoscopic vision is so essential to carrying out everyday tasks, I've found. Even making a cup of tea can mean I miss the cup with the hot water entirely. As for putting in Dupont cables into a breadboard, well, that brings a whole new level of frustration as I miss the hole, time after time. I tried to solder but ended up sticking the hot soldering iron into my hand rather than onto the PCB so I've given up for now.
It can only get better with us both, right, Bob? Great to hear from you (well, sort of, you know what I mean) I hope you have a great Xmas and a good start to the New Year. 20/20. Don't forget your eye test!
I have used those little meters a LOT over the years, keeps track of the voltage on my home built spotlight and such.
Now that I've discovered the adjustment pot on the back (miniscule) I like them even more!
Glad you are back, Ralph......but hope you are completely fixed and recovered soon!
It will take a while before I can be truly fixed but thank you for your good wishes!
Welcome back Ralph, glad you have recovered sufficient to be able to entertain and teach us again :-).
I think the glasses were more than enough entertainment, for sure, Ole! Glad you liked the video!
Hello Ralph, glad to see you back at the bench. What you said about Li-po is correct, but 18650's are Li-on and can be run down to 2.5v before they are damaged. Using the 3.3v ref for comparison against battery voltage would be perfectly safe.
What people call Li-po and Li-ion are the same thing just in a different form factor and built for different applications.
@@superdau and with different chemistries. Therefore not "the same thing" at all.
@@Tsnafu
The chemistry has nothing to do with the form factor. They can have different chemistry, but so can cylindrical cells between them and pouch cells between them. Again, the form factor is not what dictates the chemistry, what the manufacturer puts in them is. You can have the same chemistry in either form factor. Have you ever seen something like IMR, INR, ICR, IFR, LMO, NMC, NCA, NCO, LCO or LFP written on cylindrical cells or in their datasheet? Those signify different chemistries. Pouch cells use the same chemistries, although they most often use the Lithium-cobalt-oxide chemistry (ICR/LCO), which is also the same that's often used in laptop battery 18650 cells. So they *are* the same thing.
My guess why "li-po" as a name for pouch cells came to be is marketing. Cylindrical cells were the norm when the somewhat "freeform" pouch cells came along. Someone heard about the "new" cell chemistry of real li-po batteries at the same time and slapped that label on their batteries, because, hey, they got a polymer sheet separator in there (as all of those cells, even the cylindrical ones, had anyway) and a polymer (=plastic) pouch around it, even when that has got nothing to to with actual li-po cells. Lipos true to the original meaning of the name (the electrolyte itself being a solid polymer) still don't exist commercially. And even if they should ever exist, they will still be li-ion cells.
The protection circuit on my Li-Ion cells (like the on in the video) does kick in pretty much at 3.0 ±0.1v. Perhaps it is being very cautious? I misspoke when I said LiPOl I just tend to use that term for all rechargeable batteries, LiPO, Li-Ion, half the time we don't know what type it is!
Update: Jessica says her Li-Ion cylindrical battery cuts off at 2.5V so maybe my one is super cautious?
Welcome back strong as ever with a new interesting project.
Love your glasses, though I believe you can see them on for a very good reason.
The festive (sun) glasses dim the glare of the monitors and my video lights so they help me quite a bit. Glad you liked the project, thanks for posting.
Glad to see you're feeling better.
Thanks, Lee, it's a waiting game now!
Have you already made (or considered making) a custom board which combines the battery voltage check and a full power disconnect as a little breakout board. Maybe also include battery protection (tp4056+dw01 + FET) as not all batteries have protection and possible load sharing so battery can complete its charge?
Think this could be desirable and an interesting challenge/video?
Happy new year Ralph!
Well, my outdoor storage container (bin lids) project uses an 18650 battery and sends the battery voltage to me here in the workshop along with the lid status. When the lid closes it switches off the circuit completely, see videos #221, #214 which describes this project (I think).
@@RalphBacon thanks very much will take a look!
My festive break has involved watching many of your videos, keep it up!
Glad your back and feeling a bit better, oh yes good video
Glad you liked it Keith, and yes it's good to be back too!
Welcome back and nice to hear your pleasant voice here again.
I'm very happy you think I have a pleasant voice, Sgt Bond! And I'm glad to be back too, thanks for posting.
Ralph, you rock! Take care of yourself is Job #1. Get well soon
Thank you and I will! Nice to hear from you.
Best wishes and hope you recover!
Thanks, Bollie! Fingers crossed!
Good to see you back Ralph! (No pun intended)
Quick question.....if you only use an input source of 5v or less do you really need the voltage divider and an external 3.3 ARef? Couldn't you just hook up the battery+ to A0 and monitor analogRead() to a specific level, say a value of 700 for 3.4v? (0.0049V / count).
Without any resistors drawing power could you then omit the switching too?
Just thinking out loud.
use a 10k in series with A0 if it is a 5volt arduino. Use a 10k in series with A0 and a 10k from A0 to GND if your arduino is 3.3volts. the above is only if the battery voltage is 5 volts use a larger resistor (15k or 20k) in series with A0 and 10k to GND. just for info 5 volts / 1024 = 4.88 mV.
i always like to use a clean noise free source for my ADC's Ref. when the battery is getting low the DC_DC converter might start getting more noise on its output. what's the cost of a few extra resistors and a fet or so. if you want to make it more accurate then your into ref, resistor temp coefficients and drift over time, getting a known reading now does not mean that in a years time it will read the same.
It is another method
If your supply is FIXED at 5v (and doesn't run down as the battery gets flat) then you can do it your way. Just remember that the AREF by DEFAULT compares against VCC (whatever that is) so 3.3v compared against 5v (DEFAULT analog ref) is about 675 on the analog port, but 689 against 4.9v. But if the VCC drops to 3.5v then A0 will report 965 for 3.3v! So you can see the importance of a stable VCC reference (which is what the 3v3 output from the Arduino's voltage regulator gives us).
I hear you but doesn't that buck/boost module maintain a FIXED output voltage? Its written in the description as being **FIXED OUTPUT**....so the AREF will be compared to a fixed VCC regardless of the battery voltage....no?
Not trying to be awkward but I know you don't do something without good reason and yes, for an 'unregulated' supply the whole resistor divider/external Aref makes perfect sense.
Ralph, Instead of switching the high side of the resistor divider with mosfets, how about switching the low side (GND) using an arduino port? Instead of connecting the low side of the voltage divider to ground, connnect it to an arduino digital pin. Then, in code: pinMode( VMgnd,OUTPUT); digitalWrite(VMgnd,LOW); would turn the voltmeter on. digitalWrite(VMgnd,HIGH); would turn the voltmeter off. Or, the pin could be tri-stated by setting pinmode INPUT, which would provide a high-impedance connection, effectively turning the voltmeter off. This seems simpler than all those mosfets.
Switching the low side never works well, John. That's because the ground reference changes and upsets the entire electronic circuit. Try it if you want (and, who knows, maybe it will work for you) but I'll stick to high side switching.
Welcome back Ralph, another informative video. I hope you make 100% recovery and I hope it is soon. We take many things for granted until they go wrong. All the very best for Christmas to you and your clan. Greg
Wow! Two comments from you, Greg, that great, keeping up my stats with UA-cam, always appreciated! Seriously, I am grateful for all the good wishes from everyone, including you of course.
I ordered some of those two mosfet on a board chips some time ago. What with this damn virus thing, it took so damn long to get here that I plum forgot what I wanted them for. So I have been going back and reviewing videos from around that time and I found this one. Perhaps this is the one that sold me on them however I haven't figured out what I was going to do with them in the first place, except perhaps to play with them. Guess I am just a kid at heart even though I will be 69 years old in two weeks.
That's happened to me many times. In fact, even now I'm still waiting on stuff I've ordered several weeks ago and have lost interest in the item! Usually, it was free delivery to the UK, and quick too. Now it's not free and not quick.
Good to see you back. Even if I did think I'd tuned in to Elton John. ;)
They were a bit Elton, weren't they, ca. 1975 during his Glam Rock phase (that never quite ended). Just a bit of fun with a serious side inasmuch they helped me avoid the glare of the video lights and monitors.
I thought the same, a weird "Elton John" version from the 70's! Ralph, I'm glad all went well with the surgery!!!
Looking good Ralph.
"As always", I think you forgot to mention, Ane. Not to forget "youthful", "intelligent" and let's not forget "humble", "modest" and "self-deprecating". Oh. I see how that doesn't work now. Drat! Thanks for posting!
WELCOME BACK 😀
Ha ha! Cheeky, Mark, but most appreciated!
Good day, Ralph! I'm glad to realise you're back online. This is GREAT !!
I'm sure you'll excuse my behaviour as I laughed when I first saw you with those glasses. LOL! I do fully understand you wearing those, however. Better take it slowly.
Thank you for that very instructive video and I hope you will recover 100% of that vision .. age considering, of course. Health first !!
When I built my Weather Station, I figured out another way to measure the battery voltage, since I included a battery monitor in my project. I'll write to you this weekend and we'll talk about that.
Have a nice weekend, my Friend. Take care and God bless!
Thank you , Daniel, for your warm Welcome Back - hang on where have I heard that before? Always look forward to your missives, speak to you soon!
cool and interesting stuff i like the in-depth approach you do too..top stuff
Glad you liked it!
God to see you back here
Thanks, Wegi, it's nice to be back! Thanks for posting, nice to hear from you.
Hey there Ralph love the glasses. I can just hear the Dad-jokes about them, lol. I feel like you made this video for my benefit and it is on the money for my mobility Scooter control board. I had not thought about switching the current through the voltage divider but a lot easier than doing it in code. I will also be getting a few of the SI4599's, much cheaper that buying the mosfets (everything is more expensive here).
As you know I spent a lot of time messing getting multiple voltage dividers working to monitor the 24v battery and if the charger had been connected. I used a Zener diode in reverse bios to clamp the voltage going to the Arduino to 5v max regardless of fluctuations from the battery/supply. This worked very well.
Take care brother.
If you watched the next video, Adrian, you will have been even more impressed I am sure. Not with the video, but with the additional Xmas decorations!
Glad you're back
Thanks, Dave, thanks for posting.
Very interesting video, thank you for sharing. I found your circuit diagrams for the two transistors, can you share the diagram for using the Si4599?
I've added this to my GitHub repository for this video:
github.com/RalphBacon/171-Monitor-Your-Battery
Go to the "images" folder and find the file "LiPO Monitor Circuit.JPG", which is a rather shaky, hand drawn circuit diagram and shows how the Si4599 fits in.
Thanks Ralph!
I don't have much time lately for my hobby, but I make time for your work, glad your on the mend (couldn't take much more of the glasses !) great vid and love these little voltmeters haven't seen them before, and your right, a good idea to have a couple lying around...cheers and merry christmas to you and your family.
I'm flattered by your loyalty, Andy, thank you for sticking with me! As others have mentioned there is a TINY (I mean MINUTE) variable resistor on the back of the LED display to make it more accurate, I didn't spot it with my eyes until I used the USB microscope.
@@RalphBacon Oh!..I forgot to mention how cool it is to have you vids laid out as they are, they can now be used as reference, info at a glance, it brings it home to me just how much stuff you have, a veritable gold mine of tutorials..well done to you and the gentleman who made the list.
You're referring to Mike Vogel, from down under (well, he is unless you're from down there too). He does a great job. I use the list all the time now to find old videos! Far quicker than scrolling through UA-cam pages!
more easily you can switch off the voltage divider by just connecting the lower side of the voltage divider to an IO pin. Switching this pin to an output and outputting a 0 will switch the GPIO to ground and thus also the lower side of the voltage divider. Switching the IO pin as input without pull-up will leave the voltage divider floating and no current will flow.
The series resistance of the output pin is less than 100 ohm and negligible compared to the tolerance of the resistors in your divider.
Alternatively it is also enough to just have a single NPN or n-channel MOSFET at the foot of the voltage divider to switch it off.
This works reliably as long as the voltage you want to measure is lower than the supply voltage of the microcontroller, because otherwise you might get a leakage current into the protection diodes.
You can also easily scale up the two resistors in your voltage divider by a factor of 10 and then you should be able to leave it on.
Indeed, Uwe, that would be a very good way to approach this problem and probably similar to how I might do it in the future. I wonder how high the resistors can go with the analog input still being able to reliably read the voltage? If we got the current through the resistors down to a couple of microamps then, as you say, just leave it wired up!
@@RalphBacon I did some tests before a student lab 2 years ago and was surprised. In the lab I let the students measure the discharge of a capacitor with an Arduino nano. The interesting fact is that a discharge resistor of 100 Mohm parallel with the input and capacitor is not yet significantly affected by the internal resistance of the Ain-pin - so I must assume that the analog inputs of the ATmega have a resistance in the order of 10 Gohm!
Actually, if you connect the lower end to an IO pin and set it to input-no-pullup, the middle of the "divider" will suddenly rise to the full supply voltage, potentially killing the Arduino. Granted, it's a very small current, but still.
I suggest simply using bigger resistors (~10MΩ) and leaving it connected.
In addition, you can dispense with the AREF connection and simply instruct the chip to use its internal 1.1V reference. Choose a resistive divider that produces voltages between 0V and 1.1V, and go from there.
@@SodAlmighty as I wrote: "This works reliably as long as the voltage you want to measure is lower than the supply voltage of the microcontroller, because otherwise you might get a leakage current into the protection diodes."
Love your videos, but I was worried about sparks at 12:50 between the bare alligator clips when you moved the wires. LOL
That was done just to keep you tuned in, David! Keeps my audience interested to see if I am going to survive the episode!
Welcome back Ralph.
Cheers, Phil, you stole my intro catchphrase though!
Hello Ralph. I'm using a buck/boost regulator powered by 3 1.5 AA batteries to provide Vcc=3.3V to my ATMega328 with fuses burned for 8MHz internal clock mode. I just want to detect when the 3 battery levels are < 3.0 V according to the regulator minimum Voltage spec. Seems to me, all I need to do is read pin A0 connected to the batteries via a voltage divider R1/(R1+R2)=.6875, and calculate Vbats=4.8*readval/1023 (where 4.8 is max. voltage of the 3 bats.) so that I know when it's time to change them. Do you agree? Thanks.
Not to simple, Bill. The analog ports will ALWAYS read 1023 if connected to the VCC line as the VCC value is fixed, whether +5v or 3.2v. So the analog ports compare to the VCC value, understood?
You need to compare the incoming voltage to the fixed internal reference voltage (1v1) on which I have done a couple of videos: #160, #171 which do the trick nicely. I'm using that technique right now monitoring my batteries in a project (all three). Works like a dream.
@@RalphBacon Hi Ralph. I'm using 3 AA batteries to power a buck boost converter. The Arduino VCC line is coming from the buck boost converter output (always 3.3V or 0 if battery is dead). The analog port is connected directly to the battery output (I had to use a resistive divider 'cuz fully charged batteries provides 4.5V).
Hi, I make a similar device with the 1.1 volt internal référence build in the Att328 and two resistors 75k/24k. Thank for the interrupting device with 2 fets. It's à very good idea. Xmas and bye from France
Glad you liked it Rene, from France. So you are using the internal 1v1 as your reference for the analog input? How does that work? Surely the 1v1 is too low to compare against?
@@RalphBacon I use it for read the voltage of a alcaline battery Ni-mh and Li-ion cell. I make a little device for evaluate the internal resistor for these bat.You can have my code and schematic on github.com/kotec-le-raleur/Resistance_interne.
It's just a little project , but it work for me and I can dispatch my cells between bad or good. Sorry for my poor syntax !
why switch high side and use both types of mosfets? ADC input is high-Z anyway, right? So just use n-ch mosfet and switch resistor divider's ground.
I'm assuming you mean connect the Drain from the N-channel to the LiPO +ve, the Gate to the GPIO pin, the Source via two resistors to GND with the junction of the resistors going to A0? Normally the Source of an N-channel needs to go to ground to work properly (including getting the Gate voltage +5v above Source voltage). Have you tried this? It _might_ work but I haven't tested this.
@@RalphBacon No, what you are describing is called high side switching. It won't work without bootstrap gate driver. But if you move voltage divider between +Ve and Drain, while connecting source directly to -Ve, it should work. The only limitation would be voltage of battery pack should not exceed input voltage of ADC pin, which should be fine in your case with 5V MCU and 1S LiPo.
See schematic:
i.imgur.com/gjRssCb.jpg
Edit: Hell, you could connect 1S Li directly to 5V MCU, and there would be no need to waste power on divider at all. If your battery pack voltage exceeds input voltage of MCU, then your circuit makes sense.
Or even better add a simple zener:
i.imgur.com/l0rDmwU.jpg
Yes, the zener would be required if the voltage was above 5.5V otherwise you are presenting more than that (potentially) to the A0 pin (eg car battery, drone battery). Zeners are not Schmidt triggers though, they can start conducting quite early on in the voltage range, trial and error may be required! Thanks for clarifying.
I see a lot of comments here stating that you don't need a voltage divider since the battery is less than 5v.
this is false.
wall of rambly text incoming, I tend to write the same way I think...not always easy to follow
the ATMEGA 328p (I'll just call it the chip from here on, it's easier) has protection diodes for all its inputs, including the analog ones
that means you can power the chip from any single pin until that protection diode fails
so you find yourself thinking the chip is unpowered and not working, and the feed from a data line is powering it so it is running normally
I should point out that these particular diodes are not designed to power the chip, only to protect the pin from overvoltage...
so you toss a voltage divider in and it limits the current to a few nanoamps, problem solved, the chip powers only from the main rail, no risk to the internal diodes, all is well
playing Schrodinger's cat with an Arduino is no fun...is it alive?
as a bonus note: forum.arduino.cc/index.php?topic=102770.5;imode
Yes, I did notice that, Jeff, I would always limit the current via a voltage divider in this sort of situation. And once we go above 5v it's required anyway. Thanks for posting, good to hear from you.
Voltage divider isn't necessary if the maximum battery voltage is less than Vcc.
The important lesson here is that one can switch sub-circuits off and on by microcontroller output.
That's a lesson with which automotive manufacturers seem to be taking many years to learn as they add their products to the Internet of Toys. Because consumers love to come back home after a long vacation to find their car dead in the garage.
the voltage divider is required as the ADC reference voltage is lower then the supply. Ralph connected it to the 3V3 regulator output as it should be more stable than the 5V.
That's happened to me, Bernd. Car battery flat after 3 weeks. It must happen often because there was an AA (Automobile Association) assistance truck patrolling the car park giving free jump starts to motorists like me!
Certainly for battery powered circuits switching off sub-circuits is imperative. I even do that in Benny cat run for the (mains powered) Rain Detector. It has stopped the corrosion on the sensor because it is now only switched on for two seconds twice a minute.
Welcome bk sir.very informative video
Glad you liked it Muhammad! Nice to hear from you again.
I wonder if a portion of a 4007 IC could be useful in terms of providing a couple of complementary FETs...?
Sounds possible but the only way to find out is to actually do it. Remember that the chips inside a CD4007 will be fairly low current. I probably have one of those chips lying around, I will put the idea on my list!
I the ad part for pcbway, you mix up the bit about supplying some or all of the parts.
Drat! I only noticed that right at the end. But no-one has mentioned it, so if we keep it quiet I think I might have got away with it, Andy!
@@RalphBacon my lips are sealed.
You are looking great!
You ain't seen nothing yet, Ernst! The Christmas season is upon us!
You did make that more complicated than it have to be. With a 5V processor and
I love all those discharge curves - I even have some of the exact batteries you have tested. I guess the "nominal" voltage is more an "average" voltage. At least you showed the voltages all dropping off the edge of a cliff though, at the end. But it seems we might catch it before that happens with the discharge curves you plotted. Very instructional, thanks for that.
But I made it (slightly) more complicated one to allow for voltages greater than 5v (eg many drone batteries are higher voltages) and car batteries (or other, smaller lead-acid ones) are 12v of course. Not to be connected to the Arduino without a resistor divider (and now everyone knows the formula to calculate that too!).
I did wonder if a P-Channel MOSFET with its gate brought LOW by an Arduino GPIO and the DRAIN brought to ground via a series resistor (connected to A0) would work reliably. You seem to indicate that would work OK?
I test all the batteries I can get my hands on (LiIon, NiMH & Alkaline), this also means I publish a few battery reviews each week and have done that since 2012.
The nominal voltage for LiIon is the average output voltage, sometimes (not often) you even see it specified with and extra digit like 3.62V instead of just 3.6V or 3.7V
As long as battery voltage is below Arduino voltage and you do not turn the port output off (High-Z or remove power to processor), you can control it directly. If you remove power to the processor the FET will most likely be on.
I think that was one of the issues that Jessica faced: the analog port remained on after switching off the Arduino and started then powering the whole thing in some weird way. I never knew there were so many batteries out there, you must be busy doing all this!
Battery tests are mostly automatic, but they take nearly a week for each battery (A few is more), I have a couple of "Test stations" that I simply has to load with next battery. In addition I have to take some photos, do a minimal amount of writing, move some files and run a couple of scripts. It is not that much work, some of my other reviews requires much more work.
@@henrikjensen3278 Have you found that the discharge curve is fairly linear over the useful range say 4.2 to 3.3 so that after 20 minutes or so you can extrapolate ? I have been charging then discharge and plotting the volt vs time at a constant current discharge using recycled batts and found I really didn't have to discharge all the way.
It's good to see you back Ralph. I am making a 5 volt pack and I am using vcc as a reference (internally) so I dont need to use a voltage divider to measure cell voltage. But in your case could you connect the bottom of the voltage divider to a pin and make it high Z when not measuring and low when you are measuring ? I am using an ATTiny85 (thanks to your videos). I have a LED and a push btn switch. When the switch is pushed the Tiny reads the voltage and blinks the led to let me know what the voltage is to two decimal places so I know when to charge it.
" could you connect the bottom of the voltage divider to a pin" Where would the junction be connected to?
"I have a LED and a push btn switch." Why not periodically check....no need for a switch
@@kennmossman8701 The junction goes to the ADC like usual. Instead of connecting the bottom of the divider to ground connect to another pin. Make the pin low (close to ground) then make the measurement.
@@kennmossman8701 Because then its blinking the led when I don't need to know the batt. voltage. That uses more power.
@@noweare1 say what? in pseudo code"
if delta elapsed time > a minute or such
if battery voltage is low
blink LED
Hi mr. Ralph, Is possible make a video where you go in more depth and show how this is setup? I've tried but not able to get it to work. I need a way to measure battery voltage on 3.3v battery operated sensor.
It depends, Stig, on whether you are running on a 3v3 battery (perhaps 2 AA batteries?) or whether the battery goes through a buck/boost converter before getting to your Arduino. Is the sensor close to the Arduino or remote? Let me know your setup.
@@RalphBacon You know what, I just realized that I had forgot to put in 100K resistors like in your schematics so it works now :-) My plan is to make a wireless weather sensor using ATTiny84 with a weather sensor, a 433Mhz transmitter and a voltage divider. My thinking is to run all this from a CR2032. My thinking is to have the ATTiny sleep every 30 min, then wake up, turn on the sensor and read, connect the voltage divider and read voltage, turn on transmitter and send (haven't found out yet if sleep mode is supported) and then go back to sleep. All this data will be sent to an ESP32 with a small display and to the cloud so that I can integrate with Google Home and maybe even create an app. aconfluence.no/display/SS/Google+Assistant+based+weather+station
I'm not very good at this but it's a nice project and I learn a lot. Thank you so much for your help and inspiration :-)
I'm very glad you got it working. Just one point on the "waking up every 30 minutes". The maximum time an AVR chip will sleep is 8 seconds before being woking by the WDT. You can, of course, check a counter, increment it if it is not time yet to wake up, and go straight back to sleep. This means your Tiny44 will wake up about 225 times to increment that counter before deciding to do some real work. Still very power efficient. Or use an external interrupt - the question is, what?
Watch my videos on this topic, #115 and #116.
@@RalphBacon I watched the videos and it's exactly what I need. Just one note to the schematic, I needed a 1000 ohm resistor between P Channel Drain and ground before AO was able to measure correct voltage, with out, my oscilloscope showed just a few mv change between high and low. Is this correct?
Ralph! It's a good job you are not a fly!! Only two to fix!
"ONLY" two you say, Jon? MY left eye is cloudy, misty and slightly out of focus. My left eye is a sloshing glass of water through which I can see nothing much. If I were a fly I would go nuts! But the hope is that all this can be fixed in due course, so roll on summer 2020 (which will also describe my eyesight at that time).
Can you share the link for the other MOSFET?
If you only use one MOSFET will not be enough?
Did you mean the other video, Auto Switch off, Luis? That used two discrete MOSFETS because we were switching potentially higher power. Have a look at video #123: ua-cam.com/video/g1rbIG2BO0U/v-deo.html
In THIS example we might have got away with one MOSFET (or even a BJT if it comes to that) by powering the MOSFET, or just the resistor divider, with output from an GPIO pin) but I was trying to adapt the auto switch off circuit but this time using a tiny IC. Food for thought!
Yayyyys!!!! He is back!!!!
I'm very pleased to have such enthusiasm, Michael, it warms the cockles of my Christmas heart!
welcome back
Thanks, Elie, nice to hear from you again.
why use a voltage divider, since the UNO is 5V, so take the voltage directly from the battery. Save the, arguably small, drainage with the voltage divider, and the UNO will handle up to 5 volts no prob. You surely have a good reason, I am not sure what it is.
..because he wants to set a simple trigger point at 3.68 V or so.... probably doing a simple compare to the reference voltage on A0?
@@whitefields5595 Good point, shorten the range that the ADC on the UNO needs to read, gives more accuracy. instead of 4.2-3.3/1023, one gets 3.4-3.3/1023. But is this accuracy needed? approx. 1 volt (4.2-3.3) divided by 1023 gives less than 1 mV, while the aim is to monitor 100mV range, hmmm.
@@ElieWar Well, if he didn't do it, folks like me and you would tell him he should have done! He probably does not want a true measure, but a comparator. If < 3.8V then do something. Go/No Go gauges are often more accurate and reliable than absolute measuring tools, especially if you have foreshortened the range in the first place
It is another method.
Others have probably explained this, Elie but the whole point of NOT using the 5v supply when running off a buck-boost device is that the voltage is not (particularly) stable. Maybe your voltage starts dropping a bit as the battery gets discharged. Using the stable, voltage-regulated 3v3 pin means this will remain steady regardless of the VCC voltage. On custom boards I would use a simple 3v3 zener diode. I should also state that if the VCC voltage changes then the AREF is going to compare against a changing voltage - thus making it inaccurate and potentially unreliable. I hope this helps and my bad I didn't really clarify this in the video.
Hi Ralph. How would i measure the voltage of evey single cell in a 7s battery? I can inly use ground once. I could measure the difference every step up in the stringi voltage using voltage deviders but i worry 7 different voltage dividers introduce lots of errors or devintions in the results i wonder if tgere is a better way?
Hmm... you might be able to use an ADS115 Analog to Digital converter for each of the battery cells. That way, each cell is measured accurately. Have a look at video #104 and see whether that helps at all.
I believe that some ADC modules have more than one channel, seem to remember one with 4 channels. 2 ADC modules might be able to monitor your 7 cells, guessing that you access each channel sequentially in code.
Hi Ralph, again..A quick question for you...Re: The Lipo holder/charger/psu...Does it charge via the USB socket, and, Does it continue to output 5V while it's charging?..Thanks...John..Bristol
You're referring to the 18650 holder that outputs 5v (and 3V3) and also via the USB socket, right, John? Yes, whilst charging (the LED is red) it still outputs power. The LED goes green when fully charged. You charge it not via the full-sized USB socket (that is output only, and controlled via a small on-off switch). The charging micro USB is on the main board, marked 'power' or something like that. To be honest, I just pop in another fully charged LiPO and charge that in a purpose-built, commerical charger rather than using this device, but that's just my preference!
Ralph S Bacon ..Many thanks for fast response again, Ralph... That's exactly what I wanted to know..Thank you..Looking at Bangood, the Lipo they advertise has a micro USB in it...Does that one work in the charger module ok?..J
The micro USB is the charging port on mine - works fine!
Is there a difference when using this on an esp32/esp8266 with the voltage source being 3.3~ ? Do I use different values for the resistors?
Calculate the resistors so that the monitored voltage does not exceed your ESP32's VCC and is around that 95% of that value (otherwise you will always read 1023 on a 10-bit analog input).
@@RalphBacon thanks for replying kind sir. Another question but out of topic. When using a dc-dc buck converter with the source being a battery, when the battery level goes low, does the voltage output from the buck converter also goes low?
Just read your blog Ralph, what a scary ordeal you have endured. Lets hope for light at the end of the tunnel.
There's plenty of light at the end of the tunnel, it's just very, very blurry at the moment but the consultant said I should start seeing stuff again in a week or two, can't wait! Thanks for posting, Greg, always good to hear from you.
Nice one
Thanks Yogesh, nice to hear from you!
I am surprised how you're getting that Serial Monitor Output, as you are Currently connected to External Battery to power up Arduino right ?.
Or Are you connected to computer USB port for Arduino to Power up ?
Then, what the External battery is doing just for Voltage divider ?☺️
I'm pretty sure I was running this on a battery to monitor its voltage with the potential divider. Remember it uses the internal AREF fixed voltage reference. Although this video is now well over a year old I remember that I was surprised at how easy it was to do this (but don't connect AREF to 3v3 until the sketch is loaded or the magic smoke will appear).
@@RalphBacon Thanks Ralph for the Reply.
I tried this with Sleep function and it works perfectly fine Thanks.
What i was confused initially and asked you the question was
how you connected External Battery to power up Arduino and connected Computer USB at the same time.?
Since you got that Serial Output in ur computer Monitor..right?
as you must have connected it through a computer USB.So, then Arduino will also automatically draw Power from.USB and not from Battery right ?.
Since it was not clear, i connected a OLED to display the Battery Voltage. Thanks 👍
No, I have a separate FTDI USB-to-Serial to connect to the Arduino (for the serial monitor output) but I do not connect the +5v, just RX (goes to TX on Arduino) and GND.
So know we can call you pudding man
Only for this week, Bob. Next week, well, wait and see!
hi Ralph Sir, I have a small suggestion: you can add to the title of the video the IC name so anybody searches in google for: "si4599" can reach yours 👍😀🎅
Great idea Ronen, I'll do that from now on.
@1m08s: OMG!! Your hand is so much larger than your head. ARGH!!!! ;-)!! Nice to see you; we hope that you're doing well.
I have mutant hands, that's for sure. And a few other body parts but that would be telling! Glad to be up and (sort of) around, thanks for your kind words, JH.
Elton John has got nothing on you!
Apart from the estimated $500million? 🤣
@@RalphBacon Yeah, its so wrong, engineers should be the ones making that kinda scratch!
Those glasses :D
You ain't seen nothing yet, Christian!
Well come back, loose the glasses humbug ;-)
Noooo! "Humbug, I say, Humbug. Down with Christmas." You can't mean that!?! The glasses are actually sunglasses (maybe for use in tropical, sunny climes?) and dim the glare of the monitors so they actually serve a purpose.
My honest children did not approve your glasses. They were very acceptant as I explained your reason. But please don’t get attached to them :-)
Wait until next week, they can score me like ice dancers, 4.9, 5.1 ... perfect 6.0?
That's not a lipo? right?
Same thing, just a different form factor.
@@superdau I think they have different "chemistry"
@@andymouse
They can have different chemistry, but so can cylindrical cells between them and pouch cells between them. The form factor is not what dictates the chemistry, what the manufacturer puts in them is. You can have the same chemistry in either. Have you ever seen something like IMR, INR, ICR, IFR, LMO, NMC, NCA, NCO, LCO or LFP written on cylindrical cells or in their datasheet? Those signify different chemistries. Pouch cells use the same chemistries, although they most often use the Lithium-cobalt-oxide chemistry (ICR/LCO), which is also the same that's often used in laptop battery 18650 cells.
@@superdau cheers!
My bad. I tend to use the word LiPO to encompass Li-Ion and even rechargeable Ni-Mh and the such like. The cylinder battery is Li-Ion but the smaller (flat) ones I was experimenting with (from drones) are, apparently, true LiPO. Not sure of the exact difference apart from the chemicals inside.
how you even see throu this glasses xD
They are sunglasses, it's true. But they help against the video lights.
30 minutes to say use a voltage divider and one of the analog inputs!
30 minutes to describe an issue raised by a subscriber, show a dual MOSFET circuit previously used and now adapted to prevent battery drain via the potential divider, with a couple of bench experiments with some LED readouts (who doesn't love an LED display?). So, yes, 30 (rather disjointed) minutes to say all that. Too long, didn't watch? Shame.
INA226
The INA226 is more a current sensing device, Javier, I've used a mains voltage version previously to detect when the washing machine switches off. But they are not cheap (not even from Asian markets) about $5 each.
If anyone wants to look, here's a link:
www.banggood.com/CJMCU-226-INA226-Voltage-Current-Power-Monitor-Alarm-Module-36V-Bi-Directional-I2C-For-Arduino-p-1101401.html?p=FQ040729393382015118&
I use the INA226 as a voltage sensor, 840k Ohm input impedance, infinite in standby mode, 36V max. and very accurate 16bits. I am just ordering 4 more at this moment. INA226 on ali is €1.20. I like it a lot!
@@javierpallalorden I am with Ralph on that one I wouldn't use a dedicated IC and add an I2c library just to read a voltage. 16bits is way over the top for this purpose (low battery warning). It also draws a Quiescent current which can be as high as 300-400ua! A nice IC but I wouldn't use it here.
@@andrewtoogood1429 True, I agree on that it wouldn't be a good idea to use it in this scenario (a resister divider is way cheaper and simpler, leaving out the mosfet switch....), but in general to measure a voltage on it's VBS pin with very high accuracy and high impedance......…..it is a very nice chip.
Worrying about the current drain of the voltage divider is like worrying about a prostitute's bad breath when having unprotected sex. The efficiency of the boost converter swamps the overall efficiency. While 95 to 98% efficient boost converters can be had, MOST use far cheaper and far less efficient boost converters. Read the datasheet charts, lads.
I think the efficiency of the one I used is about 85%, Kenn. But as I said, we have to be sensible when trying to squeeze the last ounce of power from our batteries. It would be better to have the dual MOSFET switch on the LiPO-powered buck-boost device (OOPS! Li-Ion, I meant, of course) thus removing all current drain.
The video would be more productive w out your picture in the video.
Close one eye and I disappear. It's true. Try it.
why use a voltage divider, since the UNO is 5V, so take the voltage directly from the battery. Save the, arguably small, drainage with the voltage divider, and the UNO will handle up to 5 volts no prob. You surely have a good reason, I am not sure what it is.
It is another method
Answered in your other post!