[solved] Adafruit TSC2007 I2C Resistive Touch Screen Controller

I’ve got a Adafruit TSC2007 I2C Resistive Touch Screen Controller - STEMMA QT | ADA5423 | Core Electronics Australia and I’m trying to get it to work with a Raspberry Pi Pico W. I’ve connected a resistive touch panel to the tsc2007, and I’ve got the tsc2007 connected to the pi via a piicodev expansion board.

AdaFruit’s libraries are all for circuit python, but I’m using micropython, and I’m trying to adapt their library.

from machine import I2C, Pin
i2c = machine.I2C(id=0, scl=Pin(9),sda=Pin(8))

returns [72] which is 0x48, the address of the tsc2007, so it looks like I’ve connected it correctly, also, if I touch the panel I see the led on the tsc2007 light up registering the touch.

The AdaFruit library uses I2CDevice, which seems to be a simple wrapper with helper functions.

Where I’m running into problems is trying to replace the writeto_then_readfrom circuit python method. I think it should just be a writeto then a readfrom. However, when I do

cmd = bytearray(1)
cmd[0] = b'\xc4'      # the command the tsc2070 is trying to send
i2c.writeto(72, cmd)

I get OSError: [Errno 5] EIO apparently that’s some kind of configuration/wiring error, but all that looks ok (as far as I can tell)

Any suggestions on what I could try?


1 Like

Hi @Doug27394 - mad respect for rolling up your sleeves and DIYing a driver.

I don’t suppose you have a logic analyser you can use to capture what’s going on here?
Can you link to the driver you’re taking inspiration from too? It can be helpful to have a reference for how to correctly initialise the chip.

I’ve had a light read of the datasheet and nothing has jumped out at me yet - sometimes i2c devices have funny, non-standard behaviours and requirements.

1 Like

Just to see if there was a problem with any of the components I tried various combinations:

  1. a different pico w
  2. a different i2c cable
  3. using the Makerverse Nano power timer instead of the piccodev expansion board
  4. using the PiicoDev RGB LED Module and the related walkthrough

None of that worked, so I tried a regular Raspberry pi pico… Success! Both with the resistive touch and the PiccoDev board.

I saved all that code, then wiped and flashed a Pico W with RPI_PICO_W-20240105-v1.22.1.u2f copied the files that had worked on the regular pico… exactly the same problem. It’s like 12c on the W is broken… on both of them :angry:

1 Like

Thanks, though it was more reverse-engineering the adafruit driver. It seems it’s a problem with the I2C on the/my pico w.

I followed the steps from PiicoDev RGB LED Module - Raspberry Pi Pico Guide - Tutorial Australia with the latest u2f and it errored out. It’s weird how i2c.sacn() works, but writing doesn’t.

Have you had any troubles with the piccodev code on the pico w?

1 Like

OK, I think I know what happened:

My code i2c = machine.I2C(id=0, scl=Pin(9),sda=Pin(8)) didn’t specify the frequency.

As per this topic Raspberry Pi Pico W I2C/Piicodev Bug [Solved] - #26 by James46717 there was a problem with the pico w when you didn’t do that.

My working version on the non-W had the old PiicoDev_Unified.py so it worked on the non-W pico, then when I copied the “working” code over to the freshly wiped W it had the old version of PiicoDev_Unified.py with a known bug so it didn’t work.

All fixed now, and I can get on with the next step of talking to an e-ink display.


Hey that’s a great result :partying_face:
That issue was from so long ago I didn’t think of it when I read your post - yeah that Unifed version must have been pretty old at this point.

Best of luck with the rest of it! :smiley: