Author Topic: I2C Noise and data corruption- USB battery v mains adapter(s) show diff behavior  (Read 1398 times)

0 Members and 1 Guest are viewing this topic.

Offline USER_1234567890Topic starter

  • Newbie
  • Posts: 4
  • Country: us
Hi all,

I've got a relatively simple device - a Wemos D1 Mini running a SD card module plus the following I2C devices: 1306 driven OLED, SHT85 humidity and temperature sensor plus a MS5837 pressure sensor. All of those are powered off of a 3.3v bus.

I've got pullup resistors (started with none, then 10k then 2k with no difference in results) on the I2C lines (SDA and SCK) and and a 47 uf electrolytic cap on the 3.3v rail.

I'm using it to sample process air in an industrial (i.e. fairly electrically noisy) environment.

When I run it off of a USB battery, everything works fine, indefinitely.

When I run it off of any of multiple USB adapters into the 5V in or via a mains to 3.3v adapter, the data recorded (and screen) become increasingly corrupted. I'm also writing a time string to the SD card, and that's recording without error, so I think the issue is entirely on the I2C bus. Worth noting that it works fine on mains power (USB or other adapter) in an office environment.

Before I sit down and actually learn how to use my scope in anger, has anyone here run into a similar circumstance?

Thanks in advance,
Chris
 

Offline tooki

  • Super Contributor
  • ***
  • Posts: 12577
  • Country: ch
How long is the I2C bus? It’s not designed for anything but short distances. How’s it wired up? Does adding a ceramic cap (e.g. 100nF - 10μF) to the 3.3V rail help?

NXP makes a chip, the PCA9615 that turns I2C into a differential signal that can handle longer distances and reject noise. (I’d like to try it in a project I’m working on now, but nobody has any in stock. :/ )
 

Offline USER_1234567890Topic starter

  • Newbie
  • Posts: 4
  • Country: us
Apologies - got sidelined and forgot to check back in. The bus is all of 30mm long. Should I expect different behavior from a ceramic cap vs an electrolytic one on the 3.3V rail? 
 

Offline tooki

  • Super Contributor
  • ***
  • Posts: 12577
  • Country: ch
30mm is nothing. You didn’t answer my question about how it’s wired: PCB traces? Cables? Something else?

Ceramic and electrolytic capacitors have very different high frequency behavior. In particular, ceramics are much better at filtering high-frequency noise, which is often the kind of stuff one is dealing with.
 

Online RoGeorge

  • Super Contributor
  • ***
  • Posts: 6706
  • Country: ro
I've had similar problems with some other IC.  Thought at first it was the chip's fault.  Turned out the cause was the reflections in the transmission lines (caused by the wires that were forming a transmission line and the impedance miss-matching).

Try to add a small series resistor with each wire, so to lower the ringing in the wires.
 
The following users thanked this post: tooki

Offline free_electron

  • Super Contributor
  • ***
  • Posts: 8550
  • Country: us
    • SiliconValleyGarage
How long is the I2C bus? It’s not designed for anything but short distances.
Not true. it was designed for noisy environments like TV chassis to reduce the number of communicating lines between chips. Old analog picture tube TV's were electrically VERY noisy.
that's why the bus can detect level errors and has an abort - retry mechanism if a state change does not happen correctly. Problem is that almost none of the i2c driver code implements it !

Get your pullups correct , route SCL and SDA correctly ( separated by a ground ) .

I2c is even used in 19 inch compute racks as system management bus.
I've ran i2c over long distance using current injectors instead of simple pull up resistors without issues.. twisted pair ethernet cable.  SCL+gnd and SDA+gnd the other two were power pairs. works like a champ.
Now there is indeed differential i2c. Maxim (linear tech) also makes transceivers for that.

Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 

Offline tooki

  • Super Contributor
  • ***
  • Posts: 12577
  • Country: ch
How long is the I2C bus? It’s not designed for anything but short distances.
Not true. it was designed for noisy environments like TV chassis to reduce the number of communicating lines between chips. Old analog picture tube TV's were electrically VERY noisy.
that's why the bus can detect level errors and has an abort - retry mechanism if a state change does not happen correctly. Problem is that almost none of the i2c driver code implements it !
I didn’t say anything about noise immunity. I said it’s not designed for long distances, and it’s not. This is widely documented, and the fact that transceivers to differential, different voltages, etc. exist only prove this. (The I2C spec only mentions length once — the order of the traces/conductors for lengths over 10cm — but the maximum bus capacitance is what forms the limiting factor.)


Get your pullups correct , route SCL and SDA correctly ( separated by a ground ) .

I2c is even used in 19 inch compute racks as system management bus.
I've ran i2c over long distance using current injectors instead of simple pull up resistors without issues.. twisted pair ethernet cable.  SCL+gnd and SDA+gnd the other two were power pairs. works like a champ.
Now there is indeed differential i2c. Maxim (linear tech) also makes transceivers for that.
So yeah… workarounds for it not actually being designed for long distances. (Not that I’m against workarounds if they work! Just saying that it was not originally designed for long distances.)
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6226
  • Country: es
I2c is meant to be used on-board, if using wires and the AC adapter, you might be picking mains AC noise.

Try twister pairs to provide some shielding, each being sda+gnd, SCL+gnd.

Add 100nF+1uF between VCC and gnd in every device connected to the i2c bus.

Try using 4k7 pullups at the start and also at the end of the bus, might work like some sort of termination.
« Last Edit: April 05, 2022, 09:53:51 pm by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline free_electron

  • Super Contributor
  • ***
  • Posts: 8550
  • Country: us
    • SiliconValleyGarage
the maximum bus capacitance is what forms the limiting factor.
That is the only correct answer. Hence the usage of current mode injectors instead of pullups. Linear technologies has some of those. Many newer I2C devices have special active pull-up structures where they use two fets. They turn on a low impedance path to pull hard up and then switch that off after a few nanoseconds to a residual current. the PCA9xxx family has those i believe.

Quote
So yeah… workarounds for it not actually being designed for long distances. (Not that I’m against workarounds if they work! Just saying that it was not originally designed for long distances.)

depends what you mean by long.. on a single board tv chassis the bus length could be well over a meter , often going onto a wire bundle or connector to a second board or third board. Philips, Loewe, B&O , Salora, Finlux, Noka. They all did it. ( i worked at Salora as an intern in 1989). thos ewere the days. the ITT 2000 digivision chipset.. based on a 8048 core.
Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 

Offline USER_1234567890Topic starter

  • Newbie
  • Posts: 4
  • Country: us
Sorry! Wired via cables. Will try the ceramic cap first, since that's the easiest one. Second easiest one will be ground twisted pairs for SCL and SDA. I've got pullup resistors on the recieving end. I'll check the sensor chip spec sheet; I thought they had internal pullups, but will re-check.

Thanks!
 

Offline USER_1234567890Topic starter

  • Newbie
  • Posts: 4
  • Country: us
Posting for posterity... 47uf ceramic cap on 3.3 + twisted pair on SCL, SDA fixed it - not sure which one fixed it more, but maybe I'll circle back later and figure that out.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf