Issues with I2C touch and OLED screen

Hi folks

Would greatly appreciate any expertise/suggestions on this little conundrum!

Background:

  • Raspberry Pi Zero W
  • SSD1306 screen running over I2C using luma.oled package in Python3, has worked well for a few months when used in conjunction with touch control using an AT42QT1070 in standalone mode with three keys tied to GPIO pins
  • However I’m now putting the setup in a plastic enclosure and the sensitivity in standalone mode isn’t sufficient to detect the touch, therefore I need to run the QT1070 in comms mode (I2C), as that lets you adjust the sensitivity.

i2cdetect shows both devices fine (3c is the screen, 1b is the touch controller). I have a Python script to control the screen and another for touch control. If I just load the screen script it will start the screen and update fine but then after a few seconds it will then crash.

It seems that if I just run with the screen connected or just with the touch controls it works OK but when both are connected they’re somehow interacting with each other, despite both showing up correctly and both working to some extent before they abort.

On my breadboard layout (I created one for the VQFN package - unfortunately the larger 14-pin SOIC seems to be out of stock thanks to the worldwide chip shortages) they seem to work OK so I’m worried I’ve done something stupid with my PCB! As I say I can interrogate the registers on the AT42QT1070 OK, it’s more like something destabilises the I2C bus when I’ve got the screen running too?

My KiCAD PCB layout as follows (the weird outline is due to other components/fixings in the case I have to work around), please just say if any more info would be useful…

My question is whether there are any obvious flaws people can see from the point of view of designing a PCB layout when dealing with I2C.

As far as can understand, this has nothing to do with KiCad except that you have designed the hw with KiCad. This forum is about using KiCad. Additionally answering this question requires more than generic knowledge about electronics; it’s highly dependent on certain hw platform and its programming environment plus Python. Therefore I don’t expect you can get any help here. Isn’t there any better forum for this kind of question?

Apologies, I’d thought this project section of the forums was slightly broader than just how to undertake a particular task in KiCAD? My question here is around the PCB design itself and whether I’ve done anything stupid from an I2C design perspective - I’ll remove the Python elements. I’ve posted on some Raspberry Pi forums but although they’re helpful from a coding perspective I’ve not had much luck on the PCB front. As I say this seems to work on the breadboard (VQFN layout below) but not on the PCB so I’m trying to work out if I’ve done something silly from a PCB perspective, hence why I thought I would ask here…

As eelik already said, the sole purpose of this forum is for questions of working with KiCad itself.

That said, there are plenty of people around here who have a bit of knowledge about electronics and are willing to help in a broader sense :wink:

I see you do have a GND plane around your IC, which almost always is good, but for capacitive sensor wires, one of the first goals is to lower capacitance to any unwanted items. That means reducing the GND plane, (at least so the pads of R1, R2 and R3 do not form a capacitor with the GND plane, and using shorter tracks, for example place the IC near the place where the 4-pin “touchpad2” connector in the center is now.

I2C is also always (per definition) Open Drain, and the I2C bus requires pullup resistors. Sometimes these are already integrated on the microcontroller board, Sometimes there are such pullups on the microcontroller board but they are very weak. The best way is to check this is to look at the flank steepnes (especially rising flanks) of both I2C lines. If there are weak pullups, then there is a chance that I2C starts working at lower baudrates. But no guarantees.

Also, anything near or around the sensor pads influences the capacance changes. And I think that the GND plane itself is also an integral part of the measurement loop. Connecting GND to some shielding in the enclosure, but not too close to the sensor pads may help.

There is no hard boundary on such topics and there was quite a bit of backstory when getting to the question. :wink: Layout isn’t as removed from Kicad as the rest of it. Honestly, the limits from my perspective, have more to do with keeping postings down for the sake of the site moderators. Well behaved threads aren’t a problem. If it gets too involved we generally direct you to a more appropriate site where you are likely to get more eyes on it.

Sorry - was trying to help by providing more background to my question but realise in retrospect that probably wasn’t helpful!

Haha yes, I had seen quite a few of those other posts when browsing, hence why I was hoping someone would throw mercy on me :wink:

The Pi already has 1k8 pull-ups on the I2C pins so I didn’t think I would require any further ones? As I say it seems to work OK when just running the screen or when running via the breadboard so I think it might be more something I’ve done wrong with the PCB design.

Unfortunately the 4-pin connector in the centre is for the OLED screen (which fits in the cut-out below) so I can’t move it too much there, but I can try to reroute the touchpad wires a bit so they don’t cross the SDA/SCL lines if that would help?

I’ll see if I can get hold of an oscilloscope to look at the I2C signals, but unfortunately don’t have one to hand.

I seem to remember that when I frequented the Arduino Forum they generally considered the internal pull resistors inadequate. I think they were much higher value but don’t remember for sure now. But, that’s the kind of thing that a forum dedicated to that platform SHOULD be able to help with. I don’t know about the Pi stuff but the Arduino forum was quite robust. Hence, as @eelik said, you might really get better help with because sheer numbers count sometimes.

Thanks - unfortunately tumbleweed on my post on the Pi forums so far but will keep my fingers crossed. Now off searching for some other electronics forums where I2C PCB design is discussed, will see what I can find! I’m wondering if running some of the SDA/SCL lines (to the touch chip) near a ground plane and some (to the OLED screen) not near ground might be creating some sort of differential.

1k8 would be quite strong pullup resistors, But in the end it’s a combination between the RC constant (Bus capacitance) and the bitrate. Without a scope you can add some 2k2 resistors to see if there is a difference. Microcontrollers generally can sink about 20mA, so that would be the limit.

eevblog.com/forum is a pretty busy place. Apart from that, any forum that deals with microcontroller hard- and software would be a good guess.

1 Like

If you get some good feedback somewhere you might want to post the link here.

Just in case its needed… from the top of my head:

  1. https://electronics.stackexchange.com

  2. https://www.eevblog.com/forum

  3. https://embdev.net/forum

Also…

Have you consulted this paper yet?

1 Like

Thanks. Yes, I used it to guide my design and as I say the touch side works fine, it’s the i2c issues that are causing problems. I’ve now got the two 60-odd page NXP spec sheets for that so will have a look at them (I hadn’t bothered before as the screen worked fine when the touch controller was in standalone mode). Thanks for the embdev forum suggestion too, I hadn’t heard of it before :+1:

Will do although unfortunately no reply so far on EEVblog forums, will keep fingers crossed!

I’ve made quite a number of Touch switches and have used off-the-shelf units…

I hate them!!! Depending on Humidity and how close I get, the switches turn on/off, stay on/off…

Sometimes no problem, then hours later, something turns on… (or, off)

I suggest isolating individual switches, hooking up and seeing what happens…

Yep they’re well spaced out from each other and in I2C mode I can adjust sensitivity and it seems to work well - the issue is the conflict with the OLED running over I2C at the same time. As I say it’s fine on my breadboard layout so I just wonder if I’ve made any mistakes in my PCB design?

It may also be a software issue.
Things like humidity and other environmental changes tend to be slow and can be filtered out, but need constant attention for some moving average filter. There is probably plenty of literature “out there” for those things.

I have never used capacitive sensors myself because I just prefer the look and feel of real buttons

I went from “liking them” to “hating” them when… as follows:

I have fairly expensive warm/yellow LED kitchen lights with Touch.
One night, 4am I woke up to see flickering yellow/orange and was reminded of a house fire I was in… By the time I arrived downstairs, I realized there was no smoke.

The lights were flickering rapidly - just like a fire!

As my hand approach the light to Touch it (turn it off) it stopped.

A mind of their own…

Link to the eevblog post?

Sure, it’s https://www.eevblog.com/forum/beginners/i2c-touch-and-oled-pcb-design/

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.