I'm sorry if this is a dull question, I don't know much about electronics (I just started out).
This is what my actual breadboard looks like (cf attachment).
If I put all the components to the GND rail on my breadboard, I am getting wrong and inconsistent readings: 28C to 30C vs 26C as per another standalone close by thermometer.
But if I put the sensor and the LEDs to different GND pins directly on the Arduino (thus bypassing the power rails of my breadboard), then I am getting more accurate and consistent readings.
I suspect this has to do with interference maybe between the digital and analog “parts” of the ATMega or maybe because it's too much wire and catching too much interference?
Either way, I'd like to understand what is happening and what would be the “best practice” answer to this situation?
Thanks,
You are passing current round all that grounding wiring to power the LEDs, so it will drop a little voltage depending on how many are lit.
This little voltage will affect the ground voltage the temp sensor sees... In fact the voltage is probably mainly to do with the connections more than the wires, but all real-world connections and wires have some resistance, so as soon as significant current passes though them the voltage will be affected.
The correct way to wire up is to avoid ground "loops" like this and use a "star" configuration - each off-board device gets a separate ground wire. Certainly you shouldn't share a ground wire between an analog sensor and a high-current output device (well, medium current I suppose).
MarkT:
The correct way to wire up is to avoid ground "loops" like this and use a "star" configuration - each off-board device gets a separate ground wire. Certainly you shouldn't share a ground wire between an analog sensor and a high-current output device (well, medium current I suppose).
Hmm. So I should put every sensor on its own ground line? Maybe I'm missing something out here but there are only 3 GND pins on the Arduino…
Well the key thing is don't share a ground wire between a sensor and a large-current device - so you could use one ground connection for all low power sensors, other wires for large loads....
Assuming the temperature sensor is the popular LM335 or similar, be aware that if you're using it on USB power, the voltage put out by the computer can seriously affect the reading. They are frequently a good way from 5 volts which completely throws the reading on an analogue pin since the reference voltage is the USB voltage. Read the voltage from the 5V rail with an accurate digital meter, and incorporate the actual voltage in your code.Also make sure the reference thermometer is really close by, hanging on the wall next to your bench isn't good enough, the temperature within a room can vary significantly across quite small distances.
The sensor is a MCP9700. I ordered other sensors and thermistors to match them against each other.
I am using an external 12V 0.5mA power supply with the Arduino Uno R3.
hfp777:
I am using an external 12V 0.5mA power supply with the Arduino Uno R3.
Presume you meant 0.5A, or 500mA, not 0.5mA!
Indeed.
I found where the problem was.
The breadboard causes some interference in the readings (I shouldn't use the + and - rails)
A 220 Ohms resistor on the Vdd and a 1uF capacitor between Vout and GND on the MCP9700 filter out the interferences and I'm getting more accurate values