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 95ba0a3344bd6618a876536ad54f617b75072d90
parent 86eb04b06d3e18bb09d6361996cdf18112dd2eef
Author: therealFIGBERT <figbertwelner@gmail.com>
Date:   Fri, 21 Feb 2020 14:22:49 -0800

:sparkles: Add multiple thermistor averaging to keep temperature consistent

Diffstat:
MOperational/Operational.ino | 21+++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/Operational/Operational.ino b/Operational/Operational.ino @@ -2,7 +2,6 @@ #include <Wire.h> #include <hd44780ioClass/hd44780_I2Cexp.h> hd44780_I2Cexp lcd; -#define THERMISTORPIN A0 #define THERMISTORNOMINAL 100000 #define TEMPERATURENOMINAL 25 #define NUMSAMPLES 10 @@ -19,10 +18,21 @@ void setup() { } void loop() { + float first = temperature(0), second = temperature(1); + float celsius = (first + second) / 2; + lcd.setCursor(5, 0); + lcd.print(String(celsius) + "C"); + float fahrenheit = (celsius * 1.8) + 32; + lcd.setCursor(5, 1); + lcd.print(String(fahrenheit) + "F"); + delay(1000); +} + +float temperature(int pin) { uint8_t i; float average; for (i=0; i< NUMSAMPLES; i++) { - samples[i] = analogRead(THERMISTORPIN); + samples[i] = analogRead(pin); delay(10); } average = 0; @@ -38,10 +48,5 @@ void loop() { celsius += 1.0 / (TEMPERATURENOMINAL + 273.15); celsius = 1.0 / celsius; celsius -= 273.15; - lcd.setCursor(5, 0); - lcd.print(String(celsius) + "C"); - float fahrenheit = (celsius * 1.8) + 32; - lcd.setCursor(5, 1); - lcd.print(String(fahrenheit) + "F"); - delay(1000); + return celsius; }