6/8 Buttons battery remote node
-
You can :
- use another IC that is not so cheap about external interrupts (ex: nrf5)
- connect each button to pin 3 through a diode so your board will wake up, then check each input pin to know which button is pressed
- use pin change interrupt, it works but you need to write your own sleep method as it's not in the options of the MySensors sleep
- use an extender ic (for example sx150x but there are cheaper and easier to solder options) or a touch ic (for example mpr121) and use their interrupt pin to wake up your board, then retrieve data through I2C
-
You can :
- use another IC that is not so cheap about external interrupts (ex: nrf5)
- connect each button to pin 3 through a diode so your board will wake up, then check each input pin to know which button is pressed
- use pin change interrupt, it works but you need to write your own sleep method as it's not in the options of the MySensors sleep
- use an extender ic (for example sx150x but there are cheaper and easier to solder options) or a touch ic (for example mpr121) and use their interrupt pin to wake up your board, then retrieve data through I2C
@nca78 said in 6/8 Buttons battery remote node:
connect each button to pin 3 through a diode so your board will wake up, then check each input pin to know which button is pressed
I had the same thought, I just wanted to ask for other viable options. How is the power usage of the mpr121?
-
@nca78 said in 6/8 Buttons battery remote node:
connect each button to pin 3 through a diode so your board will wake up, then check each input pin to know which button is pressed
I had the same thought, I just wanted to ask for other viable options. How is the power usage of the mpr121?
@gohan said in 6/8 Buttons battery remote node:
@nca78 said in 6/8 Buttons battery remote node:
connect each button to pin 3 through a diode so your board will wake up, then check each input pin to know which button is pressed
I had the same thought, I just wanted to ask for other viable options. How is the power usage of the mpr121?
Somewhere around 20uA.
-
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. -
Here it is notionally for 4 buttons:

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. -
By clever resistor selection, you can even shave a few resistors off the design:

-
@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.
@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.
-
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.
-
@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.
-
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.
-
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.
-
@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?
@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.
-
Here it is notionally for 4 buttons:

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.@neverdie said in 6/8 Buttons battery remote node:
Here it is notionally for 4 buttons:

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:

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

-
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 787The 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. :)
-
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.