I am trying to read volatges (below 5V) from a device , my meter is showing 3.7 as it should be, but arduino is showing differnt some timw 4.6 v some time 0.00 etc. Want to know what went wrong
I moved your topic to an appropriate forum category @pyal_p.
In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.
This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.
Thanks in advance for your cooperation.
Just a guess, I'd bet the voltage source and the Arduino input don't share a common ground.
Oh yeah, did you notice:
Show yor code (not an image) in code tags
Also a schematic of your conection
Delete row 13 from your code.
What Arduino and what is Vcc?
If you have a 10-bit ADC maxed-out at 1023 your calculation will give 4.6V so it looks like you are at or above Vcc (the default ADC reference).
OK,
I will do that
My code
'
int analogPin = A3;
float val1=0.0;
void setup() {
Serial.begin(9600);
pinMode(A3, INPUT);
//pinMode(13, OUTPUT);
//digitalWrite(LEDOUTPUT, OUTPUT);
}
void loop() {
val1 = (analogRead(analogPin) * 0.00454); // read the input pin
Serial.println(val1);
}
I am sourcing the voltage from voltage supplier device. max voltage i am giving is 5v and minimum 1 v. when it is 5V i am getting 4.64 in Arduino, but when i give any other between 1v and 5v i am not getiing, sometmes it is showing 4.6 , sometime 0, sometime 2 etc etc. Please help. I need to know what is wrong. Meter is showing correct value
you are Right Sir, they have different ground
Thank you
I am using Arduino Uno Rev3 , No problem when I am giving 5v to pIn , but whenI am giving anything less then 5 v say between 1 v and 5v , getting different value
it is not there actually typo mistake while posting this code
That's why it's not working, you need common gnd, the code is ok.
I did GND the board and it is working now, I saw your post now. Anyways thank you a lot.
Thank you everyone.
? What, did you think I was joking? This is a very common mistake made by posters on this forum. We probably see at least one a day.
They are happy to connect their multimeter using two probes, but expect an Arduino to measure voltages with just one connection.
The GND connection is analogous to having the black probe connected.
I forgot to ground teh arduino from teh smps. I did that and it was working fine. and you are also correct , after I saw your post I was happy that you also pointed outthe same thing. Thank you Sir
This is how your code looks properly formatted and posted using code tags:
int analogPin = A3;
float val1 = 0.0;
void setup() {
Serial.begin(9600);
pinMode(A3, INPUT);
//pinMode(13, OUTPUT);
//digitalWrite(LEDOUTPUT, OUTPUT);
}
void loop() {
val1 = (analogRead(analogPin) * 0.00488); // read the input pin
Serial.println(val1);
}
Gee I get the same thing. How about this. You have a 10 bit ADC in your Arduino Uno so 0 to 5.0 volts becomes 0 to 1023 bits. Here is where I see a problem. Why do you use
With a 10 bit system and assuming your Vref is 5.00 volts things should look like 5.00 / 1024 = 0.0048828 but you are using 0.00454 rather than 0.00488. Again, this assumes a 5.00 volt reference and your Arduino Uno uses Vcc for the A to D analog reference. So with an ideal reference you should be seeing 5.00 volts with a known good 5.00 volts applied. Change your code to read:
void loop() {
val1 = (analogRead(analogPin) * 0.00488); // read the input pin
Serial.println(val1);
Things should read correctly. Now that your grounds are fixed.
Ron
Noted.. Thank you
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
