Flash fails for MCP9808 build

I have some code that is largely copied from what seems to be working for other users. I am puzzled that I have tried many variation and can’t seem to get this project working even though it seems simple.

I am using a Particle photon and an Adafruit MCP9808. I have made the following connections from

Photon -> MCP9808
3v3 -> Vdd
Gnd -> Gnd
D1 -> SCL
D0 -> SUA

I have tried this with the MCP9808 library included on Particle Build and also with a similar library I found on Github. The results are the same.

My code is only 16 lines:

// This #include statement was automatically added by the Particle IDE.
#include "MCP9808/MCP9808.h"

// The I2C devices - classes are imported from Adafruit's published libraries
MCP9808 mcp = MCP9808();

int counter;

void setup() {
    // ALERT the next line is causing the failure.
    mcp.setResolution(MCP9808_FAST);
}

void loop() {
        // This line will also cause it to fail
	Serial.print("Temp:"); Serial.println(mcp.getTemperature(), 4);
	delay(250);
}

After flashing, the flash status is failed and the devices cycles on, starts flashing red, then eventually cycles back on again. It looks like it attempts a few more flashes. Eventually it stops the attempts to flash and just cycles on, flashes red for a bit, the goes off again.

The line above (after the line labeled ALERT seems to be the line causing the problem. When the line is there, the flash process fails. If I comment out the line, the flash process succeeds. What is the problem with that line? This library is included in the Build framework, shouldn’t it work?

Can anyone offer some help?

thanks!

If you look at the demo, you’ll see an important part you are missing

	while(! mcp.begin()) { //<-- you NEED to do this before any other mcp action!
	    Serial.println("MCP9808 not found");
	    delay(500);
	}
	
2 Likes

I can’t believe I missed that! That was totally it. Thanks a ton!

1 Like