commit 6faa4f0cd26f5a671dbf26e174c76db4cff30983
parent 1559fc4ac7e64aa28081e087f6402fb7ab97a730
Author: Jacob Neplokh <me@jacobneplokh.com>
Date: Tue, 18 Feb 2020 12:59:44 -0800
:sparkles: Add ThermistorDemo Code
Diffstat:
1 file changed, 28 insertions(+), 0 deletions(-)
diff --git a/ThermistorDemo/ThermistorDemo.ino b/ThermistorDemo/ThermistorDemo.ino
@@ -0,0 +1,27 @@
+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);
+}
+
+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);
+}
+\ No newline at end of file