Posts: 12
Joined: Wed Jul 11, 2012 7:48 pm

GPIO detects very small currents

Fri Jan 17, 2014 12:06 am

I have a 3x4 matrix keypad wired up to 7 GPIO pins - each through an 18k resistor. The row pins are set as outputs and the column pins set as inputs. The inputs are configured to pull to ground via the internal pull downs. I have some code using wiringPi to detect interrupts on the input pins when they go HIGH. This works fine... although the interrupt is triggered if I so much as wave my hand in the vicinity of the wires. This is also a problem if I move the wires slightly and the magnetic field in one induces a current in another.

Can anyone speculate as to why this is detecting such crazy low currents as a state change on the inputs... and how I might solve the issue.


User avatar
Posts: 1750
Joined: Thu Oct 03, 2013 7:48 am
Location: Ljubljana, Slovenia
Contact: Website

Re: GPIO detects very small currents

Fri Jan 17, 2014 12:49 am

lavinpj1 wrote:Can anyone speculate as to why this is detecting such crazy low currents as a state change on the inputs...
I'll not speculate. ;-) I'm sure that you didn't follow "good development practice" guidelines. I haven't seen complete guidelines set collected anywhere so far, but they are (more or less) a set each must collect from various sources all the time, including from his/her own failures in the past (you just can't forget some of them :| ).
However, a book which is closest to this collection-ideal and its content is applicable to your problem, has title "High-speed digital design - A handbook of black magic". Highly recommended !!!
lavinpj1 wrote:and how I might solve the issue.
Decrease resistor values (add external ones), shorten wires, avoid breadboards usage, create PCB filled with ground plane instead. This could be enough.

Best wishes, Ivan Zilic.
Running out of GPIO pins and/or need to read analog values?

Paul Moir
Posts: 46
Joined: Wed Dec 04, 2013 7:25 pm
Location: Nova Scotia, Canada

Re: GPIO detects very small currents

Fri Jan 17, 2014 4:45 am

Another is to suppress the meaning of the interrupt with logic that says a key must be held for n milliseconds before it is counted as pressed. You can debounce your switches this way too.

I have a pi setup with a not-very-noisy solenoid attached which would generate spurious interrupts on the GPIO. Adding RC filters to the inputs helped, but did not completely eliminate the problem. A little programming did though, since noise spikes are generally very short. While this is a little hackish, it works well enough in practice.

'Dunno what the Pi's GPIO pulldowns are supposed to be, but in a noisy environment more is better. I would be thinking at least 4.7k, and more like 1k...

Posts: 758
Joined: Tue Jan 24, 2012 9:30 am
Location: Hertfordshire, UK
Contact: Website

Re: GPIO detects very small currents

Sat Jan 18, 2014 1:35 pm

My initial thought would be that you have not programmed the internal pulldown resistor correctly. This would leave the input floating.

If that is not the case then I think the cause could be RF pickup. I suspect that you are driving the rows with a high frequency square wave which is being transmitted by the wiring and received by the column wires.

Things I would do
a. Look at the many circuits and code for keypads that are on Google
b. Reduce the frequency of the drive
c. Reduce lengght of wires. Twist together the row wires and separately the column wires
d. Screen the two sets of wires connect screen to 0 volts.
e. Connect any metal chassis of the keypad to 0 volts.
f. Make the square waves less square.

I'm not sure why you need the 18K resistors. I was slightly concerned that the circuit may not work when the rows are at +3.3 volts. There is then a 36K . 10 K (or greater) potentiometer connecting output and input so the input might not register 1.

You can reduce the resistors. The calculation of the minimum value must be such that the output of the Pi are not overloaded even if all 12 keys are pressed at the same time. It also depends if the keypad has diode protection.
Pi Presents - A toolkit to produce multi-media interactive display applications for museums, visitor centres, and more
Download from

Return to “Interfacing (DSI, CSI, I2C, etc.)”