Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: sci_sensor.cpp
- Revision:
- 1:ad071d4ef366
- Child:
- 2:2a3d5370d769
diff -r e695e0f174d2 -r ad071d4ef366 sci_sensor.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sci_sensor.cpp Mon Nov 09 17:32:44 2020 +0000
@@ -0,0 +1,33 @@
+#include "sci_sensor.h"
+
+sci_sensor::sci_sensor(PinName in1, PinName in2): _in1(in1), _in2(in2)
+{
+ c1 = -1481.96;
+ c2 = 2196200;
+ c3 = 1.8636;
+ c4 = 0.00000388;
+
+ la = -2;
+ lb = 3.8062;
+}
+
+//sci_sensor::LM20(PinName in2): _in2(in2)
+//{
+
+//}
+
+float sci_sensor::temp()
+{
+ float volt = _in1.read()*3.3;
+ float T = c1+sqrt(c2 + (c3-volt)/c4);
+ return T;
+
+}
+
+float sci_sensor::phc()
+{
+ float volt = _in2.read()*3.3;
+ float res = (3.3*3300/volt - 3300)/1000.00; // 3300 is the resistance of my resistor
+ float lux = pow(10, la*log10(res)+lb); // A and B values were found using the graph for lux vs. resistance
+ return lux;
+}
\ No newline at end of file