TUTORIAL: How to Measure / Read Voltages Into Arduino - (Part 1/3 Voltages Less than 5v)

Поделиться
HTML-код
  • Опубликовано: 24 ноя 2024

Комментарии •

  • @NemonicanatLarge
    @NemonicanatLarge 3 года назад +3

    Thank you very much....I've gone thru over a thousand code / hardware videos and I must say i anm extremely impressed. You explained that circuit perfectly. All the other sites were losy to bad but yours is good. I will be looking at your other videos as time permits. This one is going to get me by writers block and back to being productive again. Good timing too because my ordered Nano and display just came in last night. So let's go to work.

  • @Estudio322
    @Estudio322 4 года назад +2

    Great video, i thought the same about the resistor in series, because the lithium ion cell that im using is actually powering the arduino itself, thank you very much!

  • @Gallardo6669
    @Gallardo6669 3 года назад +1

    FINALLY!!!!! SOMEONE WHO ACTUALLY CAN REALLY EXPLAIN THE PROBLEM AND THE CODE STEP BY STEP! T H A N K. Y O U !!!

    • @AntonyCartwright
      @AntonyCartwright  3 года назад

      Thanks!

    • @Gallardo6669
      @Gallardo6669 3 года назад +1

      @@AntonyCartwright could you make a video where you actually use the same battery or two in series to power the Arduino? I read if doing wrong, power can be backfed into a pin and through the rest of the chip destroying it. Thx.

    • @AntonyCartwright
      @AntonyCartwright  3 года назад

      @@Gallardo6669 Hi, unfortunately I can't make a video on that at the moment, however, I can answer it for you. The battery could wreck the Arduino if you fed it directly into a random pin, however, the VCC/RAW pins are exempt from this. These pins are designed to handle the current. If you wanted to power the 5v arduino using this 4.2v cell, it would work if you fed the VCC pin with it. If you are trying to power a 3.3v arduino with this cell, then use the RAW pin. The raw pin has a regulator behind it which makes higher voltage safer. Antony...

    • @Gallardo6669
      @Gallardo6669 3 года назад +1

      @@AntonyCartwright thx! I plan on using 2 18650 in series to power an 5volt Arduino uno. As the voltage goes down over some hours, the voltage regulator on the board would still get something over 6,4 volt in and it still regulates itself to 5v for the board.
      So far so good. But, can I now use a voltage divider to bring the 6,4 battery voltage down to use it for an analog pin? On top of that, to be safe, I could go off the voltage devider and go through a 10kohm resistor before going into the analog pin? I don't know if it's needed but someone mentioned it for a similar project, trying to prevent a too high current across the atmega...?

    • @AntonyCartwright
      @AntonyCartwright  3 года назад

      @@Gallardo6669 The 18650s have a capacity of sometimes near 3000mah and the Uno uses around 50ma, so your battery pack should probably last 60hrs. The cells shouldn't be discharged to less than 3.6v ideally. Both together would give you 7.2vnom, or 8.4vmax. That's ok for the raw pin but not the vcc pin.
      If you want to find the battery's voltage, then yes, you'd use a voltage divider. This splits the voltage down to an Arduino-friendly voltage for you so that you can read it. You can put the anode to the raw pin and the start of the divider. The battery would be 8.4vmax, so you could use a 50:50 divider to keep it simple. If your battery was fully charged, the Arduino would read in 4.2v (half) on the ADC. To make this happen, you could use any resistors which have the same value. You could theoretically use 1ohm and 1ohm, and the divider would work! However, in reality, you'd never do that because that's way too low resistance for what you're trying to d -, the battery would love to shoot electric through that circuit, the wires would get extremely hot, the divider itself would draw approx 4 amps and it would burn through anything in its way to ground! (Maybe burn through your computer's USB/motherboard or burn through the Arduino to get back to the negative of the battery. It would drain your battery pack in about 40 minutes! If you make the resistors 10k, then the divider would draw approx 0.4ma which is much, much safer! You could even use 20k resistors but the signal may be too weak. Basically, whatever you connect to the pins, make sure it stays below 20ma and 40ma in total for all pins... Oh, always remember: electricity always takes the path of least resistance and it has no emotions. 🤣🤣🤣

  • @adjgamer
    @adjgamer 3 года назад +5

    Super simple, it's already working for me. My cheap aliexpress arduino uno had a different reference voltage as well. I also mapped my input to a different scale to output it onto an 8segment display to use as a tachometer for my car with the map() function. It will be a fun project and you did a great job explaining the adc of the arduino. I was also getting some weird values with no voltage applied but with 0v applied from my power supply it showed a 0v output.

    • @gaurabpokharel6373
      @gaurabpokharel6373 2 года назад

      How , I also want to make tachometer so landed here , Can you please share what component used and code ?

    • @mookfaru835
      @mookfaru835 2 года назад

      I'm getting weird values too when no voltage is applied. with 2 arduinos.

  • @benediktschluter7313
    @benediktschluter7313 5 лет назад +3

    Thx a lot for the hint that the reference voltage may not be exactly 5V. I just measured mine and found out that it is 4.99V when the Arduino is connected to the power supply and only about 4.86V when powered by usb. Of course I was only using USB and man I was wondering why the measurements were so off! :) Thx again!

  • @satreaaji
    @satreaaji 3 года назад +2

    the difference voltage reader is because you add resistor on (+), to limit current, better to add resistor on (-)

  • @mohfa1806
    @mohfa1806 9 месяцев назад

    Hello ,
    Thank you for your great videos...iam new to arduino but learning...i have question please :
    The cell is connected in series with the resistor and then the resistor is connected to A0 and A0 is connected to ground , so how can the A0 pin reads the voltage across the cell ? .
    Thank you in advance

  • @vedatorpeta
    @vedatorpeta 4 года назад +1

    great tutorial, thanks, I am going to use it in my mini arduino project :) There will be GPS, GSM, temperature, pressure and humidity sensor and other things. But It will be in the 55x37x20mm box :D

  • @Revision369
    @Revision369 5 лет назад

    brillianttttt..... this code is the most easy and straightforward that ive found , cheers

  • @BonJambo
    @BonJambo 3 года назад +1

    How about using AREF pin for more generic solution?

  • @caseylocke4474
    @caseylocke4474 5 лет назад +1

    So this is a super helpful video and thank you very much for it! One question I do have...in the serial monitor, you were getting the voltage reading only every OTHER number. There was another much smaller number that alternated with it. What is that and why?

  • @kurtguevarra9262
    @kurtguevarra9262 5 лет назад +2

    What does the low reading (800 and 300) every other reading mean?

  • @DesertVox
    @DesertVox Год назад

    THERE is an internal reference of 1V that can be used through code.

  • @user-mt3hj8td4c
    @user-mt3hj8td4c 4 года назад +2

    Thank you, but I do not understand why doesn't the resistor you added decrease the neasured voltage?

    • @soret
      @soret 3 года назад

      Same question here!

    • @JasonGlisson
      @JasonGlisson Год назад +1

      Resistors restrict current, not voltage.

  • @squidben5780
    @squidben5780 2 года назад

    Insstead of calculating a value, cant you get the value from the 5v pin on the arduino and use it in the calculation ???

  • @JohnSmith-xn3fr
    @JohnSmith-xn3fr 6 лет назад +1

    Why do you think a 10k resistor in series with the PSU (battery) is needed ?
    The ADC has an input impedance (resistance) in the range of MegaOhms.
    How can the ADC draw too much of a current ?

    • @AntonyCartwright
      @AntonyCartwright  6 лет назад

      John Smith Hi Mr Smith, I used to think that too, but without the resistors, the cell can power the arduino! Try it if you like... Take the usb port out but have a few pins from arduino to the cell. The cell will power the arduino! :)

  • @ivanpiineda
    @ivanpiineda 3 года назад

    Any tutoríal, how to measure, diode voltage drop?

  • @codewithmarley
    @codewithmarley 3 года назад

    Thank you a lot! Do you also know how chose the amount of amps I am outputting? @Antony Cartwright

  • @robertdbettis
    @robertdbettis 4 года назад

    Could this work for reading power generated with a simple hand crank generator?

  • @maheshcherlapelly
    @maheshcherlapelly 4 года назад

    Am using stm32 so I need max 3.3v analog voltage & my step down transformer output voltage is 0 to 24V can you please suggest me resisters number to use.

  • @mariaantoniavogelerbalcaza8729
    @mariaantoniavogelerbalcaza8729 3 года назад

    Thank you for this! Do you know how I could record weaker electrical signals? Up to 150 mV with a 0.1mV step? Any help is appreciated!!

    • @arhamupadhye5157
      @arhamupadhye5157 2 года назад

      You should certainly use a high gain amplifier. I would recommend using LM358 high gain amplifier module for millivolts. Hope this helps!

  • @BasilHerb
    @BasilHerb 4 года назад

    Thanks for the Tutorial.
    I do have a question about some of this.
    The Delay messes with RC Cars because of the control Delay, is it possible to remove the Delay? Will that mess anything up?
    Or rather, is it possible to exclude this from the loop and make it it's own Void Function?
    Thanks for you time!

    • @mydarkguy
      @mydarkguy 4 года назад +2

      I believe the delay's purpose is just for looking at the values, if there was no delay the numbers would flood in too quickly.

    • @AntonyCartwright
      @AntonyCartwright  3 года назад

      @@mydarkguy That's right. Sometimes, the Arduino can't cope of you try to do things too fast. The delay timing isn't necessarily thought through though. Maybe 1ms is enough - maybe too much. Maybe not...

  • @ALLINONE-ec9jq
    @ALLINONE-ec9jq 2 года назад

    i want make voltage current monitor for solar charger on mobile can you wrte a code for me?

  • @NemonicanatLarge
    @NemonicanatLarge 3 года назад

    BTW wouldn't changing the resistors to 100 Megs be better as we're going to be watching 24/7 and we don't want to drain the battery and "defeat the purpose" of which they exist

  • @blackz06
    @blackz06 4 года назад

    Why is it fluctuating 10s of millivolts?

  • @ifell3
    @ifell3 2 года назад

    Awesome!

  • @kevinmac5798
    @kevinmac5798 6 лет назад

    Will this work on the ESP 8266 and ESP 32? I have a few Battery powered temperature and humidity sensors that i would like to monitor the battery voltage.

    • @AntonyCartwright
      @AntonyCartwright  6 лет назад

      Kevin Mac it will work the same way but you need to check the adc voltage of the modules...

  • @the4hunters
    @the4hunters 4 года назад

    Brilliant

  • @idvfpv
    @idvfpv 4 года назад

    do i need to use float, i want the program to be on a attiny85 and it has not that much memory...

    • @jonasschindzielorz
      @jonasschindzielorz 4 года назад

      the counts are integers
      the voltages probably need to be floats though

  • @RoyAndrews82
    @RoyAndrews82 3 года назад

    Hi Anthony, can you please tell me why the readings change constantly (821, 823, 823, 825, etc.) without any user interaction? Is it 823 or is it 821, 823, 825, 824, etc ? My digital Multimeter, car Speedometer, microwave clock/timer doesn't fluxuate, why does the reading change so much? Thanks.
    ruclips.net/video/lec7kPv3VS8/видео.html

  • @hrperformance
    @hrperformance 3 года назад

    thank you!

  • @nicholaslabrecque
    @nicholaslabrecque 4 года назад

    oooor power through the vcc pin and read it directly from that

  • @yousaftoki1599
    @yousaftoki1599 2 года назад

    I like it...

  • @hacktheplanetraktor325
    @hacktheplanetraktor325 4 года назад

    Any voltage ?, Can I try with 100v Ac ? 😜

  • @ClownWhisper
    @ClownWhisper 2 года назад

    a battery is indeed a device

  • @CARRY_ON1909
    @CARRY_ON1909 6 лет назад +2

    Vitórias amigo

  • @korishan
    @korishan 6 лет назад +2

    Awww, you didn't include the auto-adjust reference code 😜

    • @AntonyCartwright
      @AntonyCartwright  6 лет назад

      Is that with the internal reference?

    • @korishan
      @korishan 6 лет назад

      Yeah. It auto compensates for what ever the internal voltage is. The nice thing is you don't have to wire anything up to it, it can just do it.
      The only issue really is, you need to do a few blank readAnalog()'s afterwards to make sure it switches over before you use the value. At least, that's what the Arduino Dev site said.
      If you want to maintain your accuracy throughout the whole testing phase (referring back to your batter tester), you just put the call at the top of the loop() to update the global variable. If the value changed, then your calculations will be compensated for. This is nice considering, as you mentioned in this video, that the internal reference can fluctuate a little bit.

    • @AntonyCartwright
      @AntonyCartwright  6 лет назад

      Korishan ok, maybe I'll add it to the capacity checker. :)

  • @roamingcelt
    @roamingcelt 2 года назад

    Save all the math and make your code quicker and cleaner.
    float mV = counts / 5f; // change 5f to actual refV
    One line of code instead of 4.

  • @mikerilling2745
    @mikerilling2745 Год назад +1

    You measure voltages in Arduino with a volt meter
    there I just save you 17 minutes

  • @fellpower
    @fellpower 4 года назад

    Hey Antony. U need really really a proper microphone. Its sooo annoying, that i cant hear u in one video - and if im watching a playlist - in another video u are toooo loud. thats not sooo cool.
    And the most important part is, that u dont said, that the measuring of voltages with arduino, depends on the input voltage. so if i change the input voltage of the arduino - the measurement is not correct.