ECE497 Project Home Control System

Team members: Boyu Zhang, Bo Pang

Draft Feedback
Wow! Very complete and well done. I like all the pictures showing the interface and wiring. Will you be able to show the heater/cooler on Friday?

Your English is a bit rough in places. Could you have a native speaker edit it for you?

I'm using the following template to grade. Each slot is 10 points. 0 = Missing, 5=OK, 10=Wow!

 00 Executive Summary 00 Installation Instructions 00 User Instructions 00 Highlights 00 Theory of Operation 00 Work Breakdown 00 Future Work 00 Conclusions 00 Demo 00 Late Comments: I'm looking forward to seeing this.

Score: 10/100

(Inline Comment)

Executive Summary
During an era of IoT(Internet of things). We thinks it is a good idea to use Beaglebone green (which works better with Grove sensors comparing to Beaglebone black)to build a home control system.

Currently, We have connected 3 Grove sensors (temperature sensor,air quality sensor and light sensor) to the Beaglebone, so that our Beaglebone can read temperature, air quality, and light intensity of its environment. We also implemented a web server base on the Work of Kervin-Lee to display all the sensor data on a webpage. Using Grove relays, We figured out how to use Beaglebone to turn on/off of a cooling pad and a heating pad which simulates controlling the cooler and heater in a house, so user now can control cooler and heater in the home remotely on a webpage. They can also set target temperature and let the Beaglebone control cooler and heater automatically.

Fortunately, we finished all our set tasks for this project before last week of this term, so there is no feature that is not working. There only problem we encountered with was when we booted the Beaglebone and run our program, the light intensity data got from the light sensor would always be 0. However, if we rerun the our program, the light sensor worked fine again.

Overall, the project is in good shape right now. Really thanks to all the demo codes that Grove Wiki provides to us. We learned a lot when making different sensors works and trying to write a web server on the beaglebone. This is a meaningful project.

Cape and Wiring
Because we have 7 Grove devices that are needed to connect to Beaglebone, so we decided to use a Grove Base Cape for connection. The picture on the right shows the wiring of our system.

All the names of Grove devices we used and port they connect on the cape are listed in the following table.

Cooling and heating system
There is no practical way that we can use the beaglebone to control an air conditioner in our home, so we chose to use a heating pad and a cooling pad to simulate the air conditioner. The following picture shows the circuit of our cooling and heating system. (Two relays in the picture are the same relays in the previous sections)

Final Installation
The following pictures show what final installation looks like.



Prepare work
1. The python version on our bone is 2.7.9. Please first execute following command to verify python version. bone$ python -V You should see the following message: bone$ Python 2.7.9 2. For this project, we use flask web framework for our web service. To install flask please execute following command. bone$ pip install flask

3. Flask-SocketIO gives Flask applications access to low latency bi-directional communications between the clients and the server. To install it please execute following command. bone$ pip install flask-socketio

4. The flask-socketio package relies on asynchronous services, in this project, we selected gevent. To install gevent please execute the following command. This step may takes about 10 minutes. bone$ pip install gevent

5. In this project, we use Adafruit_BBIO and Adafruit_I2C python module for GPIO and I2C communication. Please execute the following command to install them. bone$ sudo pip install Adafruit_BBIO bone$ sudo pip install Adafruit_I2C

6. For controlling the OLED display, we need one more python module--smbus. To install it please execute the following command. bone$ sudo apt-get install python-smbus

Running Code
1. Now, we have installed the requirements. Please download our code from our github repository by running the following command. bone$ git clone https://github.com/Zhangb2rose/HomeControlSystem

2. Navigate to the project directory HomeControlSystem/Code and start the web service by executing the following command. bone$ cd HomeControlSystem/Code bone$ python runserver.py

3. Open a web browser and input the Beaglebone Green local IP (default is 192.168.7.2) and port 8000. You will see a web interface.

User Instructions

 * When the user open the web interface they will see a web page like the following picture.


 * The top three panel shows the real-time temperature, air quality, and light intensity data.
 * The bottom left three panel are used to control cooler and heater pad. User can turn on/off cooler/heater manually by pressing corresponding button, or user can set them in auto mode. Beagle will automatically turn on/off cooler/heater according to set temperature. Cooler will be turn on when current temperature is higher than the set temperature and heater will be turn on, if current temperature is lower than the set temperature. The default value of set temperature is 24 Celsius and user can change it by pressing up or down button.
 * The bottom right panel is used to control a LED light which stimulate control lights in a house.

Highlights

 * The RGB LED will tell us whether the cooler or the heater is running. When the cooler is running, LED will be blue. When heater is running, LED will be red.


 * An LCD display will display the live sensor data once the web server is running

We also have a video demo which you can find Here (TODO)

Web Server
In our runserver.py, we use Flask (a python web framework) to host a front-end web page and Flask_Socketio to listen on port 8000, any http request on port 8000 of the Beaglebone ip address will get response from the Python program. Once runserver.py is runing, funtions like AirRead, TemperatureRead and LightRead. All returned value will be stored as variable and then be passed to a json file. SocketIO will emit the json file to web browser every 2 seconds. This is how the front-end can display sensors' data in real time. When user press any button on the web page like turn on/off cooler or change set temperature, the SocketIO on the web browser end will send request to server (runserver.py) on Beaglebone. The server will handle the request and execute corresponding functions like ControlRelay.



Sensors
(TODO)

Work Breakdown

 * Figure how to use Beaglebone green to read data from temperature sensor, air quality sensor and light sensor -- Bo Pang -- Finished
 * Figure out how to print string on the LCD display -- Boyu Zhang -- Finished
 * Figure out how to control relays and change color of the LED light -- Bo Pang -- Finished
 * Make web service working and build the web interface -- Boyu Zhang -- Finished
 * Figure out how to transfer data between beaglebone to web browser -- Boyu Zhang -- Finished
 * Build the demo box -- Bo Pang -- Finished

Future Work
There are a lot more Grove sensors and devices are available so more features can be added to the current control system.
 * One interesting Grove devices is the Speech Recognizer which can can recognize 22 pieces of commands including 'start', 'stop', 'Play music'. Using this device, we can control our home control system using voice.
 * Another interesting devices is the Fingerprint Sensor This device will allow users to use their figerprint to login the system making the system more secure.
 * Sunlight Sensor is also a very useful device to allow the system detect whether sun rise or not and whether is a good time to open curtain of a window.

Conclusions
This project, although it seems simple, is a good practice for us to learn what is a IoT system. We spent much time exploring Adafruit's BBIO and I2C pythons APIs to figure out how to read data from Grove I2C devices and control relays. We also explored flask python framework and how to use flask to build a web server. From this project, we think we gain some experience of how to use a front end interface to interact with Beaglebone. Due to the limited time, we haven't tried many Grave sensors, but with our experience of front end and back end of an IoT system, we can add tons of new feature to our existing home control system (like what we mentioned in future work section).