Im using an
Arduino Uno
DHT22 sensor (pin 8)
1 relay (pin 2)
thats all this is my code it compiles but I dont think its working. Ive spent a lot of time on this already and it should be simple please help.
#include “DHT.h”
#define DHTTYPE DHT22
#define DHTPIN 8
DHT dht(DHTPIN, DHTTYPE);
#define CROCKPOTPIN 2
#define TEMP_HIGH 22
#define TEMP_LOW 20
#define HUMID_HIGH 60
#define HUMID_LOW 20
float minTemp = 100;
float maxTemp = 0;
float minHumid = 100;
float maxHumid = 0;
int crockValue = 0;
void setup()
{
Serial.begin(115200);
Serial.println("TEST PROGRAM ");
pinMode(CROCKPOTPIN, OUTPUT);
}
void loop()
{
// READ DATA
int t = dht.readTemperature();
int temperatureF = (t * 9 / 5) +32.5;
// DO THE MIN/MAX
minTemp = min(minTemp, t);
maxTemp = max(maxTemp , t);
// DISPLAT DATA
Serial.println(temperatureF);
// CROCKPOT
if (t > TEMP_HIGH) crockValue = 0;
else if (t < TEMP_LOW) crockValue = 1;
digitalWrite(CROCKPOTPIN, crockValue);
delay(2000); // DHT's need a delay between readings ...
}