Analog Pins always reading 1023

Hello

I can't figure out why but my analogPins are always reading 1023. I tried using a multimeter to read the voltage but it's 4.96V or less on the circuit with the resistor and 5.01V at the source. I don't get why the deal is. The interesting thing is if there is nothing plugged into the pins they read out about 3.3V except analog pin 1 which is closer to 1.6V.

Anyone have any ideas?

Thanks
Sam

There's no such thing as "nothing". There's stray electric fields all around us.

Ground an analog pin - wire it directly to one if the GND pins on the Arduino. If analogRead() doesn't give 0-2 as the value then your analog pin is broken.

DomoArigatoMrRoboto:
...it's 4.96V or less on the circuit with the resistor and 5.01V at the source.

This does not make sense to me.
Post your circuit.
Leo..

You should not have any resistors in the circuit for measuring 5V.
What is the voltage on your 5V line, that sets the value for a "full house" reading.

Yes post your circuit.

Connect your analog input pin to the arduino ground (0V) with a 10k resistor. Switch it on and expect to see near 0 ad output from your test program. With a 10k in place, you can safely prod around without having to switch things off: for example running a second 10k from that same ad in to +5V sets up a potential divider. If you have a spare volume control knob or equivalent you can test with those too. You should be able to see sensible ad values from these tests.

If an ad pin is not connected then formally its value is "undefined" so your 3.3V and 1.6V are doing what ad devices usually do. They might 'float' around unpredictably too.

Don't worry that 4.96V hits the top of the ad range. That is what the ad will usually do. I think that you want to make your signal analog voltage smaller rather than make your ad range larger than 5V. Potential dividers are a sure safe bet. I also used zeners to "subtract 20V" from a 25V twin car battery as 20 to 30 V was an acceptable range for that application.

Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png or pdf?

Can you please post a copy of your sketch, using code tags?
Please use code tags.. See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html

Tom.... :slight_smile:

Thanks for the replies. I'll try to send a more exact circuit diagram and sketch this evening but it looks like
5V -- 22k resistor -- A5 -- thermistor -- GND

The code is simply doing:
Serial.println(analogRead(A5));

The final project is trying to do this:
http://hruska.us/tempmon/

The schematic is at the bottom and the circuit is that going to the analog pins.

So what is the resistance of your thermistor? If it is too high then that are the results you will get.
Normally the resistor should be the same resistance of your thermistor at normal temperature.

Grumpy_Mike:
So what is the resistance of your thermistor? If it is too high then that are the results you will get.
Normally the resistor should be the same resistance of your thermistor at normal temperature.

I'm at work where I cannot view google docs but I believe this is the full datasheet.

OK thought so. At 20 degrees C it has a resistance of 250K. Have you worked out what voltage that will give you with a 22K resistor? Not far from what you are reading.

Grumpy_Mike:
OK thought so. At 20 degrees C it has a resistance of 250K. Have you worked out what voltage that will give you with a 22K resistor? Not far from what you are reading.

Forgive my newbie question but how would I calculate that?

I stuck the thermistor in my hand before and I didn't see much change. I also put it close to direct heat from my stove top but again I didn't see much change. But I guess in both cases I really didn't get the probe below the 100k mark. I can try this again or try sticking the probe in the oven and bring the temp up to 100C wh in brings it to about 22k.

However I don't fully understand the math behind this but it seems you're saying I got to get the temp higher to properly read the thermistor. Is that correct?

It is a simple voltage divider:
5V / (22,000+250,000) * 250,000 = 4.59V

Forgive my newbie question but how would I calculate that?

See

However I don't fully understand the math behind this but it seems you're saying I got to get the temp higher to properly read the thermistor. Is that correct?

No. I am saying you have to use a resistor that is the same value as the thermistor has at the mid temperature you want to use. If the resistor and the thermistor are the same value then you will get a reading of about 512. If you don't then you have wired it wrong.

We still don't know the temperature (range) of interest.
Is this for homebrew?
Did you use the sensor in a liquid.
Yes, double posting confuses things.
Leo..

The resistor is about right according to the datasheet. Smoked should run at around 225F.

I'll try the setup as is in the oven tonight. Thanks!

I had a similar issue - getting random readings from the analog inputs when I had nothing connected to them. According to the Sparkfun tech support,

"When analog inputs are not connected to anything we call this a floating input. When an input is floating, it will pick up all sorts of stray noise from static electricity in the air, noise from the atmega chip, or even from radio waves in the area. That's why you are seeing random data on your inputs with nothing connected. Just moving your hand around those pins will even cause the reading to change."

Also, to fix this they say,

"All you need to do is connect a high value (10K to 100k) resistor to each input and ground.That will create a weak force that keeps each input at 0 volts, but is weak enough so that when you connect an input voltage to one of those pins, the atmega will still be able to see it."

Does that help?

Ok I did the oven experiment. Oddly if I run a basic sketch that just uses a copy and past of the overall project sketch it's correct. The project sketch is wrong however.

What is that supposed to mean?

It means he won't show us the code which is not working.

The code was posted earlier. I'll just post the two sketches to the thread in full with my changes. The main difference is how the thermistor_temp function is called.