My smart home project for school will consist of a single floor house with 4 different rooms. 3 of the rooms are all the same dimensions and will have the same circuitry for all 3, the last rooms is larger and so far will only be used to open and close a door. My dilemma is that I cant think of any more features to add to the house.
Current features:
- Controlling LEDs for lighting the rooms
- Reading the temperature for the rooms
- Using a PC fan to cool down the rooms when they reach a certain temperature or manually enabling
- Rain detection sensor on the roof
- Soil moisture reader to see if plants need to be watered
- Opening and closing a door with a servo
Note that the soil sensor, servo, and pc fans haven't been implemented into the main prototype yet. Only got the PC fans working with if statements on a separate code so far.
Im just looking for some more ideas that I could add. I am researching into using GUI builder for processing to make a simple GUI rather then using the arduino serial monitor. Only did a quick search the other day but I read there are alternatives to the arduino serial monitor. Any ideas for project guidance or how to simplify my code please feel free to respond.
Warning I am an EET major not a CET so I never took any coding classes, everything below was self taught.
//Small leds Vf=2.8v
int LED1 = 8; //Pin the White LED is connected to (room-1)
int LED2 = 9; //Pin the Red LED is connected to (room-2)
int LED3 = 10; //Pin the Blue LED is connected to (room-3)
char room_req[] = "______________________________________________________________________________\n"
"Room #1\t\t\t\t Room #2\t\t\t Room #3\n"
"1=Temp Read\t\t\t 4=Temp Read\t\t\t 7=Temp Read\n"
"2=Light On\t\t\t 5=Light On\t\t\t 8=Light On\n"
"3=Light Off\t\t\t 6=Light Off\t\t\t 9=Light Off\n"
"a=Turn all lights on\t\t b=Turn all lights off\n"
"c=Check for rain\n"
"______________________________________________________________________________\n\n";
void setup()
{
pinMode(LED1,OUTPUT);
pinMode(LED2,OUTPUT);
pinMode(LED3,OUTPUT);
Serial.begin(9600);
Serial.println(room_req);
delay (200);
}
void loop()
{
//while((Serial.available()) this statement prevents the reprint of the menu
if(Serial.available())
{
int input = Serial.read();
if(input == '1')
{
readtemp1();
input = 0;
}
if(input == '2')
{
light_on1();
input = 0;
}
if(input == '3')
{
light_off1();
input = 0;
}
if(input == '4')
{
readtemp2();
input = 0;
}
if(input == '5')
{
light_on2();
input = 0;
}
if(input == '6')
{
light_off2();
input = 0;
}
if(input == '7')
{
readtemp3();
input = 0;
}
if(input == '8')
{
light_on3();
input = 0;
}
if(input == '9')
{
light_off3();
input = 0;
}
if(input == 'a')
{
all_on();
input = 0;
}
if(input == 'b')
{
all_off();
input = 0;
}
if(input == 'c')
{
rain_check();
input = 0;
}
delay (200);
}
}
void readtemp1()
{
int temp_pin_r1 = 15;
int tempsense1 = analogRead(temp_pin_r1); //reads voltage on Pin A0
float millivolts = (tempsense1 / 1024.0) * 5000;//convert pin A0 to millivolts
float celsius_value = (millivolts / 10.0) - 273.15; //sensor output is 10mV per degree Celsius
float fahrenheit_value = ((celsius_value)*(9.0/5.0)) + 32.0;//convert to fahrenheit
Serial.print("Room #1 temperature is ");
Serial.print(fahrenheit_value);
Serial.print((char)176); // 176 is ASCII number for degree sign
Serial.print(" Fahrenheit\n");
Serial.println();
}
void light_on1()
{
digitalWrite(LED1,HIGH);
Serial.println("Room #1 light is ON (White)");
Serial.println();
}
void light_off1()
{
digitalWrite(LED1,LOW);
Serial.println("Room #1 light is Off (White)");
Serial.println();
}
void readtemp2()
{
int temp_pin_r2 = 7;
int tempsense2 = analogRead(temp_pin_r2); //reads voltage on Pin A0
float millivolts = (tempsense2 / 1024.0) * 5000;//convert pin A0 to millivolts
float celsius_value = (millivolts / 10.0) - 273.15; //sensor output is 10mV per degree Celsius
float fahrenheit_value = ((celsius_value)*(9.0/5.0)) + 32.0;//convert to fahrenheit
Serial.print("Room #2 temperature is ");
Serial.print(fahrenheit_value);
Serial.print((char)176); // 176 is ASCII number for degree sign
Serial.print(" Fahrenheit\n");
Serial.println();
}
void light_on2()
{
digitalWrite(LED2,HIGH);
Serial.println("Room #2 light is ON (Red)");
Serial.println();
}
void light_off2()
{
digitalWrite(LED2,LOW);
Serial.println("Room #2 light is Off (Red)");
Serial.println();
}
void readtemp3()
{
int temp_pin_r3 = 0;
int tempsense3 = analogRead(temp_pin_r3); //reads voltage on Pin A0
float millivolts = (tempsense3 / 1024.0) * 5000;//convert pin A0 to millivolts
float celsius_value = (millivolts / 10.0) - 273.15; //sensor output is 10mV per degree Celsius
float fahrenheit_value = ((celsius_value)*(9.0/5.0)) + 32.0;//convert to fahrenheit
Serial.print("Room #3 temperature is ");
Serial.print(fahrenheit_value);
Serial.print((char)176); // 176 is ASCII number for degree sign
Serial.print(" Fahrenheit\n");
Serial.println();
}
void light_on3()
{
digitalWrite(LED3,HIGH);
Serial.println("Room #3 light is ON (Blue)");
Serial.println();
}
void light_off3()
{
digitalWrite(LED3,LOW);
Serial.println("Room #3 light is Off (Blue)");
Serial.println();
}
void all_on()
{
Serial.println("All lights are on.");
digitalWrite(LED1,HIGH);
digitalWrite(LED2,HIGH);
digitalWrite(LED3,HIGH);
}
void all_off()
{
Serial.println("All lights are off.");
digitalWrite(LED1,LOW);
digitalWrite(LED2,LOW);
digitalWrite(LED3,LOW);
}
void rain_check()
{
int rain = 8;
Serial.println(analogRead(rain));
if (analogRead(rain)>'325');
{
Serial.println("Yes it is raining.");
}
if (analogRead(rain)<'325');
{
Serial.println("No it is not raining.");
}
}