Madeline Kistler / sci_sensor

sci_sensor.cpp

Committer:
mkistler
Date:
2020-11-09
Revision:
1:ad071d4ef366
Child:
2:2a3d5370d769

File content as of revision 1:ad071d4ef366:

#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;
}