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. General Discussion
  3. 6/8 Buttons battery remote node

6/8 Buttons battery remote node

Scheduled Pinned Locked Moved General Discussion
53 Posts 7 Posters 7.0k Views 8 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.
  • NeverDieN Offline
    NeverDieN Offline
    NeverDie
    Hero Member
    wrote on last edited by NeverDie
    #5

    I wonder if this would do what Gohan has in mind?
    https://www.aliexpress.com/item/Button-Keypad-3x4-module/32530917534.html?spm=2114.10010108.0.0.2d82a4e4IC03UP&traffic_analysisId=recommend_2049_1_83259_iswiall&scm=1007.12908.83259.0&pvid=19937069-0349-4cc8-8b2a-ca440c3537da&tpp=1
    Looks as though it needs just one analog pin to read the voltage and thereby infer which button was pressed. With luck, maybe all the voltages would be high enough to trigger the interrupt.

    1 Reply Last reply
    0
    • NeverDieN Offline
      NeverDieN Offline
      NeverDie
      Hero Member
      wrote on last edited by NeverDie
      #6

      Here it is notionally for 4 buttons:
      0_1517019196870_keypad.jpg
      It's a voltage divider. Structured like this, it could trigger the IRQ pin when a button is pushed, and the analog pin could read the voltage to determine which button it was.

      NeverDieN 1 Reply Last reply
      0
      • NeverDieN Offline
        NeverDieN Offline
        NeverDie
        Hero Member
        wrote on last edited by
        #7

        By clever resistor selection, you can even shave a few resistors off the design:
        alt text

        gohanG 1 Reply Last reply
        0
        • NeverDieN NeverDie

          By clever resistor selection, you can even shave a few resistors off the design:
          alt text

          gohanG Offline
          gohanG Offline
          gohan
          Mod
          wrote on last edited by
          #8

          @neverdie I know, it is similar to the arduino examples for the classic flat numeric keypad, the problem would be how to trigger the interrupt to wake the mcu.

          NeverDieN 1 Reply Last reply
          0
          • gohanG gohan

            @neverdie I know, it is similar to the arduino examples for the classic flat numeric keypad, the problem would be how to trigger the interrupt to wake the mcu.

            NeverDieN Offline
            NeverDieN Offline
            NeverDie
            Hero Member
            wrote on last edited by NeverDie
            #9

            @gohan said in 6/8 Buttons battery remote node:

            the problem would be how to trigger the interrupt to wake the mcu.

            What problem? You trigger on the rising edge.

            The other benefit is that it consumes no power unless a button is pushed.

            1 Reply Last reply
            0
            • gohanG Offline
              gohanG Offline
              gohan
              Mod
              wrote on last edited by
              #10

              On analog pin?

              1 Reply Last reply
              0
              • NeverDieN Offline
                NeverDieN Offline
                NeverDie
                Hero Member
                wrote on last edited by
                #11

                Well, on an arduino, you could wire it to both the IRQ pin and an analog pin (see above schematic). On an nRF52832, you'd need only one pin.

                dbemowskD 1 Reply Last reply
                0
                • gohanG Offline
                  gohanG Offline
                  gohan
                  Mod
                  wrote on last edited by
                  #12

                  Would it still be able to trigger interrupt even with all those resistors?

                  NeverDieN 1 Reply Last reply
                  0
                  • gohanG gohan

                    Would it still be able to trigger interrupt even with all those resistors?

                    NeverDieN Offline
                    NeverDieN Offline
                    NeverDie
                    Hero Member
                    wrote on last edited by NeverDie
                    #13

                    @gohan said in 6/8 Buttons battery remote node:

                    Would it still be able to trigger interrupt even with all those resistors?

                    Try it. I don't see a problem with it, but if it were a problem, you'd just reduce all the resistor values proportionately.

                    1 Reply Last reply
                    0
                    • NeverDieN Offline
                      NeverDieN Offline
                      NeverDie
                      Hero Member
                      wrote on last edited by
                      #14

                      The nice thing is that since you'd be measuring the voltage relative to the voltage powering your arduino/mcu, even if the battery voltage were to decrease, you'd still get the correct value for the button pressed.

                      1 Reply Last reply
                      0
                      • NeverDieN NeverDie

                        Well, on an arduino, you could wire it to both the IRQ pin and an analog pin (see above schematic). On an nRF52832, you'd need only one pin.

                        dbemowskD Offline
                        dbemowskD Offline
                        dbemowsk
                        wrote on last edited by
                        #15

                        @neverdie said in 6/8 Buttons battery remote node:

                        On an nRF52832, you'd need only one pin.

                        Slightly off topic question. On the nRF5's, can any pin act as an interrupt?

                        Vera Plus running UI7 with MySensors, Sonoffs and 1-Wire devices
                        Visit my website for more Bits, Bytes and Ramblings from me: http://dan.bemowski.info/

                        NeverDieN 1 Reply Last reply
                        0
                        • dbemowskD dbemowsk

                          @neverdie said in 6/8 Buttons battery remote node:

                          On an nRF52832, you'd need only one pin.

                          Slightly off topic question. On the nRF5's, can any pin act as an interrupt?

                          NeverDieN Offline
                          NeverDieN Offline
                          NeverDie
                          Hero Member
                          wrote on last edited by NeverDie
                          #16

                          @dbemowsk said in 6/8 Buttons battery remote node:

                          @neverdie said in 6/8 Buttons battery remote node:

                          On an nRF52832, you'd need only one pin.

                          Slightly off topic question. On the nRF5's, can any pin act as an interrupt?

                          IIRC, any GPIO can. I can't think of any exceptions. So, notionally, you would wake from the interrupt pin, then change it to be an analog pin and read the voltage from that.

                          1 Reply Last reply
                          0
                          • NeverDieN NeverDie

                            Here it is notionally for 4 buttons:
                            0_1517019196870_keypad.jpg
                            It's a voltage divider. Structured like this, it could trigger the IRQ pin when a button is pushed, and the analog pin could read the voltage to determine which button it was.

                            NeverDieN Offline
                            NeverDieN Offline
                            NeverDie
                            Hero Member
                            wrote on last edited by
                            #17

                            @neverdie said in 6/8 Buttons battery remote node:

                            Here it is notionally for 4 buttons:
                            0_1517019196870_keypad.jpg
                            It's a voltage divider. Structured like this, it could trigger the IRQ pin when a button is pushed, and the analog pin could read the voltage to determine which button it was.

                            I made a custom PCB to test the concept:
                            0_1517086906817_test_keyboard.jpg

                            1 Reply Last reply
                            0
                            • gohanG Offline
                              gohanG Offline
                              gohan
                              Mod
                              wrote on last edited by
                              #18

                              Tomorrow I'll try to bring out the arduino numeric keypad and an old sketch I used with it and see what I can do

                              NeverDieN 1 Reply Last reply
                              0
                              • gohanG gohan

                                Tomorrow I'll try to bring out the arduino numeric keypad and an old sketch I used with it and see what I can do

                                NeverDieN Offline
                                NeverDieN Offline
                                NeverDie
                                Hero Member
                                wrote on last edited by
                                #19

                                @gohan said in 6/8 Buttons battery remote node:

                                Tomorrow I'll try to bring out the arduino numeric keypad and an old sketch I used with it and see what I can do

                                Cool! I didn't know there was an official Arduino keypad.

                                Here's mine:

                                0_1517105000210_4button_keyboard.jpg

                                1 Reply Last reply
                                1
                                • NeverDieN Offline
                                  NeverDieN Offline
                                  NeverDie
                                  Hero Member
                                  wrote on last edited by NeverDie
                                  #20

                                  It works. Connecting the output wires to A0 and D3, and running this script:

                                  #include <avr/sleep.h>
                                  
                                  void wake ()
                                  {
                                    // cancel sleep as a precaution
                                    sleep_disable();
                                    // precautionary while we do other stuff
                                    detachInterrupt (1);
                                  }  // end of wake
                                  
                                  void setup() {
                                    pinMode(A0,INPUT);
                                    Serial.begin(115200);
                                    Serial.println("Starting...");
                                    Serial.flush();
                                  
                                  }
                                  
                                  void loop() {
                                    uint16_t voltage;
                                  
                                    set_sleep_mode (SLEEP_MODE_PWR_DOWN);  
                                    sleep_enable();
                                  
                                    // Do not interrupt before we go to sleep, or the
                                    // ISR will detach interrupts and we won't wake.
                                    noInterrupts ();
                                    
                                    // will be called when pin D2 goes low  
                                    attachInterrupt (1, wake, RISING);  //pin D3
                                   
                                    EIFR = bit (INTF1);  // clear flag for interrupt 1
                                    
                                    // turn off brown-out enable in software
                                    // BODS must be set to one and BODSE must be set to zero within four clock cycles
                                    MCUCR = bit (BODS) | bit (BODSE);
                                    // The BODS bit is automatically cleared after three clock cycles
                                    MCUCR = bit (BODS); 
                                    
                                    // We are guaranteed that the sleep_cpu call will be done
                                    // as the processor executes the next instruction after
                                    // interrupts are turned on.
                                    interrupts ();  // one cycle
                                    sleep_cpu ();   // one cycle
                                  
                                    delay(100);  //debounce the button
                                    voltage=analogRead(A0);
                                    if (voltage>0) {
                                      Serial.println(voltage);
                                      Serial.flush();
                                    }
                                  }
                                  

                                  on a 3.3v Arduino pro mini yields these values for each of the four buttons:

                                  Starting...
                                  1023
                                  930
                                  852
                                  787
                                  

                                  The pro mini sleeps until one of the buttons gets pressed, then it wakes up, reads the value, displays the value, and then goes back to sleep. :)

                                  1 Reply Last reply
                                  1
                                  • NeverDieN Offline
                                    NeverDieN Offline
                                    NeverDie
                                    Hero Member
                                    wrote on last edited by NeverDie
                                    #21

                                    It * might* get a little hairy though if running at 1.8v and you've got a lot of buttons to disambiguate and you still want to wake up on any button press. According to Table 32-2 of the atmega328p datasheet, the minimum threshold for input HIGH if running at vcc=1.8v-2.4v is 0.7Vcc. So, at the limit, that is 0.7*1.8v=1.26v. So, if n is the number of buttons, you need to disambiguate, then in a perfect world 0.54/(n-1) volts separates each button press. So, if say 12 buttons, that is 0.54/11=0.049 volts. Well, let's see: resolution is 1.8v/1023=0.0018v.

                                    Hmm... Again, in a perfect world, that's 27 analog read units separating each button press. In an imperfect world, that's not a lot of headroom for disambiguation. I guess in the worst case you might have to run a one-time calibration for each button and store it in EEPROM. I would hope to avoid such a calibration step, but it might come to that.

                                    zboblamontZ 1 Reply Last reply
                                    1
                                    • gohanG Offline
                                      gohanG Offline
                                      gohan
                                      Mod
                                      wrote on last edited by
                                      #22

                                      I am planning to use a LiFePO4 3.4V battery anyway, so it will be difficult to go even below 2.8V as that would mean battery almost empty.

                                      1 Reply Last reply
                                      1
                                      • NeverDieN NeverDie

                                        It * might* get a little hairy though if running at 1.8v and you've got a lot of buttons to disambiguate and you still want to wake up on any button press. According to Table 32-2 of the atmega328p datasheet, the minimum threshold for input HIGH if running at vcc=1.8v-2.4v is 0.7Vcc. So, at the limit, that is 0.7*1.8v=1.26v. So, if n is the number of buttons, you need to disambiguate, then in a perfect world 0.54/(n-1) volts separates each button press. So, if say 12 buttons, that is 0.54/11=0.049 volts. Well, let's see: resolution is 1.8v/1023=0.0018v.

                                        Hmm... Again, in a perfect world, that's 27 analog read units separating each button press. In an imperfect world, that's not a lot of headroom for disambiguation. I guess in the worst case you might have to run a one-time calibration for each button and store it in EEPROM. I would hope to avoid such a calibration step, but it might come to that.

                                        zboblamontZ Offline
                                        zboblamontZ Offline
                                        zboblamont
                                        wrote on last edited by
                                        #23

                                        @neverdie Is this not an instance where a high efficiency low dropout booster supply would null this particular issue?

                                        NeverDieN 1 Reply Last reply
                                        0
                                        • zboblamontZ zboblamont

                                          @neverdie Is this not an instance where a high efficiency low dropout booster supply would null this particular issue?

                                          NeverDieN Offline
                                          NeverDieN Offline
                                          NeverDie
                                          Hero Member
                                          wrote on last edited by
                                          #24

                                          @zboblamont said in 6/8 Buttons battery remote node:

                                          @neverdie Is this not an instance where a high efficiency low dropout booster supply would null this particular issue?

                                          Yes, that trade-off would relax the constraints.

                                          But so does a one-time calibration. Since writing the above, I've warmed up to the idea. At least for my purposes, it's not that big a deal.

                                          Nca78N 1 Reply Last reply
                                          0
                                          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