///////THERMIS////
#include <math.h>
float A = 1.009249522e-03, B = 2.378405444e-04, C = 2.019202697e-07;
float T,logRt,Tf,Tc;
float Thermistor(int Vo) {
logRt = log(10000.0*((1024.0/Vo-1)));
T = (1.0 / (A + B*logRt + C*logRt*logRt*logRt)); // We get the temperature value in Kelvin from this Stein-Hart equation
Tc = T - 273.15; // Convert Kelvin to Celcius
Tf = (Tc * 1.8) + 32.0; // Convert Kelvin to Fahrenheit
return T;
}
///////////////
///////PIR///
const int PIR_SENSOR_OUTPUT_PIN =A0; /* PIR sensor O/P pin */
int warm_up;
////////
void setup()
{
pinMode(13, OUTPUT);
///////PIR////
{
pinMode(PIR_SENSOR_OUTPUT_PIN, INPUT);
Serial.begin(9600); /* Define baud rate for serial communication */
delay(500); /* Power On Warm Up Delay */
}
///////////
}
void loop()
{
{
Serial.print("Temp:");
Serial.print(Thermistor(analogRead(A1)));
Serial.print("k ");
Serial.print((Tc));
Serial.print(" C ;");
Serial.print((Tf));
Serial.print(" F");
delay(800);
}
{
int sensor_output;
sensor_output = digitalRead(PIR_SENSOR_OUTPUT_PIN);
if( sensor_output == LOW )
{
if( warm_up == 1 )
{
Serial.print(" Warming Up\n\n");
warm_up = 0;
delay(2000);
}
digitalWrite(13, LOW); // turn the LED on by making the voltage HIGH
Serial.print(" No object in sight\n\n");
delay(1000);
}
else
{
digitalWrite(13, HIGH); // turn the LED off by making the voltage LOW
Serial.print(" Object detected\n\n");
warm_up = 1;
delay(1000);
}
}
}