Trouble using NTC thermisistor

I’ve gone through the very-very long post but nowhere does it address the reversing of the thermistor behaviour.
I have the exact same problem and I’m using the photon-thermistor library with their sample code and I’ve tried 2 different sensors, on various different pins, all with the exact same result and the temperature readings are more than double.

Hi Rickkas,
unfortunately I don’t have the immediate ability to connect via USB for this. Surely I could publish the results to the cloud for a screenshot?

Also, I’m using a NTC 10K Thermistor (@25°C) for my testing.

Why don’t you show us a picture of how you have hooked it up?

You could also share the code you have written so we can help debug that too.

Sorry for the delay.
So here goes, just so there’s no confusion on what sensor I’m using:
NTC 10kOhm (@25°C)

One end is connected to V3.3 and the other end to A3 which is pulled down with a 10K resistor to GND as instructed.

For the photon, the Photon-Thermistor library indicates the following:

    * Particle constructor, sets defaults: vcc=3.3, analogReference=3.3, adcMax=4095
    * arg 1: pin: Photon analog pin
    * arg 2: seriesResistor: The ohms value of the fixed resistor (based on your hardware setup, usually 10k)
    * arg 3: thermistorNominal: Resistance at nominal temperature (will be documented with the thermistor, usually 10k)
    * arg 4: temperatureNominal: Temperature for nominal resistance in celcius (will be documented with the thermistor, assume 25 if not stated)
    * arg 5: bCoef: Beta coefficient (or constant) of the thermistor (will be documented with the thermistor, typically 3380, 3435, or 3950)
    * arg 6: samples: Number of analog samples to average (for smoothing)
    * arg 7: sampleDelay: Milliseconds between samples (for smoothing)
    Thermistor(int pin, int seriesResistor, int thermistorNominal, int temperatureNominal, int bCoef, int samples, int sampleDelay);

With that in mind, I’ve used their sample code as follows:

#include <photon-thermistor.h>

Thermistor *sensorA;

void setup()
    sensorA = new Thermistor(A3, 10000, 10000, 25, 3950, 5, 20);

void loop()
    double tempC = sensorA->readTempC();
    Particle.publish(String("A3 Temp Reading"), String(tempC) + "°C");

So the code “works” in the sense that I get some reading, but the value is way too high and when I apply higher temperatures to the sensor, the value goes lower.

Any ideas?

Thanks for the thread split

So higher temperatures to the sensor causing lower values probably means that the library wants your sensor on the low-side of the voltage divider instead of the high side.

That would mean that the 10k ohm fixed resistor goes between A3 and V3.3 and the thermistor goes between A3 and GND.

There might be a way to change the library for high-side vs low-side, I haven’t looked.

1 Like

If you look at the GitHub repo of the library you can see a breadboard image and the suggested wiring note

In Web IDE you can usually find the source repository by clicking the GitHub icon


@ScruffR THANKS!!!
Finally working!
Wiring wrong, entirely different to all other examples out there.
Consider this case solved!!!

(for future visitors)

The sensor needs to be wired this way:



Hello! I’m doing essentially the same thing but wrote all my own code. Not using a library. I retrofitted an existing thermal solar panel that’s about 100’ from my house and was using an old goldline differential controller.

I wired up the Photon to activate the pumps when a certain differential was reached and to fire up my boiler to heat my hot water storage tank if we had a cloudy day.

All works well and I can monitor/control over the internet.

But I have now lost two Photons, I’m assuming, by exposing the uP pins directly to the long run of wire out the 10k sensor bolted to the thermal solar panels. The analog pin gets stuck reading the equivalent of about 38 degrees F.

Anyone have a circuit that could provide some protection to the A pins without distorting the analog read?

I looked up the part number for your pump relay and they look like a traditional magnetic coil relay. If that’s true, you are missing the reverse coupled “free wheeling” diode that prevent the collapsing magnetic field from generating a killer voltage spike on your Photon pins. Your other relay is optically coupled, and in fact using an opto-isolator on your pump relay would be a good idea too.

It could also be the thermistor long wires, in which case I would recommend at least back to back zener diodes with a 3.3V rating to ground or similar. There are entire books written on signal conditioning so it’s hard to write down everything you could try for the 100’ wire and 10k NTC thermistor, but the zeners will prevent the worst problems.


@bko Thank you so much for looking at this! I really appreciate the resource of the community.

I evolved from a SSR to the mechanical relay CPC1017N because of possible V spike from the pumps. Never thought about the coil in the relay.

The PN for the MOSFET relay driver is missing. It’s a NTR4003N which has back to back zeners from gate to source. Supposedly this MOSFET provides ESD protection to the gate. No idea if it can mitigate a spike from the relay coil.

Anyway, I’m losing pin 12/A0 (connected to 100’ of underground wire) so I will grab a couple zeners and try what you suggest. Fortunately this has only happened twice in three years so may be a while before any results are in…

As a side note, on long wires a thermistor is not usually the best choice because the measured resistance, turned into voltage by the voltage divider, varies depending on the length of the wire. For long-distance temperature sensing, using a 4-20mA current temperature sensor is usually preferred because the current does not vary depending on the wire length even though the resistance does. No need to reengineer your circuit if it’s working well enough, but just something to keep in mind.


I have hundreds of 10K NTC thermistors in the field, often in electrically noisy environments with long runs at times and have lost maybe 1 port. The one thing I did that I felt might be helpful was to put a 0.1 uF capacitor across each 10K pull-down resistor to shut transients to ground. I can’t honestly say if this is a “good” idea, but may explain why I’ve haven’t had issues.

1 Like