They say "It's not the heat, it's the humidity". Well, my late Mum said it anyway.
The chart here shows a colour scheme for the comfort as perceived by "the human body" (it doesn't say whose 8) ) for H vs T.
This sketch maps those colours into a 2D array, and extracts the colour code for the current H and T. It displays the results in the serial monitor, and sets an RGB LED to R, G, B or Y according to the chart. (Haven't hooked an actual LED up yet... )
// Load h vs t comfort chart into 2d array
// example: http://www.klingenburg-usa.com/news/hugo.html
// Read the humidity and temp from a dht11
// Look up the comfort zone in the array
// Display results in serial monitor
// Set an RGB LED as Red, Blue, Green or Yellow ala chart
#include <dht11.h>
dht11 DHT;
#define DHT11_PIN 5
byte humid;
byte temp;
byte humidInd;
byte tempInd;
char comfColour;
// pins of the RGB LED..
byte LED_R = 2;
byte LED_G = 3;
byte LED_B = 6;
//fill the array based on the colour chart
int comf[10][11] = {
'B','B','B','R','R','R','R','R','R','R','\0', //high humid
'B','B','Y','Y','R','R','R','R','R','R','\0',
'B','B','Y','Y','Y','R','R','R','R','R','\0',
'B','B','Y','G','G','Y','Y','R','R','R','\0',
'B','B','Y','G','G','G','Y','R','R','R','\0',
'B','B','Y','G','G','G','Y','Y','R','R','\0',
'B','B','B','Y','Y','G','Y','Y','R','R','\0',
'B','B','B','B','Y','Y','Y','Y','R','R','\0',
'B','B','B','B','B','B','B','R','R','R','\0',
'B','B','B','B','B','B','B','R','R','R','\0', //low humid
}; //
void setup(){
pinMode(LED_R, OUTPUT);
pinMode(LED_G, OUTPUT);
pinMode(LED_B, OUTPUT);
Serial.begin(9600);
Serial.println("DHT COMFORT PROGRAM ");
Serial.print("LIBRARY VERSION: ");
Serial.println(DHT11LIB_VERSION);
Serial.println();
Serial.println("Humidity (%),\tTemperature (C),\tComfort");
}
void loop(){
//get data
int chk;
chk = DHT.read(DHT11_PIN); // READ DATA
humid = DHT.humidity;
temp = DHT.temperature;
//calc indices into the 2d matrix
humidInd =9- humid/10;
if (temp%2==0) //even temp
{
tempInd=(temp/2)-8;
}
else //odd temp
{
tempInd=(temp/2)-7;
}
if (tempInd < 0) tempInd=0;
if (tempInd > 9) tempInd=9;
// get the current value from the array
comfColour = comf[humidInd][tempInd];
// DISPLAY DATA
Serial.print(humid);
Serial.print(",\t\t\t");
Serial.print(temp);
Serial.print(",\t\t");
Serial.println(comfColour);
//and set the led
if (comfColour == 'R')
{
digitalWrite(LED_R, HIGH);
digitalWrite(LED_G, LOW);
digitalWrite(LED_B, LOW);
}
if (comfColour == 'G')
{
digitalWrite(LED_R, LOW);
digitalWrite(LED_G, HIGH);
digitalWrite(LED_B, LOW);
}
if (comfColour == 'B')
{
digitalWrite(LED_R, LOW);
digitalWrite(LED_G, LOW);
digitalWrite(LED_B, HIGH);
}
if (comfColour == 'Y')
{
digitalWrite(LED_R, HIGH);
digitalWrite(LED_G, HIGH);
digitalWrite(LED_B, LOW);
}
delay(10000);
}//loop