I am trying to measure the temperature from four MCP9700AE temperature sensors (http://www.digikey.ca/product-detail/en/microchip-technology/MCP9700A-E-TO/MCP9700A-E-TO-ND/1212508) using an ATMega 2560 microcontroller. However I get different temperature readings depending on which 5V input on the board and which ground on the board I use. I measured the potential difference between the 5V inputs and grounds using a multi-meter and they are all the same. So I don't understand why the temperatures are different. Anyone have any ideas?

By the way I tested this using two different AT Mega 2560s and the results were the same.

So I hooked up a 10 DOF sensor that has a temperature sensor as well to the ATMega. (https://www.adafruit.com/product/1604)

This chip requires an SDA and SCL connection. Now all the temperature sensors give 21 C temperature reading. Not sure what this modification does as I didn't change anything for the MCP9700A.

  • \$\begingroup\$ Have you tried reading the voltage on the same input multiple times. I once found that reading the voltage directly after switching inputs is unreliable but if I read it a second time, the voltage is OK. \$\endgroup\$ – Bimpelrekkie Jul 11 '16 at 14:44
  • \$\begingroup\$ What about each pin's average? \$\endgroup\$ – Bort Jul 11 '16 at 14:47
  • \$\begingroup\$ The pin averages all match for each ground and voltage input, I have tried it multiple times, yet the problem persists. \$\endgroup\$ – user3897744 Jul 11 '16 at 14:57
  • \$\begingroup\$ How different are the voltages / temperatures you measure ? What are the voltages ? Does the voltage read by the ADC match what you measure with a multimeter ? You have to provide more details. \$\endgroup\$ – Bimpelrekkie Jul 11 '16 at 15:06
  • \$\begingroup\$ The temperatures I got were 24 C, 30 C and 50C, so they are widely different. The multimeter measures 5V between any ATMega 5V output and ground on the AT Mega. \$\endgroup\$ – user3897744 Jul 11 '16 at 15:09

So I hooked up a 10 DOF sensor [...] Now all the temperature sensors give 21 C temperature reading. Not sure what this modification does as I didn't change anything for the MCP9700A.
when I remove Vin to 10DOF chip, problem starts up again [...]

From these updates in the question and subsequent comments, this behaviour fits with insufficient decoupling on the 5 V power supply to the MCP9700A devices.

The reason that adding the Adafruit 10 DOF module makes the MCP9700AE readings correct, could be because that Adafruit module includes at least one capacitor on the 5 V rail, as the input capacitor to its onboard LDO regulator (see red arrow below). So one side-effect of connecting this Adafruit module to the 5 V supply from the Arduino (which also powers the MCP9700A devices) is that it adds this extra capacitance to that power supply rail.

Adafruit 10DOF module with power input capacitor marked
original image source

Therefore, based on the results seen, I suspect that noise on the 5 V power supply to the MCP9700A devices could be the cause of the erratic readings. And connecting the Adafruit module adds enough capacitance to that 5 V supply to reduce noise and prevent the erratic readings from those MCP96700A devices.

Further confirmation would be possible, by adding only decoupling capacitor(s) to the 5 V power rail instead of connecting that Adafruit module, and seeing the same stable readings from the MCP9700A.

  • \$\begingroup\$ Good points. I didn't even look at the module when writing my answer. \$\endgroup\$ – Transistor Jul 11 '16 at 21:02
  • \$\begingroup\$ @transistor - Thanks. I think we both realised that the power supply voltage at the device was likely to be involved - but from different "angles" :-) I've seen similar situations with debuggers e.g. system works only with debugger attached, and it later turns out that its the capacitor inside the debugger across the target device's power supply which is making the original system work. Remove the debugger (including its capacitor across the target supply) and there was insufficient decoupling for the target system to work! With an oscilloscope, it would be easier to debug these issues. \$\endgroup\$ – SamGibson Jul 11 '16 at 21:13

enter image description here

From the datasheet we can calculate the expected output voltage.

The DC electrical characteristics show that for the MCP9700A

  • \$ T_C = 10~mV/°C \$.
  • \$ V_{0°C} = 500~mV \$.

From this we can calculate that at your room temperature of 22.3°C the voltage you measure between \$ V_{OUT} \$ and \$ V_{SS} \$ should be as follows:

$$ V_{OUT} = 10m \cdot 22.3 + 500m = 223m + 500m = 723~mV $$.

  • Check your voltages at the pins of the chips. All should give the same output. Note that the MCP9701 has a different output coefficient and 0°C voltage.
  • While you're at it, check the supply voltage reaching the chips. It must be between 2.3 and 5.5 V.

These tests will show you if you have an analog problem with the sensors or a digital problem with your micro.

Report back.

  • \$\begingroup\$ I get 28 C and measure 800 mV. All the outputs differ slightly, one is 804 mV, 830 mV, 803 mV. \$\endgroup\$ – user3897744 Jul 11 '16 at 17:40
  • 1
    \$\begingroup\$ You get 28°C where? You get 800 mV where? On one sensor? On all sensors? You need to be specific about what you are measuring and put at least as much effort into your questions as I've put into the answer. If your sensors are in a 28°C environment you should get \$ 10m \cdot 28 + 500 = 780 mV \$ so you're 2°C out in your readings (2 x 10 mV). Datasheet says "±2°C (max.), 0°C to +70°C (MCP9700A/9701A)" so that plus the uncertainty of your 28°C reference reading seems OK. Now you need to look at how you've connected them to your micro. OK. I see you've updated your comment to give more detail. \$\endgroup\$ – Transistor Jul 11 '16 at 17:46
  • \$\begingroup\$ If you have some heatsink compound stick them all onto the same piece of metal to even out the temperatures and measure again. \$\endgroup\$ – Transistor Jul 11 '16 at 17:49
  • \$\begingroup\$ 28 C for Analog pin 0, and 800 mV when I measure the potential difference between that pin to ground. 29 C for Analog pin 1, and 804 mV when I measure the potential difference between Analog Pin 1 and ground. 31 C for Analog pin 2, 830 mV when I measure potential difference between Analog Pin 2 and ground. 28 C for Analog Pin 3, 803 mV when I measure the potential difference between Analog Pin 3 and ground. I see that there is a +/- 2C margin. Thats fine, but the room is not 28 C, it feels cold, also a different temperature sensor I use tells me that it is 21 C. \$\endgroup\$ – user3897744 Jul 11 '16 at 17:55
  • \$\begingroup\$ I do not have heat sink compound, right now everything connected on a breadboard. \$\endgroup\$ – user3897744 Jul 11 '16 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.