so after doing everything i can think, even rewriting it in micropython, i added the internal pulldown resistor (the pullup resistor did not help) and now it seems to work.