RawADC

Hi all.

I'm looking for a definition of what RawADC is. Specifically from the thermistor2 code ( http://www.arduino.cc/playground/ComponentLib/Thermistor2 ) on the playground. I've checked the official docs and the docs for the parent of math.h

I'm assuming it's an internal variable, but to arduino, or to the...?

What I'm trying to accomplish is to expand the code to read 5 inputs. Obviously, I need to expand Temp to Temp1, Temp2, Temp3... But, do I need to expand RawADC as well?

Actually you don’t need to expand any of the variables. This is a function that is called after you have already read from any specific A/D channel you wish to.

Here is the example usage from that libary:

Serial.println(int(Thermister(analogRead(0)))); // display Fahrenheit

To print the temperature from analog channel one you only have to change one thing:

Serial.println(int(Thermister(analogRead(1)))); // display Fahrenheit

That make sense?

Lefty

Crystal. Thanks Lefty!

I also needed multiple thermistors/temps and the last answer is working fine for me. Thanks all. However, its not clear to me how that piece of code functions when the Serial.println(int(Thermister(analogRead(0)))); is invoked. Any help understanding this syntax?

double Thermister(int RawADC) { double Temp; Temp = log(((10240000/RawADC) - 10000)); Temp = 1 / (0.001129148 + (0.000234125 * Temp) + (0.0000000876741 * Temp * Temp * Temp)); Temp = Temp - 273.15; // Convert Kelvin to Celcius Temp = (Temp * 9.0)/ 5.0 + 32.0; // Convert Celcius to Fahrenheit return Temp; }

However, its not clear to me how that piece of code functions when the Serial.println(int(Thermister(analogRead(0)))); is invoked. Any help understanding this syntax?

Look at the statement from the inside out. The analogRead(0) function is called. That function returns a value. That value is passed to the Thermistor() function, which performs some calculations, and returns a value. The double returned by Thermistor is then passed to the int() function, which returns an int. The int returned by int() is then passed to Serial.println() for printing to the serial port.

It might help to understand what is happening if you did something like this, instead:

double pinVal = analogRead(0);
double temperatureAsDbl = Thermistor(pinVal);
int temperatureAsInt = int(temperatureAsDbl);
Serial.println(temperatureAsInt);