RAK5205 interrupts

Hi,

I’m using the RAK5205 as a counter (see my previous topic Use interrupts in RAK5205)
For time to time without any event (the interrupt circuit is open) the counter increased.

The schematic circuit -
image

the init code -
Int_1.pin_num = PB3;
Int_1.dir = RUI_GPIO_PIN_DIR_INPUT;
Int_1.pull = RUI_GPIO_PIN_PULLUP;
rui_gpio_interrupt(true, Int_1, RUI_GPIO_EDGE_FALL, RUI_GPIO_IRQ_HIGH_PRIORITY, counter_int);

How long is the cable to the switch?

How is it routed? (next to power cables etc)

It is better to add external pull-up resistor. Also, I am experienced this before adding the external resistor.

it is connected to the header connector via a 3 pin 90 degree header (where jus 2 of the pins are connected) the wire to the sensor is 35cm long (https://www.monoprice.com/product?p_id=2824) 16awg.
I dont think the wire is the issue, it is much thicker than needed

in our case , the sensor is a reed switch, so there is no power or gnd there. where would you connect the pullup to?

I was interested if in it was picking up any interference - as @mamanbudiman suggests, a pull-up resistor (10k) would be appropriate as long as the wire is not routed next to a great big power transformer, lift motor or van de Graff generator.

You can connect external resistor from PB3 to VCC.

Thanks guys!
will try

hi @leopold,
We have 30 units in the fields and it is very complicated to add resistor for each unit. Any idea for software solution here?
Thanks

Depends on how long the switch is mean’t to be closed - if you it’s a decent amount of time you can code the interrupt to ignore short durations.

How will you get the code out in to the field?

It won’t take much time to put the resistor in to pin 12 & 14 of the header.

Can you test it on your working / prototype / testing module?

Thanks @nmcc.
I’m trying to filter short noises so I detect RUI_GPIO_EDGE_FALL and increase my counter only after 300ms from the interrupt. I want to filter also short pulses width so I have to catch both edge fall and raise. Is it possible to detect both and differentiate between them?

Sure, use a volatile global to hold the state of the GPIO so when the edge interrupt is triggered, you can compare what was with what is and with another variable, you can track the time of the previous interrupt.

Or set up two interrupts one for fall and one for raise with similar variables.