Template: ARPI600 User Manual/Building a wireless network with two XBee modules

From Waveshare Wiki
Jump to: navigation, search

Building a wireless network with two XBee modules

Preparations

  1. Two XBee modules
  2. Two ARPI600 modules
  3. Twp Raspberry Pi boards
    • In this document, we will divide the device above into two groups: Group A and Group B(XBee-A, ARPI600-A, XBee-B, and ARPI600-B)

Installing X-CTU tool

  1. Double click the file software/X-CTU V5.2.8.6.exe on your PC to start installing X-CTU tool. After a successful installation, you can open the X-CTU tool as the figure shows.
    X-CTU setting
    ARPI600-UserManual-6.jpg
  2. Configure the XBee module. The default setting of XBee is as follows:
    • Baud: 9600
    • Data Bite: 8
    • Parity: NONE
    • Stop: 1

Testing the connection between PC and XBee

  1. Connect XBee-A to ARPI600-A, and XBee-B to ARPI600-B, respectively.
  2. Set the jumpers on ARPI600 to start up the serial debugging function for the XBee, as the figure shows.
    • Connect XB_RX to CP_RX
    • Connect CP_TX to XB_TX
    Jumpers setting for serial debugging function between the Pi and the XBee
    ARPI600-UserManual-7.jpg
  3. Power up Raspberry Pi board.
  4. Click the button Test/Query to check whether the connection between the ARPI600 and the XBee is established successfully.
    ARPI600-UserManual-8.jpg
  5. For a successful connection, you can see the dialog box as the figure shows.
    Successful connection
    ARPI600-UserManual-9.jpg

Configuring XBee-A module

  1. Select the option Modem Configuration, and click the button Read to read out the current parameters of XBee.
    Reading out current parameters
    ARPI600-UserManual-10.jpg
  2. Select the option ZIBGEE ROUTER/END DEVICE AT under the pull-down menu Function Set:
    Selecting the option ZIBGEE ROUTER/END DEVICE AT under Function Set
    ARPI600-UserManual-11.jpg
  3. Set the read Networking parameters:
    • ID: 234
    • DH: 0
    • DL: 0
  4. Click the button Write to download the configured parameters into the XBee-A module

Configuring XBee-B module

  1. Configure the XBee-B module according to the processes described in the Section 3.1 and the Section 0. However, there is something different. In configuring XBee-B, you should select the option ZIBGEE COORDINATOR AT under the pull-down menu Function Set:
    Selecting the option ZIBGEE COORDINATOR AT under Function Set
    ARPI600-UserManual-12.jpg
  2. Set the read Networking parameters:
    • ID: 234
    • DH: 0
    • DL: ffff
  3. Click the button Write to download the configured parameters into the XBee-B module.
  4. To implement a simple P2P network, please configure XBee-A and XBee-B according to the processes described above. Start two X-CTU tools, and select different COM interfaces in the option PC Settings to control Group A and Group B respectively.
  5. Input the data to be transmitted in the X-CTU Terminal of XBee-A, then, you can find that the inputted data will be sent to XBee-B automatically, and displayed in the X-CTU Terminal of XBee-B. In the X-CTU, data in blue is the data to be sent, and data in red is the received data.
    Data transmission and receive
    ARPI600-UserManual-13.jpg
  6. This Figure shows the normal operating state of the XBee module.

Raspberry Pi transmits data wirelessly via XBee

After making sure that the wireless transmission network of 2 XBee is normal, now the Raspberry Pi can transmit data wirelessly through XBee.
1) Set the ARPI600 jumper:
Connect the two Raspberry Pi serial ports for sending and receiving to the XBee serial port, and the ARPI600 expansion board jumpers according to the red frame in the figure below.

  • XB_RX connects to P_TX
  • XB_TX connects to P_RX

XBTX.png
2) Test the Raspberry Pi serial port:
Execute:

cd /Xbee/getdata
sudo make
sudo ./serialTest 

The serial terminal prints out the following
Cd.png
Run the sender code again, copy program/Xbee/send to the sender Raspberry Pi system, enter the send folder, and execute.
sudo make sudo ./serialTest Then the receiver will print the received data:
Xbee2.png

RTC clock

  1. Set the jumpers on RTC JMP of the ARPI600.
  2. Open the LXTerminal on the desktop of Raspbian, and input the code:
    i2cdetect -y 1
  3. Then, you will see the device address of PCF8563 connected to Raspberry Pi. Here, the device address of PCF8563 is 51, which means the PCF8563 is identified by Raspberry Pi.
    The device address of PCF8563 connected to Raspberry Pi
    ARPI600-UserManual-17.jpg
  4. Enter LXTerminal, and run:
modprobe i2c-dev
echo pcf8563 0x51 > /sys/class/i2c-adapter/i2c-1/new_device
hwclock -r# (time to read the connected I2C hardware RTC)

LXTerminal will print out the PCF8563 time, which is different from the system time.

  1. Execute in LXTerminal
hwclock -w # (write the time of the Raspberry Pi system to PCF8563)
hwclock -r # (The time of the Raspberry Pi system is synchronized to the PCF8563)
hwclock -s # (set the system time to synchronize with the hardware's RCT clock)

AD conversion (ARPI600 on-board chip TLC1543)

Configuring Pin A0 to Pin AD

  1. Please make sure you have installed relative libraries (refer to the Section 2.2: Installing relative libraries).
  2. Set the jumpers to select reference voltage:
    • Connect REF to 5V, which means the AD conversion reference voltage is 5V (connecting to 5V is a default setting).
    • Connect REF to 3V3, which means the AD conversion reference voltage is 3.3V.
    Notices: REF can only be connected to one reference voltage at a time.
    Setting AD reference voltage
    ARPI600-UserManual-18.jpg
  3. Copy the file program/AD_TLC1543 in to Raspbian. Then, enter the folder AD_TLC1543, and execute the following code under the terminal:
    sudo make
    sudo ./tlc1543
  4. Terminal will display relative AD conversion value. By default, the displayed conversion value comes from Pin AD0 on TLC1543 (Pin T_A0 on ARPI600).
  5. Connect the jumpers T_A0 to A0, then the Pin A0 on the Arduino interface can serve as an AD conversion pin, as shown.
    connecting Pin T_A0 to Pin A0
    ARPI600-UserManual-19.jpg

Configuring as other AD pins

  1. If you want to display the conversion value from other AD pins on TLC1543, please enter the terminal and edit the file tlc1543.c:
    sudo nano tlc1543.c
    Find out the following line:
    re=ADCSelChannel(0);
    Modify the "0" in the line into the number corresponding to the other AD pins (For example, modify to "1" for testing the conversion value from Pin AD1 (Pin T_A1), and modify to "2" for testing the conversion value from Pin AD2 (Pin T_A2), and so on, until to "10" for testing the conversion value from Pin AD10 (T_A10)).
    After completing the operation described above, press the keys Ctrl+X, and select the option Y to save the modification.
  2. Execute the following code under the terminal:
    sudo make
    sudo ./tlc1543
    Now, the modification is in effect.