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. APM 8Mhz, 2 AA batteries and within 2 tot 3 days dead

APM 8Mhz, 2 AA batteries and within 2 tot 3 days dead

Scheduled Pinned Locked Moved Troubleshooting
7 Posts 4 Posters 1.4k 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.
  • Sander StolkS Offline
    Sander StolkS Offline
    Sander Stolk
    wrote on last edited by
    #1

    I've got this sensor with two magnetic sensors.
    1 for the mailbox and 1 for the front door.

    Both working on a interrupt base with sleeping mode on a Arduino Pro Mini 3.3v 8 Mhz.
    Powered by 2 AA batteries on the Vraw pin and GND.

    The unit works for aprox. 2 to 3 days and then the batteries are empty.
    The LED is cut and I believe the code is good. What else can I do to last this device longer then 2 to 3 days? I've read the whole battery powered modules but I have no idea's so far.

    Maybe there is something wrong in my code?

    #include <SPI.h>
    #include <MySensor.h>
    #include <avr/sleep.h>
    #include <Bounce2.h>
    
    #define BUTTON_PIN_1 2 // Voordeur
    #define BUTTON_PIN_2 3 // Brievenbus
    #define INTERRUPT 0
    #define INTERRUPT 1
    
    MySensor gw;
    MyMessage msgVD(BUTTON_PIN_1,V_TRIPPED);
    MyMessage msgBB(BUTTON_PIN_2,V_TRIPPED);
    
    Bounce debouncerVD = Bounce();
    Bounce debouncerBB = Bounce(); 
    int oldValueVD=-1;
    int oldValueBB=-1;
    
    void setup()
    {
      gw.begin(NULL,6,false);
      gw.sendSketchInfo("Voordeur_Brievenbus", "1.1");
      
      pinMode(BUTTON_PIN_1,INPUT_PULLUP);
      pinMode(BUTTON_PIN_2,INPUT_PULLUP);
      gw.present(BUTTON_PIN_1,S_DOOR);
      gw.present(BUTTON_PIN_2,S_DOOR);
      debouncerVD.attach(BUTTON_PIN_1);
      debouncerVD.interval(5);
      debouncerBB.attach(BUTTON_PIN_2);
      debouncerBB.interval(5);
      Serial.println("Setup gerund");
    }
    
    void loop()
    {
      debouncerVD.update();
      // Get the update value
      int valueVD = debouncerVD.read();
     
      if (valueVD != oldValueVD) {
         // Send in the new value
         gw.send(msgVD.set(valueVD==HIGH ? 1 : 0));
         oldValueVD = valueVD;
         enterSleep();
      }
    
      debouncerBB.update();
      // Get the update value
      int valueBB = debouncerBB.read();
     
      if (valueBB != oldValueBB) {
         // Send in the new value
         gw.send(msgBB.set(valueBB==HIGH ? 1 : 0));
         oldValueBB = valueBB;
         enterSleep();
      }
    }
    
    void Voordeur()
    {
        Serial.println("VD Loop gerund");
    }
    
    void Brievenbus()
    {
        Serial.println("BB Loop gerund");
    }
    
    void enterSleep(void)
    {
      attachInterrupt (0,Voordeur,CHANGE);
      attachInterrupt (1,Brievenbus,CHANGE);
      delay(100);
      Serial.println("Entering sleepmode...");
      delay(100);
      set_sleep_mode(SLEEP_MODE_PWR_DOWN);
      sleep_enable();
      sleep_mode();
      /* The program will continue from here. */
      /* First thing to do is disable sleep. */
      sleep_disable(); 
      Serial.println("Recovering from sleepmode...");
    }```
    1 Reply Last reply
    0
    • sundberg84S Offline
      sundberg84S Offline
      sundberg84
      Hardware Contributor
      wrote on last edited by sundberg84
      #2

      Hi!
      Are you running a 5 or 3.3v arduino? Best for battery based sensors are 3.3v and run the 2xAA bat to VCC and remove voltage regulator to save power. Radio can be powered directly from the battery (Down to 0.9v i think). Then you can use a booster to maintain 3.3v to arduino and/or sensors.

      Removing the volt. regulator did a big difference for me.

      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
      • Sander StolkS Offline
        Sander StolkS Offline
        Sander Stolk
        wrote on last edited by
        #3

        I'm running a 3.3v APM. I'll check if I've cutted the voltage regulator or not... I'm not sure anymore.

        1 Reply Last reply
        0
        • sundberg84S Offline
          sundberg84S Offline
          sundberg84
          Hardware Contributor
          wrote on last edited by
          #4

          From learning, ill suggest remove (desolder). Atleast I think thats much easier... i cut two volt. regulators and destroyed stuff nearby...

          Also if you have removed the volt. regulator, you would not be able to run it from RAW so you are using it.

          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
          • Sander StolkS Offline
            Sander StolkS Offline
            Sander Stolk
            wrote on last edited by
            #5

            I've read that somewhere. I will check soon and post my findings.

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

              The internal pullups will consume 3.3/20000=0.165mA each. That's not a lot but I would switch to external pullups of 1Mohm or more.

              Is there a reason why you're not using the MySensors sleep?

              Will the avr sleep turn off the radio?

              1 Reply Last reply
              0
              • hekH Offline
                hekH Offline
                hek
                Admin
                wrote on last edited by
                #7

                I don't think Bounce2 works when you're sleeping.

                Why not use a simple interrupt to trigger wake up? Like in this example:
                https://github.com/mysensors/Arduino/blob/master/libraries/MySensors/examples/BinarySwitchSleepSensor/BinarySwitchSleepSensor.ino

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


                20

                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