Read battery voltage without resistors.



  • You can read the battery voltage on arduino without any voltage dividers using a trick. It is described here:
    http://provideyourown.com/2012/secret-arduino-voltmeter-measure-battery-voltage/
    The trick is to read the value of the internal 1.1V reference against the battery voltage. This is not supported by the analogRead(); command


  • Hardware Contributor

    Hi!

    Its a great tool, but if you are reading the battery voltage before a booster/step up converter you need the divider or else you will only get the booster (3.3v) as battery voltage untill it goes below what the booster can handle and everything dies.



  • Thats right. But with the same principle you can also read an external voltage that is fed into the Aref-pin. Just read the value of the internal 1.1V reference against the external reference.
    Sadly the Aref is not available on the pro mini boards. With some soldering skills it could be obtained directly from the chip.


  • Hardware Contributor

    Didnt know that (probably since om 95% working with pro mini then) but appreciate to learn that.



  • Hi @fleinze

    does that mean this would work fine with an Arduino Nano supplying both the 5V and 3.3V output? And if so, how hard would it be to add the code? So far all my nodes are Nano's, so i'm hoping i'm ok.



  • @fleinze said:

    Thats right. But with the same principle you can also read an external voltage that is fed into the Aref-pin. Just read the value of the internal 1.1V reference against the external reference.
    Sadly the Aref is not available on the pro mini boards. With some soldering skills it could be obtained directly from the chip.

    I'm not 100% sure, but I guess it should work for Pro Minis, too? I'm going to give it a try and maybe implement it, to MySensors Dev...


  • Mod

    as for the "secret" reading, it is already implemented in the MySensors library (at least for ATMega328): https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/core/MyHwATMega328.cpp#L135

    However, it can only be accessed from within the library. It was available briefly from Thu Dec 17 15:25:10 2015 +0100 to Fri Dec 18 12:14:02 2015 +0100. Perhaps @tekka has some input?


  • Contest Winner

    What voltage levels would be acceptable on Aref in that case? Suppose I have a board that has a 12V supply which is regulated to 3.3V.
    I have designed a solution so that measurement is cpu triggered. That way, when not measuring, voltage divider is disconnected.


  • Mod

    From my understanding of the datasheet (specifically, Table 29-15. ADC Characteristics) max Vref is AVcc and AVcc may not be higher than Vcc+0.3V.


  • Contest Winner

    Sounds no good then. It would not even survive a 5V regulation to 3.3V. Or at least not support it.


  • Mod

    @fleinze @mfalkvidd I wrote a nice library supporting vcc readout without resistors. You can read all about it here (don't mention the topic name 😆 )



  • @Yveaux I must say that I like your library it is easy to use and it is on all my battery driven sensors. Thank for this great library.


  • Mod

    @Yveaux just at the function implemented in the MySensors library, your library requires that the sensor is powered directly from battery, not trough the regulator. The discussion started there but has partly moved towards being able to measure Arduinos powered through the regulator.


  • Mod

    @mfalkvidd said:

    The discussion started there but has partly moved towards being able to measure Arduinos powered through the regulator.

    Yeah, that's why I also referred to the original thread of vcc measurement. The same thing happened over there and it could be interesting for you guys to read.


  • Contest Winner

    Not to be pedantic but strictly speaking, the post topic says nothing about this not allowing regulators (and if I recall the other post did not as well, but topic changed during the course of discussion :)). Since the technical level of forum members vary, it is also important to emphasize limitations in a design. It does not necessarily mean the design is bad. I use this feature myself. And I do apologize if my earlier post seemed dismissive of the solution. It is excellent for situations where the arduino is directly battery powered.



  • I didn't realize that this has already been discussed. Just thought this is a very good option - at least when powering directly from battery. Maybe it could be mentioned in the battery powering section on the mysensors webpage.


  • Contest Winner

    Yes. There also exist a function for it in development branch in the MyHwxxx implementations. But it does not seem to be available for use so I am guessing it is a feature in developing stages. I think the SenseBender sketch also makes use of it since the SenseBender is a hw that can capitalize on such a feature. I also have it in my sketch for my MySensorsNode board but I have not published a finished sketch. But on the openhardware.io entry for it, there is a codebender sketch that can be examined (very much work in progress).


Log in to reply
 

Suggested Topics

20
Online

11.4k
Users

11.1k
Topics

112.7k
Posts