Exbee

This tutorial is to explain how to use zigbee protocol in Xbee module, the most popular programming languages is Python so i decided to develop a light module to send and receive data using Zigbee , i googled  to find a light and a working  modules to operate xbee , but i didn't find it.
I will start by a small tutorial that explain how to use X-CTU, so you have to download it from Digi.com
Required Hardware:
  1. buy two xbee (the same series) , in my case i have xbee pro series 2

  1. USB converter to serial in my case i’m using sparkfun USB to Serial FT232RL.2

  1. Computer (I my case I’m using ubuntu 14.4 as OS) OR Raspberry Pi, i tested this pythom module on the Raspbian and it works as expected. For the other OS I didn’t tested yet so if it’s your case please tested and send me the result.

Required Software:
  1. X-CTU : available from Digi.com
  2. Python :  you have to install Python
  3. Download  EXbee : https://github.com/esmairi/EXbee

Steps:

  1. Connect your two xbee to your computer (USB) then open X-CTU and click add and keep the default configuration.


Before starting test modules you have to update the firmware to configure the mode to API, simply click in button below

, in my case i configured the first xbee as Zigbee Coordinator API and the second as Zigbee Router API

Then click Update. The same for the other module

Configuration:
Now we move to the configuration,

  1. Configure  the PANID and channel


  1. click in the coordinator module ad move the addressing section
To make this module communicate with others routers we have to use Broadcast mode, enter 0 in the DH field and FFFF in the DL field

Note: if you want to send frame to this module you have to use SH and SL as DL and DH

  1. make sure that your module configured to use API 2

To test a communication between those two xbee , you have to construct the frame by click in the generate then choose protocol : Zigbee and set API 2 and frame type to : x10 Transmit   request


Then click in first top button to open the console (also you have to open the serial of the other module) then click send
You can see the two packets: one transmitted and one received.
When you move to serial of the other module you will see the received packet

Now you succeed to make connection between the two modules.

Move now to develop a program for reading and receiving   .
Download EXbee from github and install it :
https://github.com/esmairi/EXbee
Examples
You can find those examples in the examples dir; I will explain how to use it ☺
Example1:
To send a packet, use the function send_tx

Create new python file


Run the program and open the serial for the other module (/dev/ttyUSB1)
As you see the response is a received packet from the module /dev/ttyUSB1, look at the Delivery status: 00 Success

Example2:

To wait for incoming packet, use the function read_rx()
Create new python file


Run the program then go to the console of the module /dev/ttyUSB1 and construct a packet and send it to /dev/ttyUSB0 module and look at the Terminal


You can see that the module receives a packet: the sender is 0013A2004071F023 and Data is salam

Example3:  

To execute an AT command, use the function execute_at(command,param=””) ,


Run the program, you see the result in the terminal

Example4:

Send a Remote AT command:  use the function

send.remote_at(command,address,parameter=””,frame_id=””)


Run the program, the Response is 4071f023

3 comments

When initializing an EXbee object (kk in the first example) Will this work in windows where the serial connection is COM1/COM2/COM3 etc...? OR will this only work in Linux?

Reply

I don't have a Windows, this modules tested in Linux. Please tested in Windows and give us a feedback

Reply

Not working in Windows

Reply

Post a Comment

CodeNirvana
Older Posts
Copyright © JEsmairi
Back To Top