sci-oly-detector-building

[RADIOACTIVE] arduino thermometer for science olympiad
git clone git://git.figbert.com/sci-oly-detector-building.git
Log | Files | Refs | LICENSE

commit e6a06aab2593d121fa18a951849556ac5d686596
parent f2db065227f9d1d855f8471103235b12d939c25d
Author: Jacob Neplokh <me@jacobneplokh.com>
Date:   Tue, 18 Feb 2020 13:19:44 -0800

Update ThermistorDemo.ino

Diffstat:
MThermistorDemo/ThermistorDemo.ino | 73++++++++++++++++++++++++++++++++++++++++++++++++-------------------------
1 file changed, 48 insertions(+), 25 deletions(-)

diff --git a/ThermistorDemo/ThermistorDemo.ino b/ThermistorDemo/ThermistorDemo.ino @@ -1,27 +1,50 @@ -int ThermistorPin = 0; -int Vo; -float R1 = 10000; -float logR2, R2, T, Tc, Tf; -float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07; - -void setup() { -Serial.begin(9600); +/* Sensor test sketch + for more information see http://www.ladyada.net/make/logshield/lighttemp.html + */ + +#define aref_voltage 3.3 // we tie 3.3V to ARef and measure it with a multimeter! + + + + +//TMP36 Pin Variables +int tempPin = 1; //the analog pin the TMP36's Vout (sense) pin is connected to + //the resolution is 10 mV / degree centigrade with a + //500 mV offset to allow for negative temperatures +int tempReading; // the analog reading from the sensor + +void setup(void) { + // We'll send debugging information via the Serial monitor + Serial.begin(9600); + + // If you want to set the aref to something other than 5v + analogReference(EXTERNAL); } - -void loop() { - - Vo = analogRead(ThermistorPin); - R2 = R1 * (1023.0 / (float)Vo - 1.0); - logR2 = log(R2); - T = (1.0 / (c1 + c2*logR2 + c3*logR2*logR2*logR2)); - Tc = T - 273.15; - Tf = (Tc * 9.0)/ 5.0 + 32.0; - - Serial.print("Temperature: "); - Serial.print(Tf); - Serial.print(" F; "); - Serial.print(Tc); - Serial.println(" C"); - - delay(500); + + +void loop(void) { + + tempReading = analogRead(tempPin); + + Serial.print("Temp reading = "); + Serial.print(tempReading); // the raw analog reading + + // converting that reading to voltage, which is based off the reference voltage + float voltage = tempReading * aref_voltage; + voltage /= 1024.0; + + // print out the voltage + Serial.print(" - "); + Serial.print(voltage); Serial.println(" volts"); + + // now print out the temperature + float temperatureC = (voltage - 0.5) * 100 ; //converting from 10 mv per degree wit 500 mV offset + //to degrees ((volatge - 500mV) times 100) + Serial.print(temperatureC); Serial.println(" degrees C"); + + // now convert to Fahrenheight + float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0; + Serial.print(temperatureF); Serial.println(" degrees F"); + + delay(1000); } \ No newline at end of file