ECE497 Project Home Control System
Embedded Linux Class by Mark A. Yoder
- 1 Grading Template
- 2 Executive Summary
- 3 Packaging
- 4 Installation Instructions
- 5 User Instructions
- 6 Highlights
- 7 Demo
- 8 Theory of Operation
- 9 Work Breakdown
- 10 Future Work
- 11 Conclusions
I'm using the following template to grade. Each slot is 10 points. 0 = Missing, 5=OK, 10=Wow!
09 Executive Summary - Looks good 08 Installation Instructions - Good instructions, but install.sh and setup.sh are missing. 10 User Instructions - Very clear. Nice figures 10 Highlights - Nice video with web interface inset. 09 Theory of Operation - Looks complete 10 Work Breakdown 10 Future Work 10 Conclusions 10 Demo 10 Not Late Comments: Nice demo with the cardboard house Score: 96/100
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 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.
|Grove Device Name
|Number of Devices
|Port used on Cape
|Grove - Temperature Sensor
|Grove - Air Quality Sensor
|Grove - Light Sensor
|Grove - OLED Display 1.12"
|Grove - Chainable RGB LED
|Grove - Relay
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)
The following pictures show what final installation looks like.
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:
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
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.
- 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.
- 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
Theory of Operation
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().
The majority of sensor operations are handled by 'sensor.py', in which:
- Digital Light Sensor is connected to i2c bus, which can be accessed using "Adafruit_I2C".
- The temperature sensor is connected to analog input, we used "pyupm_grove"'s "GroveTemp" to directly read data in Celsius.
- The air quality sensor is also connected to analog input, but we used "mraa"'s "Aio" to read ADC value.
- Two relays are connected to general GPIO pins. To operate them we used "mraa"'s "Gpio" to write 1s or 0s to operate relays.
- the 0.96 inch OLED is connected to i2c bus. There is a existing driver using "Adafruit_I2C" to operate the OLED screen.
- Chainable RGB LED is connected to the Digital connector. There is a existing driver manipulating the Digital output to simulate an i2c connector, to be able to drive more than one LEDs. We used that driver to control our only LED.
- 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
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.
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).
Embedded Linux Class by Mark A. Yoder