Pull up resistors vs. Pull down resistors

I designed an add-on board for my Raspberry Pi Zero to interface a CCS811 volatile organic compound sensor (Source files available from here). The CCS811 comes with an I²C interface.

IMG_20180101_171840.jpg

Raspberry Pi Zero add-on board for Sparkfun’s CCS811 breakout

My intention behind designing a PCB was to avoid all the messy wires you would need while a prototyping board (or a “dot board”).

IMG_20171031_163834.jpg

Same circuit (as above) but soldered onto a prototyping board

The PCB design was a simple one and I did not anticipate problems with the design. When I soldered the PCBs and began my testing, I was surprised to note that the sensor was not detected by the i2cdetect command.

The circuit is very simple and the sensor breakout contains pull up resistors for the I²C interface. I had to draw four traces to interface the sensor (3.3V, GND, SDA & SCL).

The sensor breakout is equipped with a reset pin, a wake pin and an interrupt pin. All of them are active low signals.

PCB_Schematic

Raspberry Pi Zero add-on board

In order to exploit the sensor’s features, I decided to interface those pins to the Raspberry Pi’s GPIO interface.

If you are an EE, you might me aware of the fact that GPIO pins are set to a high impedance state. I was aware of this fact but I also found out that while they are set to a high impedance state, they are also either pulled up or pulled down (Source).

The wake pin of the sensor breakout is connected to a GPIO pin (of the Raspberry Pi) that is pulled high in its high impedance state. I was wracking my brain to understand why the sensor wasn’t detected by the Raspberry Pi. My assumption was a bad solder or lack of continuity.

It turns out that a combination of current leakage (from the GPIO pin) and a weak pull-down resistor caused this headache. The sensor breakout’s reset pin comes with a 100K pull down resistor on the wake pin.

ccs811

CCS811 schematic

It turns out that the 100K pull-down resistor was not sufficient to overcome the effects of leakage current. The wake pin was tied to “high” and put my sensor to sleep. I had to create a solder bridge between the wake pin and the ground pin. It worked like a charm!

i2c_detect

I wonder if a stronger pull-down resistor would have solved the problem. I was conducting further investigation into the problem and I learned that pull-down resistors are a bad idea. Read all about it in Jack Ganssle’s article.

Adafruit has a similar sensor breakout and they used a pull-up resistor. You need to tie the pin to ground and it makes sense to me.sensors_schematic

I think it is crucial to choose the right resistor value AND it is best to pull up your signal line (wherever possible).

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: