Hi guys. how can I correctly reading a 5v analog sensor with INTERNAL reference ?
when I used blow code always showing 1023 at serial output.
int analogInputPin1PA = A1;
float vAnalogValue1 = 0;
void setup()
{
analogReference(INTERNAL);
Serial.begin(115200);
}
void loop()
{
vAnalogValue1 = analogRead(analogInputPin1PA);
delay(1000);
}
The reference voltage determines the range of measurement that is possible,
the Arduino will return 1023 for any voltage equal or above.
Use a voltage divider to scale your input range to below reference voltage.
Added:
I think analogInputPin1PA is a strange and useless name,
sensorPin or the like would make more sense to me.
Why do you want to use float for the analog value?
The presented code does not produce any output.
And, "blow code " is a really nice typo.
1 Like
Why would you do that?
You cannot exceed the reference voltage with your signal voltage. Your reference voltage is 1.1v.
Wawa
July 11, 2022, 10:56am
4
ErfanDL:
float vAnalogValue1 = 0;
The A/D returns an int.
int vAnalogValue1;
Which sensor.
There could be gremlins when changing from a ratiometic 5volt A/D to an absolute 1.1volt A/D.
Yes, you can still safely put up to VCC (5volt?) on the pin.
But with Aref switched to internal (~1.1volt), anything above that will return 1023.
Leo..
red_car:
Why would you do that?
To get a reading that is not influenced by VCC fluctuations?
Wawa
July 11, 2022, 11:10am
6
That depends on the type of sensor.
A ratiometric sensor (like a pot) has a stable readout with default Aref,
but gets influenced by VCC fluctuations when used with 1.1volt Aref.
Other (absolute/voltage) sensors are stable on 1.1volt Aref, and unstable on default Aref.
Leo..
I just answered your question, why someone would use INTERNAL.
I have no clue if that is a valid reason for the OP.
thanks guys. the problem with the divider is solved
system
Closed
January 7, 2023, 12:36pm
9
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.