#include <math.h>
const int PULLUP_RES = 10000; // in Ohm( 20kOm )
const double BETA = 3950; // in K for Semitec 104 GTA-2
const double THERMISTOR_RES = 10000; // in Ohm
const double THERMISTOR_NOM_TEMP = 25; // Celsius, C
int greenLED = D0;
int yellowLED = D1;
int redLED = D2;
int blueLED = D6;
int start = Time.minute();
void setup()
{
pinMode(greenLED, OUTPUT);
pinMode(redLED, OUTPUT);
pinMode(yellowLED, OUTPUT);
pinMode(blueLED, OUTPUT);
digitalWrite(greenLED, LOW);
digitalWrite(yellowLED, LOW);
digitalWrite(redLED, LOW);
digitalWrite(blueLED, LOW);
}
void loop()
{
thermister_temp(analogRead(4));
delay(10000);
}
void thermister_temp(int aval) {
double R, T;
R = (double) PULLUP_RES / ( (4095 / (double) aval ) - 1 );
T = 1 / ( ( 1 / (THERMISTOR_NOM_TEMP + 273.15 )) + ( ( 1 / BETA) * log ( R / THERMISTOR_RES ) ) );
T -= 273.15; // converting to C from K
// return degrees C
//Particle.publish("Temperature", String(T) + " °C");
if (38 <= T && T <= 43) { //Celsius temperatures
Particle.publish("Temperature", "Ready");
digitalWrite(blueLED, HIGH);
delay(10000);
digitalWrite(blueLED, LOW);
}
if (start <= Time.minute() && Time.minute() <= start + 3) {
digitalWrite(greenLED, HIGH); }
if (start+3 < Time.minute() && Time.minute() <= start + 6){
digitalWrite(greenLED, LOW);
digitalWrite(yellowLED, HIGH); }
if (start + 6 < Time.minute()){
digitalWrite(yellowLED, LOW);
digitalWrite(redLED, HIGH); }
}
Click to Expand
Content Rating
Is this a good/useful/informative piece of content to include in the project? Have your say!
You must login before you can post a comment. .