Hi!
Which, if any, of these two method is best for supplying power to an Arduino Uno board; a power adapter or a 9V battery.
A reason for this question is that I'd like to find out if switching to an external power supply would affect the accuracy/reliability of the temperature readings from my LM35DZ and TMP36 temp sensors.
If you mean the PP3 style of 9v battery that is used in smoke alarms then it is totally unsuitable for an Arduino. They cannot provide enough current and would run flat very quickly.
A pack of 6 x AA alkaline cells would be a suitable 9v power supply.
It's not clear whether you are planning to use the Arduino on battery power some times and on mains power at other times and want to get identical analog readings from a sensor. If so you will need to do some tests and see what happens.
If you provide a stable reference voltage on the Vref pin you will avoid any problems. You can get ICs that provide stable voltages.
Thanks for answering!
I was planning on buying a 9V battery [PP3] along with a battery holder and 'barrel-type connector, but you think something like this will suffice?
LM35 and TMP36 sensors are best measured with a low reference voltage, to get some useful (0.1C) temp resolution.
An uno has a ~1.1volt reference buildin. Using that makes the sensor also less dependent of power supply voltage.
Example sketch attached. Uncomment the relevant line for the type of sensor used.
Leo..
// LM35_TMP36 temp
// works on 5volt and 3.3volt Arduinos
// connect LM35 to 5volt A0 and ground
// connect TPM36 to 3.3volt A0 and ground
// calibrate temp by changing the last digit(s) of "0.1039"
const byte tempPin = A0;
float calibration = 0.1039;
float tempC; // Celcius
float tempF; // Fahrenheit
void setup() {
Serial.begin(9600);
analogReference(INTERNAL); // use internal 1.1volt Aref
}
void loop() {
tempC = analogRead(tempPin) * calibration; // use this line for an LM35
//tempC = (analogRead(tempPin) * calibration) - 50.0; // use this line for a TMP36
tempF = tempC * 1.8 + 32.0; // C to F
Serial.print("Temperature is ");
Serial.print(tempC, 1); // one decimal place
Serial.print(" Celcius ");
Serial.print(tempF, 1);
Serial.println(" Fahrenheit");
delay(1000); // use a non-blocking delay when combined with other code
}
One day you will discover the easier to use digital DS18B20.
Robin2:
Yes
I have some FAN431 chips "The output voltage can be set any value between V REF (approximately 2.5 volts) and 36 volts with two external resistors."
I'm sure there are many similar devices on the market.
Robin2:
I have some FAN431 chips "The output voltage can be set any value between V REF (approximately 2.5 volts) and 36 volts with two external resistors."
I'm sure there are many similar devices on the market.
Yes, the TL431.
But 2.5volt Aref is too high for an LM35, and even too high for a TMP36.
Anything more than ~1volt Aref looses resolution.
Leo..