Arduino UNO connected to 16x2 display using the same power source.
I am using a TMP36 to measure temperature and it seemed to be undereading somewhat, but within tolerance, compared to a DS18B20+ on a Raspberry pi beside it.
The Arduino was being powered from a newish 9V battery.
I then powered the Arduino from a computer USB hub and the underreading disappeared.
This got me thinking and I tried powering the Arduino from a collection of various power supplies.
I was surprised by the results.
I have listed the results and the temperatures (degrees c) shewn, 5V, 3.3V pin volts.
9V battery 18.36
Computer USB 19.34
1000mA 9V power supply(1) 19.34 4.9 3.28
1000mA 9V power supply(2) No display 4.4 3.27
2.4A 5V power supply 48.14 3.5 3.3
2.15/1.7A 6-7.5V power supply 27.64 4.37 3.3
I understand that these power supplies can be "not as stated on the pack" and that will probably account for the "no display".
Can anyone explain to me how the readings of circa 48c and 27c come about?
"Update"
I decided to get my multimeter out and check the voltage (since added above) on the 5V and 3.3V pins with nothing connected to the Uno.
I think that is the source of the odd readings.
I will check the maths and see if the errant temp readings are reasonable with the measured voltages.
I'd hate to think what volts you would get if you ran these power supplies at or near their rated amperages!!!
Try using the 3.3V pin as the analog reference - see the documentation for the analogReference function. That will make your reading much less dependent on the power supply.
I am not sure how to tell the Aref pin to not use 5v or does it work it out automatically - ie should I set Aref to external although it is using an internal 3.3v?
The description of Aref doesn't seem, to me, to make this clear.
Sense suggests I should set Aref to external if I want to use 3.3v.
I will test it later.
The adafruit tutorial 12, which is the basis for my experimentation, implies, at the beginning, that you just need to substitute 3.3 for 5, where appropriate.
This gives me negative readings.
Only later does it suggest using an extra connection and calling Aref.
As you may gather, I am a bit of a newbie to this but it is all fascinating stuff to a retired 66 year old!!
To use 3.3V Aref, you connect the Aref pin to the 3.3V pin and you call analogReference(EXTERNAL) in setup(). You must not make any analogRead calls before you have made the analogReference call, otherwise you risk damaging the mcu.
The 3.3V reference may be more stable if you place a light load on it, e.g. 10K resistor to ground.
I had a problem of the temperature being incorrect when using your suggestion (it read +8 when the room temp. is about +19).
Eventually I split the power supplies and ran the LCD off the 5v pin and the TMP36 off the 3.3v pin.
This has cured the problem - I suspect that I was trying to draw too much power from the 3.3v pin.
I have tried the other supplies now and they all work correctly except the 9V supply(2) which doesn't do anything as before - it is now in the "under desk filing cabinet"!!!