Hello guys,
On the last update we added the room freshener. Soldering part is done.
Things to be done to complete the challenge:
1) Ventilation & Lighting
2) Bluetooth Communication between the Arduino and Raspberry Pi
3) UI design (I've never worked on UI, but I'm spending time over it) and program integration
This week on Bluetooth unleashed, we are gonna add a relay module and test it.
I'm strictly not allowed to keep my hands on the building wiring, since the power outage we caused last time.
Somehow I've managed and got permission to test it for a single day and I'm gonna save it for my final demonstration.
A simple connection nothing much, 2 digital pins drive the relays, on addition I've attached a light sensor to analog pin A0.
This light sensor helps to switch on the light under low light condition while running on the automatic mode and DHT11 provides the room temperature.
Yep I've planned both emotion based and manual control and its time to complete the Arduino program.
#include <TroykaDHT.h> #define ROOM_SUM 11 #define ROOM_CIT 12 #define HUMIDIFIER 9 #define FAN 4 #define LIGHT 5 #define LIGHT_SENSE A0 void freshner (int fresh) {digitalWrite(fresh,HIGH); delay(750); digitalWrite(fresh,LOW); } DHT dht(10, DHT11); void setup() { pinMode(HUMIDIFIER, OUTPUT); pinMode(ROOM_SUM, OUTPUT); pinMode(ROOM_CIT, OUTPUT); pinMode(FAN, OUTPUT); pinMode(LIGHT, OUTPUT); digitalWrite(FAN,HIGH); digitalWrite(LIGHT,HIGH); Serial.begin(9600); dht.begin(); } void loop() { digitalWrite(HUMIDIFIER,LOW); dht.read(); delay(100); int hum = dht.getHumidity(); float temperature = dht.getTemperatureC(); char c = Serial.read(); int lux = analogRead(LIGHT_SENSE); switch(c){ case 'a' : //Auto if (lux < 100) { digitalWrite(LIGHT,LOW); } break; case 'b': //ANGER digitalWrite(LIGHT,HIGH); if (hum<80) { digitalWrite(HUMIDIFIER,HIGH); } if (temperature>26) { digitalWrite(FAN,LOW); } freshner(ROOM_CIT); break; case 'c': //SAD digitalWrite(LIGHT,HIGH); if (hum<60) { digitalWrite(HUMIDIFIER,HIGH); } if (temperature>26) { digitalWrite(FAN,LOW); } freshner(ROOM_SUM); break; case 'd': //JOY digitalWrite(LIGHT,LOW); if (hum<60) { digitalWrite(HUMIDIFIER,HIGH); } if (temperature>26) { digitalWrite(FAN,HIGH); } freshner(ROOM_CIT); break; case 'f': digitalWrite(LIGHT,LOW); break; case 'g': digitalWrite(LIGHT,HIGH); break; case 'h': digitalWrite(FAN,LOW); break; case 'i': digitalWrite(FAN,HIGH); break; } }
Since the Bluetooth part is on progress I ain't providing the complete code in this post.
Here's a sneak peek of the UI, its my first attempt with GUIs kindly bear with me!
Cheers,
Sakthi
Top Comments