In the previous tutorial, we learned how to connect a Zig-Bee module to a PC using an FTDI USB to serial converter cable or USB cable and an Arduino board and various AT commands were tested. In this tutorial, a Zig-Bee module will be used to read analog data and transmit it to another module. The Zig-Bee module comes with 6 analog input pins and 8 digital input output pins. Any analog input pin can be used to read analog voltage. To read the analog voltage, it is necessary to define a reference voltage for the module. The process of reading analog data from the Zig-Bee module and passing the data to another module is called Analog I/O Line Passing.
Required components –
1) X-Bee Modules – 2
2) Arduino UNO
3) Test boards
4) Connecting Wires
5) FTDI USB to serial converter cable
6) PC
7) 10K Pot
Circuit Connections –
In this project, two X bee series 1 (S1) modules are used. One module serves as the Transmitter and the other as the Receiver. Both modules will be PCs connected to pass AT commands and monitor data transfer. An X-Bee module is a 20-pin module with the following pin configuration –
To connect a Zig-Bee module to the PC, an FTDI USB to serial converter cable can be used. The converter cable has four pins – VCC, Ground, RX and TX. These pins must be connected to the X-Bee module as follows –
Another way to connect the X-Bee module to the PC is to connect it via the Arduino board. The PC and Arduino board can be connected by a USB cable. The RX and TX pins of the Arduino can be connected to the Tx and RX pins of the Zig-Bee module and the Reset pin of the Arduino UNO can be grounded. Now, by loading the 'Bare Minimum' Arduino Sketch onto the board, it can be used for serial communication with the X-Bee module.
Both modules need to be powered by 3.3V batteries. According to the pin configuration of the X-Bee modules, the positive terminal of the battery must be connected to pin 1 of the module and the negative terminal to pin 10 of the module.
The X-Bee module to be used as a transmitter will be supplied with an analog input through a 10K potentiometer. One terminal of a 10K ohm potentiometer must be connected to VCC and the other terminal to ground. The middle terminal of the pot must be connected to pin 20 of the Zig-Bee module, as the module's analog input 0 will be used to read analog data. The pin will be configured for analog input using AT commands. Pin 14 of the module must be connected to 3.3V as pin 14 is the reference voltage pin which will be set to 3.3V.
The X-Bee module to be used as a receiver will have an LED connected to pin 6 of the module. Pin 6 of the X-Bee is pulse width modulation output 0. The pin will be used to generate a PWM signal that will vary depending on the potentiometer. The LED will disappear according to the potentiometer due to the PWM signal varying according to the analog input on the transmitter module.
How the circuit works –
AT commands will be used to configure both modules. The transmitter module will be configured to read analog data and pair with the receiver module to pass the data to it. Commands will be transferred via the 'CoolTerm' application on the PC. In the transmitter module the following configuration parameters must be changed –
1) PAN ID
2) Low Destination Address
3) Origin address
4) Data I/O pin 0 (20th pin)
5) I/O sampling rate
These parameters will be set to the following values using the AT commands –
1) PAN ID = 0x3332
2) Lower destination address = 0x22
3) Source address = 0x24
4) Data I/O pin (D0) = 0x02 (passing 0x02 sets the pin for analog input)
5) I/O sampling rate = 0x1E (30 seconds)
The following AT commands are passed to change the configuration parameters of the transmitter module –
The receiver module will be configured to pair with the transmitter module and generate PWM on pin 6 according to the analog data passed. On the receiver module, the following configuration parameters must be changed –
1) PAN ID
2) Low Destination Address
3) Origin address
4) PWM pin (6th pin)
5) Define ATIA
These parameters will be set to the following values using the AT commands –
1) PAN ID = 0x3332 (Setting the PAN ID equal to the transmitter address pairs the two modules)
2) Destination address low = 0x24 (Receiver's DL address must be the same as transmitter's source address)
3) Source address = 0x22 (the transmitter's destination low address must be the same as the receiver's source address)
4) PWM pin (Po) (module pin 6) = 0x02 (Passing 0x02 configures the pin for analog output)
5) Set “ATIA” as the transmitter source address (24) so that pin 6 (PWM) of the receiver follows the changes in pin 20 of the transmitter.
ATIA is the address command. Helps enable pin output mode updates from the other X-Bee radio. It should be noted that D0 in the transmitter is a digital pin and the data received also in digital form, but the PWM output is analog, because PWM acts as a DAC here.
The following AT commands are passed to change the receiver module configuration parameters –
After configuring each module, the settings must be saved by sending the ATWR command and finally exit AT mode using the 'ATCN' command. After configuring the modules and saving the settings, when changing the potentiometer value on the transmitter side, the LED on the receiver side will gradually appear and disappear.
This tutorial demonstrated passing an analog I/O line between two X-Bee modules. In the next tutorial on Zig-Bee interface, digital data will be read in the X-Bee module and passed to another X-Bee module.
Project source code
Project source code
###
//Program to
###