Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Development
  3. Read battery voltage without resistors.

Read battery voltage without resistors.

Scheduled Pinned Locked Moved Development
17 Posts 8 Posters 7.3k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • sundberg84S Offline
    sundberg84S Offline
    sundberg84
    Hardware Contributor
    wrote on last edited by
    #4

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

    Controller: Proxmox VM - Home Assistant
    MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
    MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
    RFLink GW - Arduino Mega + RFLink Shield, 433mhz

    1 Reply Last reply
    0
    • D Offline
      D Offline
      drock1985
      wrote on last edited by
      #5

      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.

      My Projects
      2 Door Chime Sensor
      Washing Machine Monitor

      1 Reply Last reply
      0
      • F fleinze

        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.

        R Offline
        R Offline
        Rasenheizung
        wrote on last edited by
        #6

        @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...

        1 Reply Last reply
        0
        • mfalkviddM Offline
          mfalkviddM Offline
          mfalkvidd
          Mod
          wrote on last edited by
          #7

          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?

          1 Reply Last reply
          0
          • AnticimexA Offline
            AnticimexA Offline
            Anticimex
            Contest Winner
            wrote on last edited by
            #8

            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.

            Do you feel secure today? No? Start requiring some signatures and feel better tomorrow ;)

            1 Reply Last reply
            0
            • mfalkviddM Offline
              mfalkviddM Offline
              mfalkvidd
              Mod
              wrote on last edited by
              #9

              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.

              1 Reply Last reply
              0
              • AnticimexA Offline
                AnticimexA Offline
                Anticimex
                Contest Winner
                wrote on last edited by
                #10

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

                Do you feel secure today? No? Start requiring some signatures and feel better tomorrow ;)

                1 Reply Last reply
                0
                • F fleinze

                  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

                  YveauxY Offline
                  YveauxY Offline
                  Yveaux
                  Mod
                  wrote on last edited by
                  #11

                  @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 :laughing: )

                  http://yveaux.blogspot.nl

                  1 Reply Last reply
                  1
                  • FrancoisF Offline
                    FrancoisF Offline
                    Francois
                    wrote on last edited by
                    #12

                    @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.

                    1 Reply Last reply
                    0
                    • mfalkviddM Offline
                      mfalkviddM Offline
                      mfalkvidd
                      Mod
                      wrote on last edited by
                      #13

                      @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.

                      1 Reply Last reply
                      0
                      • YveauxY Offline
                        YveauxY Offline
                        Yveaux
                        Mod
                        wrote on last edited by
                        #14

                        @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.

                        http://yveaux.blogspot.nl

                        1 Reply Last reply
                        0
                        • AnticimexA Offline
                          AnticimexA Offline
                          Anticimex
                          Contest Winner
                          wrote on last edited by
                          #15

                          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.

                          Do you feel secure today? No? Start requiring some signatures and feel better tomorrow ;)

                          1 Reply Last reply
                          0
                          • F Offline
                            F Offline
                            fleinze
                            wrote on last edited by
                            #16

                            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.

                            1 Reply Last reply
                            0
                            • AnticimexA Offline
                              AnticimexA Offline
                              Anticimex
                              Contest Winner
                              wrote on last edited by
                              #17

                              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).

                              Do you feel secure today? No? Start requiring some signatures and feel better tomorrow ;)

                              1 Reply Last reply
                              0
                              Reply
                              • Reply as topic
                              Log in to reply
                              • Oldest to Newest
                              • Newest to Oldest
                              • Most Votes


                              15

                              Online

                              11.7k

                              Users

                              11.2k

                              Topics

                              113.1k

                              Posts


                              Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                              • Login

                              • Don't have an account? Register

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • MySensors
                              • OpenHardware.io
                              • Categories
                              • Recent
                              • Tags
                              • Popular