Home Automation Using Xbee

Chris Wilson - Max Mujica - Hai Pham - Nicholas Parham


Contents


Description

For our project, we created a home automation system that allows the user to monitor and control different devices throughout a home. Each of the devices in a room are attached to Xbee radio nodes that are fasioned in a mesh network.

A mesh network was used for two main reasons:

The user interacts with the system via an Android application called "My Home". This app communicates with the Mbed microcontroller via RPC server over HTTP, sending it commands to read information from and write to devices.

The Mbed that is interfaced with the app via Ethernet is also serially connected to an Xbee coordinator radio, which uses a wireless protocol (Zigbee) in order to communicate with other Xbee nodes located nearby. The diagram below shows how the system communicates with the coordinator and other nodes.

communication diagram of the system


Parts

Pictured below are the parts that were used in our home automation system. Please click on each of the images to get more information on each part.

Mbed Application Board Xbee (S2) Radio RJ45 Adapter Temperature Sensor Motion Sensor PowerSwitch Tail II
http://i.imgur.com/P2lj0tn.jpg http://i.imgur.com/GpaVNmC.jpg http://i.imgur.com/l7DmWgR.jpg http://i.imgur.com/A3z4AlN.jpg http://i.imgur.com/ZUynRaQ.jpg http://i.imgur.com/b5D3rMe.jpg

Connections

The table below shows the pin connections made between the Mbed, the Xbee, and the RJ45 adapter

Component Connections


Code

The Android application can be found here. When the app is started, the IP address of the Mbed will need to be entered by pressing the settings button. After that, the refresh button must be pressed.

Link to the Mbed program

App - Home System Communication

The Android application communicates with the home automation system via Ethernet with a RPC server. In the application, the user must enter in the IP address that correlates to the router and the RPC that is connected to the home system. Once properly connected, the RPC server will transfer all known information about the home to the app and also will be ready to receive instructions from the app.

The app communicated with the RPC server using commands in HTTP format. The command template looks like:

http://<IP Address>/rpc/<Object>/<Command> <Args (optional)>

As an example, let's look at the command that reads the values from the temperature sensor on Node 1. The HTTP command looks like this:

http://xxx.xxx.xxx.xxx/rpc/Temp0/read

Communication Between App, Mbed, and Xbee Nodes

In order to get information for the app, the Mbed has code that uses packet communication between the Xbee coordinator and the Xbee routers that are located throughout the building. The Mbed creates structs that represent all of the Xbee nodes in the system. The structs contain all of the following information:

In order to distinguish each device (due to the different nature of each device and conversion factors that are dependent on the device), an internal encoding mechanism has been created for each device. The numbers that are associated with each device are as follows:

Digital Type Analog Type Device Attached
1 X PowerSwitch Tail II Control Module
2 X motion sensor
3 X button
X 1 TMP36 Temperature Sensor Module

In order to update the structs so information can be relayed between the system and the app, the Mbed is constantly monitoring the packet information and updating the structs as needed. A summary of the main functions are shown below.

Serial Handler - The serial handler copies the packets being sent to the coordinator and stores it in a buffer for future use.

Monitor Xbee - This function takes the packet form the buffer and parses all of the bytes to figure out what the packet is supposed to do. There are different internal handlers that activate depending on what type of device (digital or analog) the packet correlates to. Once the information from the packet is properly parsed, it uses the address information to locate the Xbee that it correlates to and updates the proper struct with the new information.

Digital Read/Write Comparison - This checks the new information in the struct with the previous known data in the struct and sees if it changed. If there is an action that happens due to the change, then the action happens. For example, if one of the Xbee motion sensor was a 0 before, but changed to a 1 with the new updated information, this method would notice that and turn on the lights.

Timer - This method is used exclusively for the motion sensor. If the sensor has turned the lights on, a timer starts to run. If a set amount of time goes by without any new motion being sensed, then it will turn the lights off in the room. If motion is sensed while the timer is running, the timer is reset.


Video


Improvements

There are a few improvements that can be made to the system.