taylor santiago - ece 561 - smart home controller
TRANSCRIPT
Smart Home ControllerTaylor Santiago
Taylor Santiago ECE 561
HTC 8xPhoto Credit: Amazon.comRaspberry Pi
Photo Credit: Wikipedia.org
TCP OperationPhoto Credit: Cisco.com
Physical Setup
Taylor Santiago ECE 561
This project required the following physical items:
• Raspberry Pi• SD Card to boot Debian Unix• HTC 8x (Windows Phone OS)• Bluetooth Dongle• USB Mouse and Keyboard• AC Powered USB Hub• Breadboard, LEDs, Resistors, and Misc. Wiring• HDMI Compatible Monitor• Ethernet Cable
Bluetooth Handler
Taylor Santiago ECE 561
• The Raspberry Pi is setup as a Bluetooth server• Python script constantly receives messages from the client, the smartphone• Incoming messages are parsed and are then handled by either driving GPIO pins or replying
to the client with metrics
TCP Socket Handler
Taylor Santiago ECE 561
• Raspberry Pi is setup as a client connected to my personal website• The Pi polls the website every second to see if it’s accepting connections• Incoming messages from the server are accepted and handled in a similar manner to the
Bluetooth handler
Metrics Handling
Taylor Santiago ECE 561
• Metrics are collected by threaded functi0ns that monitor the Raspberry Pi pin values• When the monitors witness a change on the pin (light toggled), the light status and usage
time metrics are updated• Light metrics are kept in a python dictionary, with values such as
‘status’, ‘time_off’, ‘time_on’, and ‘total_time’ being tracked
Website Support
Taylor Santiago ECE 561
• The website is written in PHP – http://tws928.com/smarthome.php• Once the website is accessed in a browser, it begins listening for connections• Radio buttons are presented to the user to choose accepted commands to send to the
Raspberry Pi• Information on the lights status and percentage of time used is presented to the user
Windows Phone Application
Taylor Santiago ECE 561
• The windows phone application is written in C# using Visual Studio• The application is leveraged from a Bluetooth template provided by Microsoft• I added the handling of user interactions and encoding and decoding outgoing and incoming
messages, respectively
Project Learnings
Taylor Santiago ECE 561
• Raspberry Pi setup and usage• The importance of handling exceptions – when dealing with socket connecti0ns from
multiple sources, it’s crucial to not let communication errors crash your application• PHP and Bluetooth socket programming• Windows phone programming• Python Threading
Possible Project Extensions
Taylor Santiago ECE 561
• Password encryption• Multiple user support with parental controls• It may be worth investing in a different embedded system, or at least a better USB powered
hub. Bluetooth flakiness was an issue• Add semaphore support – lots of shared resources
Video
Taylor Santiago ECE 561
http://www.youtube.com/watch?v=Ik2gXzdcTewhttp://www.youtube.com/watch?v=ALd-DvJ9pBM
To view these without opening your browser, open this in Slide Show mode
Physical Setup Pictures
Taylor Santiago ECE 561
Raspberry Pi Breadboard connections
Physical Setup Pictures
Taylor Santiago ECE 561
Raspberry Pi, breadboard, and USB Hub Cardboard house with four rooms
Smartphone Application Pictures
Taylor Santiago ECE 561
Start Screen After tapping find paired devices After connecting After hitting ‘View Control Options’
Taylor Santiago ECE 561
Smartphone Application Pictures
User interface for lights control Metrics screen