How to Use XBee Modules As Transmitter & Receiver - Arduino Tutorial

145,337

74

30

Introduction: How to Use XBee Modules As Transmitter & Receiver - Arduino Tutorial

About: Arduino Tutorials by Codebender.cc Team

In this tutorial we will use two xBee (series 1) modules with the Arduino uno board. We will configure them to act as a receiver and transmitter to control the brightness of an LED wirelessly by using one potentiometer.

The xBee - series 1 - modules take the 802.15.4 stack (the basis for Zigbee) and wrap it into a simple to use serial command set. These modules allow a very reliable and simple communication between micro controllers, computers or other systems by using just a serial port!

They can communicate up to 300 Ft (~100m), they have 2.4GHz frequency , use the 802.15.4 protocol and have data rate up to 250kbps. They have also a 1mW wire antenna on them. They supports Point to point and multi-point networks.

You can see the result of this tutorial on the below video :

So, let's get started!

Step 1: What You Will Need

For this tutorial you will need:

  • 2x Arduino uno boards
  • 2x xBee series 1 modules
  • 2x XBee Explorer Regulated boards
  • XBee Explorer USB
  • 220 Ohm resistor
  • potentiometer (e.g. 2k)
  • led
  • 2x breadboards
  • some breadboard cables

Step 2: XCTU - Setup Your XBee Modules

Download the XCTU software from here.

Run the program and connect the XBee Explorer USB board with your computer.

Click on the "Discover devices" icon to add your xBee in the XCTU software.

Now click on it (first image above) and set the CH field to e.g. "C" and the ID field to e.g. "1001". These values must be the same to all xBee modules to communicate with each other. Now as this xBee will be our transmitter, set the CE field as "Coordinator". If the baud rate isn't set to 9600bps, change it to this value.

Now click the "Write" button to save the changes in your xBee module.

Disconnect the xBee explorer board from your computer and connect the other xBee module on it.

Connect the explorer board with your computer again and follow the same procedure (second image above) but this time set the CE field as "End device".

Finally the configuration for our xBees must be:

For xBee transmitter:

  • CH: C
  • ID: 1001
  • CE: Coordinator
  • Baud rate: 9600 bps

For xBee receiver:

  • CH: C
  • ID: 1001
  • CE: End point
  • Baund rate: 9600 bps

Step 3: The Code

Here's the "xBee Transmitter" code, embedded using Codebender!

Try downloading the Codebender plugin and clicking on the "Run on Arduino" button to program your Arduino board with this sketch. And that's it, you've programmed your Arduino uno board with this sketch!

And here's the "xbee Receiver" code, connect the second Arduino uno board with your computer and press the "Run on Arduino " button.

Step 4: The Circuit

The connections are pretty easy, see the above image with the breadboard circuit schematics.

Power on both Arduino uno boards and try to fade the led by turning the potentiometer.

Step 5: Well Done!

You have successfully completed one more "How to" tutorial and you learned how to fade an LED wirelessly by using the xBee S1 modules.

I hope you liked this, let me know in the comments.

There will be more of them, so make sure to click Follow button!

1 Person Made This Project!

Recommendations

  • Arduino Contest

    Arduino Contest
  • Box Challenge

    Box Challenge
  • Explore Science Challenge

    Explore Science Challenge

30 Comments

Hello to everyone, is there a limit in distance between the XBEE transmitter and receiver?

0
jancharlie
jancharlie

5 months ago

Isn't it necessary to insert an attenuator between Arduino Tx and XBee Rx?

0
rysspol
rysspol

8 months ago on Introduction

Hi,
Does that contradict the idea of ZigBee / Xbee. Why an additional Arduino in the transmitter if XBee has its own pins. After all, *** Bee was designed to make the device power supply very low. small battery (long life) Such Arduino only increases this power unnecessarily. I am looking for a solution where the transmitter is only X (Zig) Bee and the receiver is X (Zig) Bee connected to the module (Nodemcu or Raspberry). The receiver only passes the serial info on. Imagine an alarm system that sends a text message to you if the pin on the transmitter has changed its state after someone opened the door.
Sorry my language. I translate my think from Google translator.

*** - X or Zig

0
indrayunartanto21
indrayunartanto21

1 year ago

Thank you so much for basic lesson to using XBee Module

0
Bagusiero
Bagusiero

1 year ago

can i changed to send the DHT11 temperature ?

0
Waqas_Wani
Waqas_Wani

Reply 1 year ago

yes absolutely

0
Waqas_Wani
Waqas_Wani

Answer 1 year ago

no

0
calou2626
calou2626

2 years ago

bonjour,
comment faire pour piloter 2 led avec 2 pot.
how can y do with 2 led and 2 pot.

1
xMarYx
xMarYx

5 years ago

Hi, Great tutorial.

I am doing something similar. Just one thing though, i cant seems to properly tweak the receiving coding to get another set of analog input to control another LED. I have 2 POT and 2 LED. One to control another

0
calou2626
calou2626

Reply 2 years ago

hi,
have you succed with 2 pot and 2 led?

0
avishkars1
avishkars1

Question 2 years ago

Hey guys.. I am working on a project which involves Zigbee.Can someone help me out with these questions? I'd really appreciate
1. How do you configure a Zigbee device for a WSN. What are the fundamental requirements to configure it?
2. The basic requirements for designing software to extract and store data from any communicating devices such as Zigbee.
3. How a Zigbee based WSN can avoid interferences from another Zigbee based sensor network in the same region?

0
EmdadulH2
EmdadulH2

Question 2 years ago

Can I made it using xBEE Series 2??

0
KartikB4
KartikB4

2 years ago

I am trying to transfer button pulse values for 9 buttons
100010010
Each digit giving the status of a button
Is this the right way or is there a better way of doing it?
How do I transfer these values?

0
SahlaS
SahlaS

Question 2 years ago on Step 5

Can a zigbee module act as transmitter and reciever at the same time?

0
ScienceTrip
ScienceTrip

Question 2 years ago on Step 1

Is it possible to have 2 transmitters talking to 1 receiver module?

0
engrshaukat
engrshaukat

2 years ago

is it possible to connect multiple arduinos without master-salve configuration??

0
kurakulaanusha8
kurakulaanusha8

2 years ago

Hi

I am doing a project based on ZigBee on both the sides transmitter and receiver but m not using arduino instead of that m using micro controller so plz can u help me in coding

0
ThierryV
ThierryV

Question 3 years ago on Step 5

Hello,

I want to know if I can be able to understand by learning a zigbee thermostat and be able to send commands to it ?

Best regards and thanks for the post

0
PRAKASHS69
PRAKASHS69

3 years ago

what shld be done in case of xbee s2c?