Template: ARPI600 User Manual/Building a wireless network with two XBee modules
From Waveshare Wiki
Building a wireless network with two XBee modules
Preparations
- Two XBee modules
- Two ARPI600 modules
- 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
- 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.
- 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
- Connect XBee-A to ARPI600-A, and XBee-B to ARPI600-B, respectively.
- 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
- Power up Raspberry Pi board.
- Click the button Test/Query to check whether the connection between the ARPI600 and the XBee is established successfully.
- For a successful connection, you can see the dialog box as the figure shows.
Configuring XBee-A module
- Select the option Modem Configuration, and click the button Read to read out the current parameters of XBee.
- Select the option ZIBGEE ROUTER/END DEVICE AT under the pull-down menu Function Set:
- Set the read Networking parameters:
- ID: 234
- DH: 0
- DL: 0
- Click the button Write to download the configured parameters into the XBee-A module
Configuring XBee-B module
- 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:
- Set the read Networking parameters:
- ID: 234
- DH: 0
- DL: ffff
- Click the button Write to download the configured parameters into the XBee-B module.
- 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.
- 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.
- 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
2) Test the Raspberry Pi serial port:
Execute:
cd /Xbee/getdata sudo make sudo ./serialTest
The serial terminal prints out the following
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:
RTC clock
- Set the jumpers on RTC JMP of the ARPI600.
- Open the LXTerminal on the desktop of Raspbian, and input the code:
i2cdetect -y 1
- 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.
- 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.
- 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
- Please make sure you have installed relative libraries (refer to the Section 2.2: Installing relative libraries).
- 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.
- 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
- Terminal will display relative AD conversion value. By default, the displayed conversion value comes from Pin AD0 on TLC1543 (Pin T_A0 on ARPI600).
- Connect the jumpers T_A0 to A0, then the Pin A0 on the Arduino interface can serve as an AD conversion pin, as shown.
Configuring as other AD pins
- 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.
- Find out the following line:
- Execute the following code under the terminal:
sudo make
sudo ./tlc1543
- Now, the modification is in effect.