Raspberry Pi with xbee in python-gkarthik
ZigBee
is a communication device used for the data transfer between the
controllers, computers, systems, really anything with a serial port.
As it works with low power consumption, the transmission distances is
limited to 10–100 meters line-of-sight.
ZigBee devices can transmit data over long distances by
passing data through a mesh
network of intermediate
devices to reach more distant ones. ZigBee is typically used in low
data rate applications that require long battery life and secure
networking. Its main applications are in the field of wireless sensor
network based on industries as it requires short-range low-rate
wireless data transfer. The technology defined by the ZigBee
specification is intended to be simpler and less expensive than other
wireless
networks.
Here we make use of an
interface of Zigbee with Raspberry Pi2 for a proper wireless
communication. Raspberry Pi2 has got four USB ports, so it is better
to use a Zigbee Dongle for this interface. Now we want to check the
communication between the two paired ZigBee modules.Modules Needed :
- Raspberry Pi2
- XBee 1mW Wire Antenna- Series 1 (2 No:)
- XBee Explorer Dongle
(2 No:)
The
two Zigbee must be paired with the same baudrate (for Ex: 9600) with
X-CTU
Software. Attach
the two Zigbee’s to the two dongle’s and connect one
pair on the USB port of the Raspberry Pi2. Connect the other pair to
the USB port of a computer or a Laptop. Install
the FTDI Driver on the
Computer /laptop to provide usb communication. Create a
hyperterminal, select the corresponding com port and the
baudrate for the connected device.
FTDI Virtual Com Port(VCP) driver Installation
Many embedded devices communicate over the serial port connection as most modern computers lack a hardware serial port; USB adapters provide the serial interface. Here we are discussing how to open a serial connection to an embedded device on Windows XP.
The FTDI makes USB communication with a
micro controller or serial device .The chip on the board translates
the serial data coming from a device into USB data and vice-versa. It
is widely used to upload firmware to the Various development boards,
but it can communicate with any serial-enabled device
Download the latest available CDM
drivers from the FTDI web site and unzip them to a location on your
PC
How to Install
Connect the device to a spare USB port on your PC. If the device is based on the FT2232, the Microsoft composite device driver is automatically loaded in the background and a little popup bubble in the bottom right corner of the screen that says Found New Hardware FT232R USB UART.
Connect the device to a spare USB port on your PC. If the device is based on the FT2232, the Microsoft composite device driver is automatically loaded in the background and a little popup bubble in the bottom right corner of the screen that says Found New Hardware FT232R USB UART.
After a few seconds Windows Found New
Hardware Wizard will launch
Select “No, not this
time” from the options available and
then click “Next”
to proceed with the installation.At the next screen, Select “Install from a list or specific location (Advanced)” as shown above in Figure and then click “Next”
Select “Search
for the driver in these locations” and
enter the file path in the combo-box (“C:\CDM 2.02.04″ in Figure
or browse to it by clicking the browse button. Once the file
path has been entered in the box, click Next
to proceed.
If Windows XP is configured to warn
when unsigned (non-WHQL certified) drivers are about to be installed,
the message dialogue shown in above Figure will be displayed unless
installing a Microsoft WHQL certified driver. Click on
“Continue Anyway”
to continue with the installation. If Windows XP is configured
to ignore file signature warnings, no message will appear.
It should copy some required driver
files and installing the software, then come up with this window
display a message indicating that the installation was successful
Click “Finish”
to complete the installation for the first port of the device.
If the device is based on the FT2232
almost immediately, another window will pop up; this time it will say
USB Serial Port. As before, click Install from a list or specific
location. The procedure for installing the second port is identical
to that for installing the first port from the first screen of the
Found New Hardware Wizard.
The Found New Hardware Wizard will
again launch automatically to install the COM port emulation drivers.
Select “No, not this time”
From the options and click “Next”
to proceed with the installation.
Select “Install from a
list or specific location (Advanced)”
and then click “Next“.
Browse to the same folder again and click Next to proceed.
Again the warning message will pop
up,If Windows XP is configured to warn when unsigned (non-WHQL
certified) drivers are about to be installed, the message dialogue
shown in above Figure will be displayed unless installing a Microsoft
WHQL certified driver. Click on “Continue
Anyway” to continue with the
installation. If Windows XP is configured to ignore file
signature warnings, no message will appear.
The below screen shown will be displayed as Windows copies the required driver files.
Now the required device driver is installed, you may need to reboot the computer.
Connect your FTDI device to a spare USB port on your PC,Now a popup bubble in the bottom right corner of the screen that says Found New Hardware USB Serial Port.
OK now you can verify that the driver
installed properly..
Right Click on the my computer Icon in the Desktop click Manage (Open start=>run=>compmgmt.msc) then come up with this window.
Right Click on the my computer Icon in the Desktop click Manage (Open start=>run=>compmgmt.msc) then come up with this window.
Click on the Device Manager Button Look
for an entry under Ports (COM & LPT)
It shows USB Serial Port (COM) the COM
number may vary but it should be something like COM3 or COM4 the COM
number may be as high as COM99 so just look for the USB serial port.
The COM stands for “communication”, and each one has a unique
number, known as the COM Port number. In this case the COM Port
number is COM4. If you don’t see the COM port, verifies the cable
is plugged in, and check that VCP FTDI driver is installed.
Right click on the selection then click
on properties the above window is come up and here you can change the
port setting.
XBee Explorer Dongle
Testing
xbee:
XBee Explorer board with USB A
Type connector for the XBee line of products which can be used as
Dongle – can avoid USB cable and LAPTOP friendly!! . The board is
populated with high current LDO to support most of XBee modules
including XBee Pro! .The XBee Explorer Dongle will help you to reduce
lot of hassles normally facing to implement Xbee Network.We have also
added two more LED’s (SLEEP & Associate) apart from normal 4
LED. This help you to use latest versions XBee Modules as well. The
module is self powered from USB Port itself, thanks to low dropout
regulator.This unit works with all XBee modules including the Series 1 and Series 2.5, standard and Pro version. Plug the Xbee Module into the XBee Explorer Dongle , attach to the LAPTOP, and you will have direct access to the serial and programming pins on the XBee unit.
Features:
- USB A Type Connector
- Built in SMD fuse for protecting PC USB Port
- Powered from PC USB Port
- High Current (500ma) 3V3 Voltage Regulator for XBee/XBee PRO Module
- 5 Onboard Status LEDs (Associate,Sleep,Tx,Rx and RSSI)
- Onboard Power LED
- High qualty PTH PCB and made by Automatic Pick
and Place Machine
Specifications:
PIN Diagram:
PIN descriptions are given below:
Layout:
How to Test:
Test your XBee Explorer Dongle with PC:- When XBee Explorer Dongle is connected with USB port of PC,the PWR (blue) LED will glow on the top of module ,it shows power indication.
- For a quick installation on XBee Explorer Dongle and connection details please read the blog…
- Here we are using a paired Zigbee, to construct a simple point-to-point network.One of the devices must be a Coordinator and the other must be a Router (an ‘endpoint’ device).
- After completion of installation setup SLP LED(Green) is turn ON and also ASSOC LED(Red) will blink rapidly 2 times per seconds(Association Confirmation received to the endpoint device from the Coordinator) or ASSOC LED will not blink if the End Device has not associated.
- During the transmission TXD led blinks as per the data rate and at the time of reception RXD led blinks.
- RSSI LED(yellow) on top of the board is connected to the RSSI (Received Signal Strength Indicator) pin of the XBee module. XBee outputs a PWM signal on this pin which is directly proportional to the quality of the RF signal, until the last packet was received by it. This PWM signal applied to the RSSI LED will vary its brightness as per the quality of the RF signal,better the RF signal brighter the LED.
Here below one example is shown:
- Placing XBee module on XBee Explorer Dongle is shown below.
- In this example we are making communication between two paired zigbee COM PORT of coordinator zigbee is set in Hyperterminal and wrote a message like here it is “Hai Xbee connected” sent it to end point Xbee.
- And we opened other terminal window i.e realterm and COM PORT set in realterm terminal window is of End point Xbee and received message sent from coordinator Xbee in realterm.Click here to download realterm.
Note:The
above message shown in hyperterminal is written from
coordinator XBee and simultaneously sent to the end device XBee.
n the Raspberry Pi2 section
open the LX terminal and type lsusb.
The response showed inside a red box indicates the presence of a usb device in the module. Write a python script to perform Zigbee communication which is given below.
The two zigbee must be in a line of sight and check the results in the Python shell and in the hyperterminal of the computer.
The Communication could also be established with two Raspberry Pi or with another controller it self.
import serial
# Enable USB Communication
ser = serial.Serial('/dev/ttyUSB0',
9600,timeout=.5)
while True:
ser.write('Hello User \r\n')
# write a Data
gk = ser.readline().strip()
print 'Received Data : '+ gk
super
ReplyDelete