How to get zero on analogRead


I’ve the following Setup:

I’ve read the Topics about reading analog values, but they don’t answer my question.

If I attach termistors to the shown 2.5mm audio jacks the readings I get are valid. The question I have is how to detect that no thermistor is attached.

I get readings arround 800 on Inputs A0 - A3 when no thermistors are connected. I tried reading from the analog Inputs without anything connected (empty spark) and get readings arround 2000. Shouldn’t I get zero?

Thanks for some advice.

Kind regards

Hi @dromero

The input impedance of the Spark ADC is much lower than that of say an Arduino UNO ADC so your 10k resistors to ground are not enough to pull the input completely low.

If you could substitute 1k resistors you would get 0, but your thermistors might not like that. You could also buffer the inputs with op-amps but that would certainly add extra cost.

I would try to find the smallest resistor that meets your needs and does not upset your thermistors too much.

1 Like

Thanks @bko. So if I understand you right, if i’d where using a smaller resistor 1k, then i’d get zero. What about the 2000 values i’m reading when nothing is connected? How does the spark mobile app detect that nothing is connected?

Is my understanding wrong that i’d get zero when i directly connect the analog Input to the ground?

Does the Photon change in respect of Input impedance?

I’m using 100k resistor at the moment but will soon change the thermistors to one which are compatibel with 10k…

I hope that with the 10k resistor the value will be low enough to be sure that it can’t actually be a temperature which can be measured while cooking

The input impedance of the ADC depends on the mode it is programmed in, but it is currently around 40k. So your 10k thermistor should be OK.

Another thought is that a lot of headphone jacks have a built-it switch to detect when something is plugged in. That would be super reliable.


@dromero: In your current configuration if you connect the input of the audio jacks to ground you should read 0 on on the Spark Core. Is that not happening?

If that is happening, it sounds like your problem is what when nothing is connected you don’t get zero volts as you were expecting given your pull down resistors. If your pulldown resistors are too large (high impedance) then you will get the result you are seeing. As @bko suggested, you probably need lower value pull down resistors