[SOLVED] Trouble communicating with MCP9808

I’m trying to get my photon to communicate with an MCP9808 without much success. I’ve tried using a few samples I’ve found online, including the Adafruit_MCP9808 class. I’ve had to tinker a bit with the includes to get it to compile, but it’s otherwise stock.

For wiring, I have:

MCP9808 vdd -> Photon 3v3
MCP9808 gnd -> Photon gnd
MCP9808 scl -> Photon D0
MCP9808 sca -> Photon D1

I definitely see 3V across the vdd/gnd pins, and there’s nothing obviously wrong with the scl/sca pins (that is, they’re not soldered together or anything).

Anyway – when the Adafruit_MCP9808 class reads the manufacturer and device IDs, they come back as 0xffff (or -1, 65535, whatever you want to call it).

Code is:

int manu = read16(MCP9808_REG_MANUF_ID);
int devid = read16(MCP9808_REG_DEVICE_ID);

Which runs as part of setup. MANUF_ID and REG_DEVICE_ID are 6 and 7, respectively.

Any ideas on what might be wrong? Is the board just fried or something?

I’ve tried swapping the scl/sca wires, switching between the 3v3 pin and a 5v source, tried a number of different examples online, but get the same results every time.

SDA = D0
SCL = D1
If you’re actually using D1/D2 and that’s not a typo, that’s probably the problem!

Which breakout board are you using? I2C requires pull-up resistors on SDA and SCL, but, for example, the Adafruit MCP9808 board includes the pull-ups on the breakout board, so you don’t need to add more.

Also, the MC9808 is addressable. The Adafruit board has pull-down resistors on A0, A1 and A2 so make sure you’re using the default address of 0x18 unless you’ve changed the address by connecting one or more of the A pins to 3V3.

1 Like

Ah, you’re right. I was forgetting to zero-index the pins. It’s actually D0/1, not D1/2.

I have the Adafruit board with the pull-up resistors on SDA/SCL.

When I started it up again this evening it started to generate accurate temperatures intermittently. After that, it was easy enough to track down a bad connection (which was, in this case, a bad solder joint (which, with the multimeter pressed on it, had good connectivity).

Anyway – once I resoldered it, things worked out fine.


1 Like