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. Troubleshooting
  3. Sleep mode/Read Vcc issue

Sleep mode/Read Vcc issue

Scheduled Pinned Locked Moved Troubleshooting
12 Posts 5 Posters 3.9k Views 5 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.
  • E Offline
    E Offline
    engy
    wrote on last edited by
    #3

    I'm not sure if it's related to DHT22, because sleep mode works fine when Vcc function is commented in the sketch.

    1 Reply Last reply
    0
    • mfalkviddM Online
      mfalkviddM Online
      mfalkvidd
      Mod
      wrote on last edited by
      #4

      Maybe you could try to move sendBatteryReport(); from loop to setup and see if it makes a difference if vcc is only called once.

      1 Reply Last reply
      0
      • F Offline
        F Offline
        flopp
        wrote on last edited by flopp
        #5

        I dont use vcc.h i use this code at the bottom of my sketch

        long readVcc() {
        Serial.println("readVcc");
        // Read 1.1V reference against AVcc
        ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
        delay(2); // Wait for Vref to settle
        ADCSRA |= _BV(ADSC); // Convert
        while (bit_is_set(ADCSRA,ADSC));
        result = ADCL;
        result |= ADCH<<8;
        result = 1126400L / result; // Back-calculate AVcc in mV
        //return result;
        //gw.begin(incomingMessage,node_id, false)
        batteryPcnt = (result - 3300) * 0.111111;
        batteryVolt = result/1000.000;
        gw.sendBatteryLevel(batteryPcnt);
        gw.send(battMsg.set(batteryVolt, 3));
        /*Serial.print("battery volt:");
        Serial.println(batteryVolt, 3);
        Serial.print("battery percent:");
        Serial.println(batteryPcnt);
        */
        }
        

        how does you vcc.h look like

        M 1 Reply Last reply
        0
        • F flopp

          I dont use vcc.h i use this code at the bottom of my sketch

          long readVcc() {
          Serial.println("readVcc");
          // Read 1.1V reference against AVcc
          ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
          delay(2); // Wait for Vref to settle
          ADCSRA |= _BV(ADSC); // Convert
          while (bit_is_set(ADCSRA,ADSC));
          result = ADCL;
          result |= ADCH<<8;
          result = 1126400L / result; // Back-calculate AVcc in mV
          //return result;
          //gw.begin(incomingMessage,node_id, false)
          batteryPcnt = (result - 3300) * 0.111111;
          batteryVolt = result/1000.000;
          gw.sendBatteryLevel(batteryPcnt);
          gw.send(battMsg.set(batteryVolt, 3));
          /*Serial.print("battery volt:");
          Serial.println(batteryVolt, 3);
          Serial.print("battery percent:");
          Serial.println(batteryPcnt);
          */
          }
          

          how does you vcc.h look like

          M Offline
          M Offline
          m26872
          Hardware Contributor
          wrote on last edited by
          #6

          @flopp
          You shouldn't need your own readVcc() code like that since you're including the Vcc library in the beginning of the sketch. Make sure you have the vcc-lib in your Arduino folder:
          https://github.com/Yveaux/Arduino_Vcc

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

            If you use the readVcc function in flopp's sketch, remove gw.begin(incomingMessage, NODE_ID, false);
            Calling gw.begin several times seems strange.

            F 1 Reply Last reply
            0
            • mfalkviddM mfalkvidd

              If you use the readVcc function in flopp's sketch, remove gw.begin(incomingMessage, NODE_ID, false);
              Calling gw.begin several times seems strange.

              F Offline
              F Offline
              flopp
              wrote on last edited by
              #8

              @mfalkvidd
              Sorry that line I don't use anymore. Code must be copied from an old sketch where I was using an LDO that I disabled and when power was back I have to run gw.begin again otherwise I could send anything.
              I have now comment that row out.
              Thanks for noticing

              1 Reply Last reply
              0
              • M m26872

                @flopp
                You shouldn't need your own readVcc() code like that since you're including the Vcc library in the beginning of the sketch. Make sure you have the vcc-lib in your Arduino folder:
                https://github.com/Yveaux/Arduino_Vcc

                F Offline
                F Offline
                flopp
                wrote on last edited by
                #9

                @m26872
                I don't use vcc.h I like to have it in the bottom of the sketch.
                Is it better to have it in a seperate file?
                Except that it looks cleaner?

                1 Reply Last reply
                0
                • mfalkviddM Online
                  mfalkviddM Online
                  mfalkvidd
                  Mod
                  wrote on last edited by mfalkvidd
                  #10

                  @engy: just a note: the sketch you posted has #include <Vcc.h>

                  You should either include Vcc.h OR include readVcc() in your sketch. Not both.

                  F 1 Reply Last reply
                  0
                  • mfalkviddM mfalkvidd

                    @engy: just a note: the sketch you posted has #include <Vcc.h>

                    You should either include Vcc.h OR include readVcc() in your sketch. Not both.

                    F Offline
                    F Offline
                    flopp
                    wrote on last edited by
                    #11
                    This post is deleted!
                    1 Reply Last reply
                    0
                    • E Offline
                      E Offline
                      engy
                      wrote on last edited by
                      #12

                      The problem was faulty NRF24... another batch :(
                      Just powered sensor in sleep mode is consuming as expected - a few uA.
                      But later, after while, power consumption is increasing.
                      Commenting Vcc was just coincidence.

                      Received new NRFs batch from mysensors shop, and all the problems gone.
                      Thanks!

                      1 Reply Last reply
                      1

                      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                      With your input, this post could be even better 💗

                      Register Login
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      20

                      Online

                      12.1k

                      Users

                      11.2k

                      Topics

                      113.4k

                      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