This example as written requires the following hardware:

BlueZigbee takes on and off commands from an Android phone and sets a GPIO pin on a remote circuit with this information, allowing for control of relays or other objects.

This program was written as a demo of how the BlueScripts Android application can be used in a simple embedded system to accomplish something useful without having to write any code for Android.

Although the program is written for the list of hardware above it could easily be ported to another Stellaris Cortex M3 microcontroller with minimal changes. Other backends other than Digi Zigbee modules could also be substituted, relays could be replaced with triacs or simple power FETs for simple switch applications.


This is the same video on the BlueScripts page but as some people may look at this page first it is reproduced here. It shows BlueScripts/BlueZigbee in action:

The Adobe Flash Plugin is needed to display this content.

Application Details

On a high level BlueZigbee as a program listens on one UART for commands, these commands are interpreted and then sent out on another UART to be executed.

In the implementation here the Eridani board acts as a master controller for the Zigbee network which serves as the remote control backend. Commands are sent from an Android phone to a SPP Bluetooth module. These commands are outputed as ASCII over a UART to the Eridani board. Eridani parses the commands and converts them to Digi Zigbee API commands which are sent over the other UART to a Digi Zigbee module.

Specifically as written BlueZigbee accepts <nodeName> <on/off> as an ASCII command. This command toggles GPIO pin D0 on the Zigbee end point radio with the ASCII name <nodeName>.

Because this application is very simple, we do not need a separate microcontroller to complete the action in each remote location. Zigbee radios allow for A/D and GPIO allowing the example here to be extended for use in remote sensing applications, and more complicated control.

Here we need only a single GPIO pin to control a relay. This relay switches a household outlet to allow us to turn appliances on or off via the phone interface.

Disclaimer: working with high voltages can be hazardous both in terms of personal risk and property loss, if you are not comfortable working with such things do not attempt them. Proper engineering margin is required in high power applications: that is using parts in excess of what is needed, improper design will result in fires, electric shocks and other harm.

If you are familiar with the Eridani you may have already realized that there are not two hardware UARTs on the board, and for this project as I already mentioned we need two. Fortunately there is an easy to use software based UART in the StellarisWare library examples. This allows us to create an extra UART that is controlled with interrupts.

Zigbee radios could be replace with any radio type when combined with a microcontroller on the remote endpoint.

The general topology of the example is shown in the following block diagram:


To interface with the Android phone the simplest means is to use a Bluetooth module that supports Serial Port Profile (SPP). There are many such modules available. Popular examples are Roving Networks RN-41 and RN-42. Many Bluetooth SPP modules are based on CSR417 and similar chips. There are many flavors of these available on eBay with 2-3 week lead time for less than 10 dollars. (MDFly offers a slave only CSR417 module on an inexpensive breakout board for those averse to SMD soldering or PCB design).

For the Zigbee backend we used series 2 Digi Zigbee modules in API firmware mode. These are no longer sold. However, the software API mode appears to still be used on the newer DigiMesh modules (See the DigiMesh datasheet). The API is a fairly complicated packet based exchange method. The source code implements what is needed to issue remote AT commands to allow for remote GPIO on the remote Zigbee radios.

The general schematic of Eridani based controller is:

Each remote endpoint is a simple power supply, radio, and Zigbee endpoint module, the schematic for this is:

Source Code

The full source code for this project is available here.

It is commented extensively inline. All of the application specific code is in bluezigbee.c.

eridani/bluezigbee.txt · Last modified: 2014/08/01 20:14 (external edit)
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki