Faulty MPC9808 Sensor?

I am setting up a particle photon to act as a thermostat supervisor just to see when it turns on and at what temperatures. I choose to use a MCP9808 temperature sensor as it seemed to be the best temp sensor (.25C accuracy) available at a reasonable price (<10 dollars). However, the sensors readings are extremely off compared to real-world temperatures as seen in the attached pic constantly reading high. Would anyone have an idea of what could be causing this/how to recalibrate the sensor?

@armashanth, can you tell us a little more about your hardware setup? It is quite possible that your MCP9808 is being affected the temperature of nearby components. Also, which MCP9808 library are you using?

2 Likes

@peekay123, thanks for responding. I have an image attached of my set up. I had a similar concern with radiant heat, but when I used my finger to prob I was unable to notice much head coming off surrounding components.

I am using the MCP9808 library, found at this github link https://github.com/romainmp/MCP9808. I know there is also an adafruit_MCP9808 library, but I choose to go with the MCP9808 library as it had more downloads and I assumed functionality would be the same.

@armashanth, I noticed you have a full-wave rectify and regulator but with no input or output filtering capacitors. You also have a diode connecting to the ground rail of the protoboard. What is the regulator powering? What is the diode for?

Other observations:

  • If the regulator is powering everything, you will need a large (100uF or more) cap at the input and a small (0.1uF) decoupling cap at the output of the regulator. Ripple on the output of the regulator could affect the performance of the MCP9808.
  • The Photon (and the WiFi antenna) is VERY close to the MCP9808, again possibly creating noise for the MCP9808. I suggest you put the MCP9808 far away from ANY components such as the Photon and the bridge/regulator circuit.

@peekay123 I thought I should explain what those are for. Currently that’s the prototype wiring for how I am detecting if the heat is on or off. I am measuring the voltage differential between the power wire and the heat wire. If there is a voltage differential the heat relay is closed, thus the heat is off. If there isn’t a voltage differential the heat relay is open and the heat is on. I have to trouble shoot some issues with that wiring but it was an initial idea. There was a minor ground loop that was causing the LCD screen to bug out, so I added a diode between the regulator and ground which seemed to fix that.

I will try moving the MCP9808 far away for now

So I tried moving the MCP9808 as far as possible on the bread board and am still getting faulty measurements (I can assure you my bedroom is no 83 degrees)

@armashanth, are you ONLY getting a value of 82.85 or does it fluctuate. Looking at the Adafruit_MCP9808 library on the Web IDE, I can see that it isn’t even complete. Are you compiling with the Web IDE or with Particle Workbench?

@peekay123 it fluates quite a bit and also drifts significantly. I am using particle dev, which to my understanding compiles in the cloud.

I reached out to where I sourced the part and they were experiencing similar issues
“Sorry for the issue. I tested one of these myself and was seeing a similar problem. I will say that it started out reading around 83F and settled down to 77F. I still think that’s a bit higher than it should be.”

I wonder if I have to manual calibrate/ add a correction factor as well

@armashanth, the MCP9808 should not need a correction factor and doesn’t need calibration. However, it seems there are registers that contain calibration data that should not be overwritten but could!

image

The “safest” library, IMO, is the Adafruit one which you can get from their github repo. It would needs minor tweaking to work with the Particle environment.

BTW, you may seriously want to consider moving from Particle Dev, which is no longer supported (for a while now), to the VSCode-based Particle Workbench for local and cloud compiling. Workbench is a VAST improvement over Dev.

3 Likes

@peekay123 I may try and move over to using a thermistor for this project instead. Since the MCP9808 hasn’t been as plug and play as I’d hoped I’ll keep it around in case I want to try manually calibrating, but I am not sure if it is worth the effort right now.

Oh that is good to hear about Particle Workbench, are there any tutorials for getting it set up? I installed it but have been unable to reopen it/find it in VS code. I am much more familiar with atom, thus why I choose to use particle dev.

@armashanth, for Workbench, take a look here:

https://docs.particle.io/tutorials/developer-tools/workbench/

I’ve been using the MCP9808 with Xenon for some time now with Romain’s driver. The sensor is very accurate. No calibration is necessary.

A section of my code using the MCP9808:

 mcp.setPowerMode(MCP9808_CONTINUOUS);
    delay(250);
    digitalWrite(D4, LOW);
    previousTime = currentTime;
    Mesh.on();
    Mesh.connect();
    waitUntil(Mesh.connecting);
    waitUntil(Mesh.ready);
    temp = mcp.getTemperature();
    delay(300);