20X2 with Thermistor for NXT

A while ago I got 4 100k thermistors. Because they are 100k, I can’t really use them on the NXT ADC with the built-in 10k pullup. The 20X2 doesn’t have pullups (actually it does have optional pullups on some pins), so I connected a thermistor to one of it’s ADCs with a 100k pullup.

Here is the schematic of the 20X2 with the thermistor:

I got the thermistors second-hand, so I don’t really know what brand or model they are. I think I might have found the brand and model, but I can’t be 100% sure. Based on the guess information, I got the datasheet. I implemented the values into a modified version of Xander’s ROBOTC drivers for the DI thermistor, and ended up with a fairly decent turnout. To be honest, I was quite surprised by the results. I really don’t understand all about those calculation values and all that, not to mention I took them from an unconfirmed datasheet. Comparing the values to a thermometer, I get results within 1 degree C or so across a range of about -15 to 26 degrees (all I have tested so far). Actually, it is typically within about 0.5 degrees Celsius.

Here is the NXC code that converts the RAW ADC value (from the 20X2) into degrees Kelvin:

float RtRt25;
float lnRtRt25;

RtRt25 = RAWADCvalue / (1023 - RAWADCvalue);
lnRtRt25 = log(RtRt25);

temp = 1.0 / ( 0.003354016 + (0.0002460382 * lnRtRt25) + (0.000003405377 * (lnRtRt25^2)) + (0.000000103424 * (lnRtRt25^3)));

To convert into Celsius, you can subtract 273.15 from the temp. To convert into Fahrenheit, you can use this pseudo code:
Fahrenheit = (Kelvin - 273.15) * 9 / 5 + 32

This entry was posted in Drivers, Electronics, Mindstorms, NXC, NXT, PICAXE and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s