pcf8574 random key presses indicated

I am using a pcf8574 board from waveshare to give me 5 key inputs via i2c.

I wired up initially without pullup resistors and was getting intermittent indications of key press and wrong values , so, I stuck in some 10k resistors and provided 3.5 volts to the circuit. I was still getting odd indications so I thought maybe 5v.

It seemed to be ok for a good while and then I was getting odd key presses again, if I turn power off and wait for 10 min and then turn it all back on its good again, until its not.

So I suspect that I have not got the correct resistors or …

#include <PCF8574.h>
#include <Wire.h>
#include <TimedAction.h>
PCF8574 PCF_38(0x38);  // add switches to lines  (used as input)

uint8_t expander = B00100000;
TimedAction timer = TimedAction(100, check_switch_multi);
int val;

void setup()


void loop()

void check_switch_multi()
	for (int sw = 0; sw < 5; sw++)
		val = PCF_38.read(sw);   
		if (val == 0)  
/* ************************************************************** */
void check_switch_single()
	val = PCF_38.read(0);  // get the value for pin i

expected serial output of pressing keys in order of 0123401234  

Opening port
Port open



BUT occasionally I get random key presses the can start and then just continue 

01234012340000000000000000000000000000000000000000 ...

0 with no key pressed  

sometimes pressing 3 will illicit a 0  in the output

turn off the device wait 10 minutes turn it back on and its working ok again


Problems you might be facing -Loose connection -if resistors are incorrect check through multi-meter. -use proper power supply -your arduino might be lagging depends on your board.

are 10k resistors the right type/value ??

is perhaps the usb cable from the pc to the Arduino not powerful enough to supply the voltages ??

why would it work ok for 10 - 15 minutes and then not, I thought it might be getting too much voltage ??

1) yes 2) no 3) probably loose connections.

thank you both very much

Some days passed and I built a second keypad very carefully ( I thought) and I had the same problem, so I thought its gotta be something else, so I stuck it together on a bread board, turned it on and not a problem, doesn’t miss a beat.

Seems I can’t solder to save my life.