Home Automation over Mesh Network

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 fashioned in a mesh network.

A mesh network was used for two main reasons:

Scalability: The mesh network makes it easy to add a new node to the system.

System communication reliability : By using a mesh network, If a node is located outside of the coordinator's range, then the coordinator will use speak to the destination node via nearby nodes that the coordinator could reach.

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. http://i.imgur.com/xCExmUR.png

Parts

Connections

http://i.imgur.com/GG94HF0.png

Code

The Android app 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.

Here is the mbed program:

Import programXbeeHomeAutomation

Home automation using Xbee radios

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.

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:

Xbee address number What digital devices are connected Current state of the digital devices What analog devices are connected The values received from the analog devices Timer information for motion control 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 type are as follows:

Digital TypeAnalog TypeDevice Attached
1XPowerSwitch Tail II Control Module
2Xmotion sensor
3Xbutton
X1TMP36 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.

  • A more dynamic system, with the mbed figuring out what is attached instead of hard coding devices
  • More device types, preferably with the ability to add new device types
  • More app features, like sorting and filtering the list
  • Make the app save IP address information so it doesn't need to be entered each time the app is reopened
  • App auto refresh, as the app currently only updates values when the user requests a refresh
  • Move to the mbed RTOS to better handle tasks
  • Full system control using Mbed Application Board
  • System control through a web interface


Please log in to post comments.