Hello everybody, this my first topic here in the forum, i've always been only a reader.. feel happy to interact
well let get to the problem, i'm using my arduino uno card to read an analog voltage from the A0 pin and print it using the serial monitor, i've tested if it's working by attaching the A0 pin to the 5V pin in the card and it worked - showed me 5V in the screen - and also the ground pin and showed me 0V. but when i've tried to use it to read a voltage that i've already checked using a voltmeter ( around 4.2V ), it gives me a wrong read ( print around 0.6V in the screen ).
i'm still wondering where the problem might be.. here's the code i've used
Nafie92:
i'm using my arduino uno card to read an analog voltage from the A0 pin and print it using the serial monitor, ... it gives me a wrong read ( print around 0.6V in the screen ).
i'm still wondering ...
void setup() {
Serial.begin(9600);
}
void loop() {
int sensorValue = analogRead(A1);
float voltage = sensorValue * (5.0 / 1023.0);
Serial.println(voltage);
}
Why are you testing A1 if you're connecting to A0 ?
And did you see the difference between using the code tags and not ?
Use code tags !
Nafie92:
i'm using my arduino uno card to read an analog voltage from the A0 pin and print it using the serial monitor, ... it gives me a wrong read ( print around 0.6V in the screen ).
i'm still wondering ...
void setup() {
Serial.begin(9600);
}
void loop() {
int sensorValue = analogRead(A1);
float voltage = sensorValue * (5.0 / 1023.0);
Serial.println(voltage);
}
Why are you testing A1 if you're connecting to A0 ?
because first i taught that the A0 pin is damaged or something, that's why i've changed it to the A1 pin but still it's always the same problem.. and i forgot to change it in the code
And did you see the difference between using the code tags and not ?
Use code tags !
mm i'm a newbie in the arduino programming, what code tags are for ?
thx for replying
And did you read that 4.2 between the analog pin and ground, or accidentally between
the analog pin and +5V??
The things that will cause a difference between a multimeter and an ADC reading are
source impedance (is the voltage source stiff enough?) and any AC signal present
atop the average voltage (multimeters average over a long timescale, a second or more,
the ADC reads a snapshot taken in 6 microseconds...
You can look for AC signals by switching the multmeter to AC - if the reading there is zero
then its fairly likely the signal is steady (although very high frequencies will completely
confuse a multimeter).
MAS3:
Hi again.
Code tags don't relate to programming, they do relate to correct use of the forum. Read this (click!) to find out more about that.
ok got it!
Can you read the voltage using your multimeter again at the Arduino's pins to check you've still got that 4.2 volts ?
i'm using the arduino card to read the voltage sent from a CNY70 that i've fixed to 4.2 volts using my multimeter by changing the distance between a white paper and the sensor and tried to read it with my arduino card to check if that's working so that i can move to something else.
i've tried to change to 3 volts and 1.5 volts and still the arduino card won't read it, it just gives me random numbers around 0.8 volts
MarkT:
And did you read that 4.2 between the analog pin and ground, or accidentally between
the analog pin and +5V??
between the analog pin and ground
The things that will cause a difference between a multimeter and an ADC reading are
source impedance (is the voltage source stiff enough?) and any AC signal present
atop the average voltage (multimeters average over a long timescale, a second or more,
the ADC reads a snapshot taken in 6 microseconds...
it's a signal sent from a CNY70 sensor that i tried to read, and its steady enough to be readed by the arduino i guess
You can look for AC signals by switching the multmeter to AC - if the reading there is zero
then its fairly likely the signal is steady (although very high frequencies will completely
confuse a multimeter).
no it's not an AC signal
I dug up a datasheet to see what component exactly.
I expected an optocoupler and found out it is an object detector similar to an optocoupler.
That means it doesn't output a voltage, it is a switch.
You need to use more components (at least 1 more) to do what you want to do.
Therefore: show us some drawing or a picture showing what you made, and how the components are wired.
Don't be disappointed, you don't need to build some difficult circuit.
But for us to offer the correct answer you will understand, we first need to see what you already know.