0
0
Drone-programmingHow-ToBeginner · 4 min read

How to Configure XBee Module in IoT for Wireless Communication

To configure an XBee module in IoT, connect it to a serial interface and use AT commands via a terminal or software like XCTU to set parameters such as PAN ID, baud rate, and destination address. This setup enables wireless communication between devices in your IoT network.
📐

Syntax

The basic syntax to configure an XBee module uses AT commands sent over a serial connection. Each command starts with AT followed by the command code and optional parameters.

  • ATIDxxxx: Sets the PAN ID (network ID).
  • ATDLxxxx: Sets the destination address low.
  • ATMYxxxx: Sets the module's own address.
  • ATBDx: Sets the baud rate.
  • ATWR: Writes the configuration to memory.
  • ATCN: Exits command mode.

Commands are sent after entering command mode by sending +++ without line endings.

plaintext
+++
ATID1234
ATDL5678
ATMY0001
ATBD4
ATWR
ATCN
Output
OK OK OK OK OK OK
💻

Example

This example shows how to configure two XBee modules to communicate wirelessly by setting their PAN ID, addresses, and baud rate using AT commands.

plaintext
+++
ATID1A2B
ATDL2B3C
ATMY1A2B
ATBD3
ATWR
ATCN
Output
OK OK OK OK OK OK
⚠️

Common Pitfalls

Common mistakes when configuring XBee modules include:

  • Not entering command mode properly (send +++ without line endings and wait for OK).
  • Using mismatched PAN IDs between modules, which prevents communication.
  • Setting incorrect baud rates causing serial communication failure.
  • Forgetting to save settings with ATWR, so changes are lost after reboot.

Always verify settings with ATAC (read configuration) before exiting.

plaintext
+++
ATID1234
ATWR
ATCN
+++
ATID5678
ATWR
ATCN
Output
OK OK OK OK OK OK OK
📊

Quick Reference

CommandDescriptionExample
ATIDxxxxSet PAN ID (network ID)ATID1A2B
ATDLxxxxSet destination address lowATDL2B3C
ATMYxxxxSet module's own addressATMY1A2B
ATBDxSet baud rate (0-7)ATBD3
ATWRWrite settings to memoryATWR
ATCNExit command modeATCN

Key Takeaways

Enter command mode by sending +++ without line endings and wait for OK.
Set matching PAN ID and addresses on XBee modules for successful communication.
Always save changes with ATWR to keep configuration after reboot.
Use XCTU software or serial terminal to send AT commands easily.
Verify settings with ATAC before exiting command mode.