AREF

I am using a Current Transformer, wired up as shown on OpenEnergyMon
it uses a 2.5v center point so the AC output has 2.5v as the midpoint.

I want to an LM34 that has a 0-1vdc input and to get higher resolution, I would like to use AREF at a lower voltage for that input.

the reference is a bit confusing.

it seems to say that MUST use analogReference(EXTERNAL)
or you could short out the board,

but it also says you can :switch between external and internal reference voltages."

I would like to use (EXTERNAL) for the LM34 and (DEFAULT) for the CT reading

I understand that a couple dummy calls to analogRead() are needed to clear the residuals. that is typicaly for any ADC inputs.

can anyone clear this external/default up for me ?

.

The way I read it it says that if you have something connected to the AREF pin then you must use EXTERNAL or risk shorting the board. The way I read it you can't have both.

But if it is 0 - 1V you could use the internal 1v1 reference and not need an external one.

can I do this in void loop() ?

void loop() {    
  // this will read the LM34    
  analogReference(INTERNAL) ;
  int dummy = analogRead(2);
  dummy = analogRead(2);
  int lm34volt = analogRead(2);
  
   // this will read the thermistor
  analogReference(DEFAULT) ;
  int dummy = analogRead(3);
  dummy = analogRead(3);
  int thermistor = analogRead(3);

That should work as long as you're double reading like that. Definitely wouldn't trust the first read.

dave-in-nj:
I want to an LM34 that has a 0-1vdc input and to get higher resolution, I would like to use AREF at a lower voltage for that input.

Note that the practical range with the LM34 and 1.1volt Aref is ~5F to ~105F.
I explained in another post how to extend the upper range with a resistor and/or the lower range with a diode.

dave-in-nj:
...the reference is a bit confusing.
analogReference() - Arduino Reference

it seems to say that MUST use analogReference(EXTERNAL) or you could short out the board,

but it also says you can :switch between external and internal reference voltages."

IF you use an external voltage on the Aref pin AND you forget to switch to EXTERNAL in your code, the internal and the external voltage will short each other out.
If you use a >5k current limiting resistor, it's ok to do that.
So a resistor is needed if you want to switch from internal to external in your code.
Leo..

dave-in-nj:
can I do this in void loop() ?

void loop() {    

// this will read the LM34   
  analogReference(INTERNAL) ;
  int dummy = analogRead(2);
  dummy = analogRead(2);
  int lm34volt = analogRead(2);
 
  // this will read the thermistor
  analogReference(DEFAULT) ;
  int dummy = analogRead(3);
  dummy = analogRead(3);
  int thermistor = analogRead(3);

Better if you use always the internal reference and use a voltage divider for the thermistor.

Cheers, Ale.

Wawa:
Note that the practical range with the LM34 and 1.1volt Aref is ~5F to ~105F.
I explained in another post how to extend the upper range with a resistor and/or the lower range with a diode.
IF you use an external voltage on the Aref pin AND you forget to switch to EXTERNAL in your code, the internal and the external voltage will short each other out.
If you use a >5k current limiting resistor, it's ok to do that.
So a resistor is needed if you want to switch from internal to external in your code.
Leo..

I started this thread because there is a dearth of information on how to change AREF in void loop()

I have 3 analog inputs. two need the full 5v range and the LM34 has the smaller 1 volt range.
I was hoping to be able to switch between the internal 1.1v and internal 5v, but it is not as simple as calling which you want to use and to jump back and forth in the program.
when used in void setup() it is stable when I tried to use it in the program, it was flaky.
it may need a lot of time to settle, have not tried it with a long duration settling time.
as a note, it seems the LM34c has a -50 to +300 v range and +/-0.6 F
the TMP36 has a horrible accuracy +/-2C but costs less and is more available.

I was hoping to be able to switch between the internal 1.1v and internal 5v, but it is not as simple as calling which you want to use and to jump back and forth in the program.
when used in void setup() it is stable when I tried to use it in the program, it was flaky.
it may need a lot of time to settle, have not tried it with a long duration settling time.

I switch back-and-forth between 1.1 and 5V to get an auto-ranging feature with my sound activated* lighting. I'm not having any trouble...

I'm reading "slowly" at about 10 times per second, and the range only changes infrequently when necessary.

(The tricky thing about my particular application is that I have some variable software references and thresholds and I'm keeping a short-term moving average and the short-term peak, so all of that has to be re-scaled up or down whenever the range changes.)

*I'm using a peak detector circuit, so the Arduino never sees the AC audio signal and I don't have to bias the input at 2.5V.

dave-in-nj:
...it may need a lot of time to settle, have not tried it with a long duration settling time.

as a note, it seems the LM34c has a -50 to +300 v range and +/-0.6 F

the TMP36 has a horrible accuracy +/-2C but costs less and is more available.

You might be right there. I have seen delays used after default/internal change.

300F is only possible with a 3volt Aref, because the sensor output is 3volt (10mV/F)
In previous posts I recommended a 10k resistor from 3.3volt to the Aref pin.
That gives 2.5volt Aref, and an upper sensor range of 250F.
With 10k you can safely switch between default, internal and external (see the Aref help page).

The TMP36 is perfect for outdoor temp measurements.
It has a practical range of -40C (-40F) to +55C (+131F) with 1.1volt Aref.
Don't confuse accuracy with stability. Calibration fixes accuracy.
The TMP36 with the right code should read to 0.1F
Leo..

Wawa:
Don't confuse accuracy with stability. Calibration fixes accuracy.
The TMP36 with the right code should read to 0.1F
Leo..

resolution of the sensor is key. if it cannot detect a change of 2 def F, then it will not have an output.

you have both an increasing slope and decreasing slope. although much less pronouned with electronical things.
if you start at 70 deg and allow the space to cool to 50.000 degress and the sensor reports 51 degrees ....
and then you cool to 20 and raise the temp to 50.0000 and the sensor reports 49, you have a whole diferent problem than if you

cool from 70 to 50.000 and get 51.037
then heat from 20 to 50.000 and get 51.037

All these LM/TMP sensors are analogue.
You can display the temp to ten decimal places if you want to.

Granularity (steps) are introduced with an A/D converter.
Arduino has a 10-bit A/D, so the temp range you work with is chopped into 1024 steps.

You can't display 50.000F (0.00x accuracy) with a 10-bit A/D.
Because that would require an A/D with a minimum of 50000 steps (16-bit A/D).
You can display 50.3F, or 100.6F, because that's within the capability of a 10-bit A/D.

Smoothing (taking many samples) could increase granularity to some extend. Maybe to two decimal places.
But do you need more than one decimal place.
Do you have the gear to calibrate to that percentage.
What about self-heating, mouting bracket, wind, sensor linearity, etc.
I think a 10bit A/D, and reducing fahrenheit readings to one decimal place (after calibration) is all you need.
leo..

Wawa:
What about self-heating, mouting bracket, wind, sensor linearity, etc.
I think a 10bit A/D, and reducing fahrenheit readings to one decimal place (after calibration) is all you need.
leo..

wind has no effect on temperature except to shed heat. if the device is not self heated, wind is not an issue.
as for as accuracy, 1.0 deg F would be great. in my mind, to have an accuracy to withing 1 degree, you must be able to sense to within 0.1 degree.
if the temp is 50.000
and my sensor has a sensitiviy of 0.1, I could read 49.9, or 50.1 and be within 0.2 degrees.
if the sensitivity is 1.0m then it could be 49.5 to 50.5 before the granularity would show the change.