Zigbee XBee modules with Arduino and Atmega8 uController + Breadboard

In this exercise I just tried to use two zigbee series 2 modules (1 Coordinator and 1 End Device) to communicate between themselves, and I wanted to see whether I coud use an external microcontroller (of my choosing, anything, really, that would require command console flashing and not a fancy easy going IDE just like Arduno SDK :P ) with it, and what would be the effort level. 


The two XBee modules

In this picture we see two arduino Uno at the bottom of the shield, but only one of them was used. The other was replaced by the Atmega8 microcontroller, all the required wiring (to flash and run it), and a led with a capacitor of 220 Ohm. (In the picture we can also see the USBasp module, to program it).


Never mind the circuitry at the background, you can do yours, or ask me about mine ;) Now, the goal: one of the zigbee modules (the coordinator) will start the network and look for peers that might have the same PAN ID (network group id). As it is off course the case, it will find and join the other end device into the network. This process is done automatically with the firmwares I've flashed into both modules (using the X-CTU program from DIGI - http://www.digi.com/products/wireless-wired-embedded-solutions/zigbee-rf-modules/xctu). 


After that, I had to program the logic of both microcontrollers. So what I did was the following: I want to send 2 characters from one uController to the other, and having the other turning the LED on or off, depending on the character sent. for that, upload to one of the microcontrollers (for e.g. the arduino, with arduino SDK), the program that will send the characters. REJOICE, the program is already built under examples/communication/PhysicalPixel of the Arduino SDK. Now, the other one will controll the LED, and it is a matter of initializing the serial port, reading the serial port, and do an IF-ELSE case. Because I'm using an Atmega8, I had to program it with a slight different code, but the Arduino SDK equivalent code is here:




The outcome is as expected:


What this Atmega8 receives is:


L stands for Low (turn off the led), and H for High (turn on the led). And a little video showing the execution is here as well ;)  :







Published by fxsf às 22:08