and finally i have put the 2 togther tho this isnt working coming up with errors but will workon this.
1 quick question
on the light sensor script there is a
void setup(void)
is the naming txt in the ( ) which is void is this calling the setup a name. so if i wanted to go back to the top of that script i would use the name void?
anyway here is mash up of both
/* YourDuino.com Example Software Sketch
DHT11 Humidity and Temperature Sensor test
Credits: Rob Tillaart
http://arduino-direct.com/sunshop/index.php?l=product_detail&p=162
terry@yourduino.com */
/* Photocell simple testing sketch.
Connect one end of the photocell to 5V, the other end to Analog 0.
Then connect one end of a 10K resistor from Analog 0 to ground
For more information see www.ladyada.net/learn/sensors/cds.html */
/-----( Import needed libraries )-----/
#include <dht11.h>
/-----( Declare objects )-----/
dht11 DHT11;
/-----( Declare Constants, Pin Numbers )-----/
#define DHT11PIN 2
int photocellPin = 0; // the cell and 10K pulldown are connected to a0
int photocellReading; // the analog reading from the analog resistor divider
void setup(void) /----( SETUP: RUNS ONCE )----/
{
Serial.begin(9600);
Serial.println("DHT11 TEST PROGRAM ");
Serial.print("LIBRARY VERSION: ");
Serial.println(DHT11LIB_VERSION);
Serial.println();
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
// We'll send debugging information via the Serial monitor
Serial.begin(9600);
}/--(end setup )---/
void loop(void) /----( LOOP: RUNS CONSTANTLY )----/
photocellReading = analogRead(photocellPin);
Serial.print("Analog reading = ");
Serial.print(photocellReading); // the raw analog reading
if (photocellReading < 10) {
} else if (photocellReading < 500) {
Serial.println(" - START TESTING");
{
Serial.println("\n");
int chk = DHT11.read(DHT11PIN);
Serial.print("Read sensor: ");
switch (chk)
{
case 0: Serial.println("OK"); break;
case -1: Serial.println("Checksum error"); break;
case -2: Serial.println("Time out error"); break;
default: Serial.println("Unknown error"); break;
}
Serial.print("Humidity (%): ");
Serial.println((float)DHT11.humidity, 2);
Serial.print("Temperature (oC): ");
Serial.println((float)DHT11.temperature, 2);
if (DHT11.humidity < 80) {
// do stuff if the condition is true
digitalWrite(12, HIGH); // set the ON_Relay on
delay(1000);
digitalWrite(12, LOW); // set the ON_Relay off
} else {
// do stuff if the condition is false
digitalWrite(12, LOW); // set the ON_Relay off
}
if (DHT11.humidity > 80) {
// do stuff if the condition is true
digitalWrite(13, HIGH); // set the OFF_Relay on
delay(1000);
digitalWrite(13, LOW); // set the OFF_Relay off
} else {
// do stuff if the condition is false
digitalWrite(13, LOW); // set the OFF_Relay off
}
} else if (photocellReading > 499) {
Serial.println(" - DO NOTHING");
}
delay(500);
}
delay(50);
}/* --(end main loop )-- */
/-----( Declare User-written Functions )-----/
//
//Celsius to Fahrenheit conversion
double Fahrenheit(double celsius)
{
return 1.8 * celsius + 32;
}
//Celsius to Kelvin conversion
double Kelvin(double celsius)
{
return celsius + 273.15;
}
// dewPoint function NOAA
// reference: Algorithms - Schlatter and Baker
double dewPoint(double celsius, double humidity)
{
double A0= 373.15/(273.15 + celsius);
double SUM = -7.90298 * (A0-1);
SUM += 5.02808 * log10(A0);
SUM += -1.3816e-7 * (pow(10, (11.344*(1-1/A0)))-1) ;
SUM += 8.1328e-3 * (pow(10,(-3.49149*(A0-1)))-1) ;
SUM += log10(1013.246);
double VP = pow(10, SUM-3) * humidity;
double T = log(VP/0.61078); // temp var
return (241.88 * T) / (17.558-T);
}
// delta max = 0.6544 wrt dewPoint()
// 5x faster than dewPoint()
// reference: Dew point - Wikipedia
double dewPointFast(double celsius, double humidity)
{
double a = 17.271;
double b = 237.7;
double temp = (a * celsius) / (b + celsius) + log(humidity/100);
double Td = (b * temp) / (a - temp);
return Td;
}
/* ( THE END ) */