Coordinator (Transmitter) Code: #include #include // constants won't change. They're used here to set pin numbers: const int buttonPin = 7; // the number of the pushbutton pin const int ledPin = 13; // the number of the LED pin // Variables will change: int ledState = HIGH; // the current state of the output pin int buttonState; // the current reading from the input pin int lastButtonState = LOW; // the previous reading from the input pin // the following variables are unsigned longs because the time, measured in // milliseconds, will quickly become a bigger number than can be stored in an int. unsigned long lastDebounceTime = 0; // the last time the output pin was toggled unsigned long debounceDelay = 50; // the debounce time; increase if the output flickers SoftwareSerial Xbee(2, 3); // RX, TX //---------------------------------------------------- void setup() { pinMode(buttonPin, INPUT); pinMode(ledPin, OUTPUT); Serial.begin(9600); Xbee.begin (9600); // set initial LED state digitalWrite(ledPin, ledState); } //---------------------------------------------------- void loop() { // read the state of the switch into a local variable: int reading = digitalRead(buttonPin); // check to see if you just pressed the button // (i.e. the input went from LOW to HIGH), and you've waited long enough // since the last press to ignore any noise: // If the switch changed, due to noise or pressing: if (reading != lastButtonState) { // reset the debouncing timer lastDebounceTime = millis(); } if ((millis() - lastDebounceTime) > debounceDelay) { // whatever the reading is at, it's been there for longer than the debounce // delay, so take it as the actual current state: // if the button state has changed: if (reading != buttonState) { buttonState = reading; // only toggle the LED if the new button state is HIGH if (buttonState == HIGH) { ledState = !ledState; } } } // set the LED: digitalWrite(ledPin, ledState); Xbee.write(ledState); Serial.println(ledState); // save the reading. Next time through the loop, it'll be the lastButtonState: lastButtonState = reading; } ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- End Device (Receiver) code: #include #include SoftwareSerial Xbee(2, 3); int data = 0; //---------------------------------------------------- void setup() { Serial.begin(9600); Xbee.begin(9600); pinMode(7, OUTPUT); } //---------------------------------------------------- void loop() { while(Xbee.available()) { data=Xbee.read(); Serial.print(data); } if(data==0) { digitalWrite(7, LOW); } if(data==1) { digitalWrite(7, HIGH); } }
Hi. I'm trying to run this kid - digi xk-z11-t-w. But i receive the next error. I work with digi esp for python, and i'm trying to use digi tank solution simulation. Any help?
XTankSensor: DoCommandRequestForMiscSensorInformation -> START! XTankSensor: DoCommandRequestForMiscSensorInformation -> REQUEST SENT! XTankSensor: scheduling a state machine callback of 20 seconds and a backup callback of 30 seconds.
What is the schematic of the switch? I have hooked it up and programed it exactly like you say but I can not get it to work. Is the 5v and the resistor common and the terminal connected to pin7 make the connection? I think I have my pushbutton set up wrong....Please Help!
what really changes if I use 2 xbee series2, an Arduino UNO, and a NANO?.. its all I have. thank you so much! Great video. Also its 3 years later so what changes since then?.. if you know. thank you !
Great Man. Congrats for you. Please, Your code when finish the Power Up of the Arduino the X-BEE alrealdy to start to transmit without any command over the pushbutton....Someone here Can help me?
Thank you for your helpful video ! I wanna know how I can send two data in the same time. I’m actually working with Dht22. And I want to send temperature and humidity using 2 xbee s2c pro and two Arduino ! Thank you
Can a Zigbee sensor data be read in XBee module? I have Zigbee PIR Sensor of different make. I want to read its data on my Raspberry Pi. I have an Xbee module with its USB Dongle. Please guide.
Hello i'm doing a project with Xbee and i don't know where to start. Basically what i want to do is a wireless object counter.The Xbee must be able send the number of object to the computer wirelessly (with the aid of arduino and ultrasonic sensor) whenever an object passes near the sensor. Any advice on how to do this please? Thank you.
Probably a bit late on this but XBee is a radio transmitter. I don't think most computers have radio capabilities. So I suppose you could connect an XBee to your PC. Doesn't Arduino have Bluetooth? If not I'm sure there's a shield for that. I feel like that might work. But who knows. I'm curious what you ended up doing though.
Hey I have a doubt ...I have configured both the radios to be end user, actr the transmitter is supposed to be coordinator and the receive is supposed to be the end-user right ??
UPDATE: New video posted (Wireless and Hands-free Prototype Light Switch) It uses the same XBee radios shown in this video Link: th-cam.com/video/A8MTWsSVoEQ/w-d-xo.html
Like your videos great work and now my question is I have xbee mod sheild and one xbee Bluetooth wireless module so my question is would it still work or I need to get the same cuz talking to the people at this electronic store they said it will because they the same xbee but the other xbee said xbee Bluetooth module and the other day xbee sheild module
hello...your work is very interesting Well I did everything on your tutorial.... but unfortunately it is not working with me I did all the checks....both Xbees are communicating with each other...the codes are same as yours....I just don't know what is the problem Any Advice?? Thanx in advance
how to order a robot with 4 button pussoire transmitter (arduino1) / receiver (arduino2) with this principle of Xbee as on the example of led please answer me ?????
yougourthene brinis You can use the same principle shown in this video but instead of having the receiver XBee controlling an LED have it control a motor driver
This is perfect for my application! Great job! Can you please post the Arduino code in the coments or provide a link to the code please? Thank you so much!
why is the TX and RX goes to pin 2 and 3 in the arduino? the RX and TX text in arduino is on pin 0 and 1. i really new to xbee, pls help me Thank you in advance
Michael Nathaniel Hi Michael. At that time, I encountered some issues when I used the hardware serial ports of the arduino (pins 0 and 1) with the XBEE shield. Hence I used the “softwareserial” library to configure pins 2 and 3 to act as TX and RX so that I can receive serial data from the XBee radios. With the softwareserial library, you can configure any digital pin on the arduino to function as TX and RX, similarly to pins 0 and 1 and in this case I used pins 2 and 3.
@@mujtech4887 Thank you for replying. i use pin 0 and 1 for the RX and TX, and i think it works. But something is wrong when i receive the data i send. when i print the received data, i got a bunch of number and i don't know what it is. here is my code for send data. #include #include #include SoftwareSerial XBee(0,1); String data; void setup() { // put your setup code here, to run once: Serial.begin(9600); XBee.begin(9600); data = "test send data"; } void loop() { delay(3000); // put your main code here, to run repeatedly: static char *dataSend = data.c_str(); // need to use c_str() because the write function don't accept String XBee.write(dataSend); } and her is the receive code #include #include #include SoftwareSerial XBee(0,1); String data; void setup() { // put your setup code here, to run once: Serial.begin(9600); XBee.begin(9600); } void loop() { delay(3000); // put your main code here, to run repeatedly: while(XBee.available()) { data = XBee.read(); Serial.print(data); // Serial.print((char)data); Serial.print(" "); } Serial.println(); Serial.println("===================="); } can you help me? in your tutorial, you just send a number(1 or 0). can you tell me how to send a String? or there is another way? i need to send some datas from sensors.
Michael Nathaniel I still haven’t tried to send string data via arduino. From what you’re telling me, the numbers that you are receiving are the ASCI codes of the characters that are sent from the transmitter and it’s showing like that because you’re printing them at the receiver using “serial.print”. Perhaps if you change it to “serial.write” it might work?
I have a question, why you use pin 2 and 3 in arduino for RX, TX from xbee? it is possible if I use pin RX, TX in arduino directly to connect TX,RX from xbee?
Pins 0 and 1 are hardware serial ports that can only transmit and receive to one device at a time. Since we are using the serial commands in this code, we are communicating the Arduino with the computer via these pins so we can't also use them to communicate it with the XBee radios. Hence, the digital pins are used. In the Arduino Mega however, you are given 3 hardware serial ports to choose from so you can use two ports at the same time without the need of using the digital pins like I did in this video.
ooh sir, i have another question. i wonder if i want to controll the LED intensity with potensiometer, can you explain it? i've tried but still failed. thanks
Thank you! Im No longer scared of Xbee
Do u recommend having a 1k resisitor between rx and tx pins instead of direct connection like you show?
Austin Mosley if you’re using a shield then you don’t need a resistor otherwise yes
Coordinator (Transmitter) Code:
#include
#include
// constants won't change. They're used here to set pin numbers:
const int buttonPin = 7; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
// Variables will change:
int ledState = HIGH; // the current state of the output pin
int buttonState; // the current reading from the input pin
int lastButtonState = LOW; // the previous reading from the input pin
// the following variables are unsigned longs because the time, measured in
// milliseconds, will quickly become a bigger number than can be stored in an int.
unsigned long lastDebounceTime = 0; // the last time the output pin was toggled
unsigned long debounceDelay = 50; // the debounce time; increase if the output flickers
SoftwareSerial Xbee(2, 3); // RX, TX
//----------------------------------------------------
void setup()
{
pinMode(buttonPin, INPUT);
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
Xbee.begin (9600);
// set initial LED state
digitalWrite(ledPin, ledState);
}
//----------------------------------------------------
void loop()
{
// read the state of the switch into a local variable:
int reading = digitalRead(buttonPin);
// check to see if you just pressed the button
// (i.e. the input went from LOW to HIGH), and you've waited long enough
// since the last press to ignore any noise:
// If the switch changed, due to noise or pressing:
if (reading != lastButtonState) {
// reset the debouncing timer
lastDebounceTime = millis();
}
if ((millis() - lastDebounceTime) > debounceDelay) {
// whatever the reading is at, it's been there for longer than the debounce
// delay, so take it as the actual current state:
// if the button state has changed:
if (reading != buttonState) {
buttonState = reading;
// only toggle the LED if the new button state is HIGH
if (buttonState == HIGH) {
ledState = !ledState;
}
}
}
// set the LED:
digitalWrite(ledPin, ledState);
Xbee.write(ledState);
Serial.println(ledState);
// save the reading. Next time through the loop, it'll be the lastButtonState:
lastButtonState = reading;
}
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
End Device (Receiver) code:
#include
#include
SoftwareSerial Xbee(2, 3);
int data = 0;
//----------------------------------------------------
void setup()
{
Serial.begin(9600);
Xbee.begin(9600);
pinMode(7, OUTPUT);
}
//----------------------------------------------------
void loop()
{
while(Xbee.available())
{
data=Xbee.read();
Serial.print(data);
}
if(data==0)
{
digitalWrite(7, LOW);
}
if(data==1)
{
digitalWrite(7, HIGH);
}
}
For those who have a shield with an XBEE/USB switch, mine only worked on the USB setting. Took like 6 hours to figure that out
nice job! very understandable and i liked the step by step setup and visible code - maybe make your code downloadable? i hope you do some more! thx
Thank you!
Why you did a software serial. Why you didn’t connect them directly to pins tx rx (0,1)
Hi. I'm trying to run this kid - digi xk-z11-t-w. But i receive the next error. I work with digi esp for python, and i'm trying to use digi tank solution simulation.
Any help?
XTankSensor: DoCommandRequestForMiscSensorInformation -> START!
XTankSensor: DoCommandRequestForMiscSensorInformation -> REQUEST SENT!
XTankSensor: scheduling a state machine callback of 20 seconds and a backup callback of 30 seconds.
What is the schematic of the switch? I have hooked it up and programed it exactly like you say but I can not get it to work. Is the 5v and the resistor common and the terminal connected to pin7 make the connection? I think I have my pushbutton set up wrong....Please Help!
what really changes if I use 2 xbee series2, an Arduino UNO, and a NANO?.. its all I have. thank you so much! Great video. Also its 3 years later so what changes since then?.. if you know. thank you !
Can you do a demo for ultrasonic sensor data transmission using XBEE+Arduino
Great Man. Congrats for you. Please, Your code when finish the Power Up of the Arduino the X-BEE alrealdy to start to transmit without any command over the pushbutton....Someone here Can help me?
Thank you for your helpful video !
I wanna know how I can send two data in the same time. I’m actually working with Dht22. And I want to send temperature and humidity using 2 xbee s2c pro and two Arduino ! Thank you
Can a Zigbee sensor data be read in XBee module? I have Zigbee PIR Sensor of different make. I want to read its data on my Raspberry Pi. I have an Xbee module with its USB Dongle. Please guide.
Hello i'm doing a project with Xbee and i don't know where to start. Basically what i want to do is a wireless object counter.The Xbee must be able send the number of object to the computer wirelessly (with the aid of arduino and ultrasonic sensor) whenever an object passes near the sensor. Any advice on how to do this please? Thank you.
Probably a bit late on this but XBee is a radio transmitter. I don't think most computers have radio capabilities. So I suppose you could connect an XBee to your PC. Doesn't Arduino have Bluetooth? If not I'm sure there's a shield for that. I feel like that might work. But who knows.
I'm curious what you ended up doing though.
What is the range of these radio communication components?
Hey I have a doubt ...I have configured both the radios to be end user, actr the transmitter is supposed to be coordinator and the receive is supposed to be the end-user right ??
Hi, im trying to do this but I have xbee series 2, do I have to configure it differently? When I was configuring them, there was no MY section
How long( in meters) they can communicate?
UPDATE: New video posted (Wireless and Hands-free Prototype Light Switch)
It uses the same XBee radios shown in this video
Link: th-cam.com/video/A8MTWsSVoEQ/w-d-xo.html
Like your videos great work and now my question is I have xbee mod sheild and one xbee Bluetooth wireless module so my question is would it still work or I need to get the same cuz talking to the people at this electronic store they said it will because they the same xbee but the other xbee said xbee Bluetooth module and the other day xbee sheild module
Unfortunately Adapter is no longer for purchase
hello...your work is very interesting
Well I did everything on your tutorial.... but unfortunately it is not working with me
I did all the checks....both Xbees are communicating with each other...the codes are same as yours....I just don't know what is the problem
Any Advice??
Thanx in advance
how to order a robot with 4 button pussoire transmitter (arduino1) / receiver (arduino2) with this principle of Xbee as on the example of led please answer me ?????
yougourthene brinis You can use the same principle shown in this video but instead of having the receiver XBee controlling an LED have it control a motor driver
i need links for arduino programming
I posted the code in the comments
Hey can you send me the link to the project? THANKS
This is perfect for my application! Great job! Can you please post the Arduino code in the coments or provide a link to the code please? Thank you so much!
me to I need the code please ,
why is the TX and RX goes to pin 2 and 3 in the arduino? the RX and TX text in arduino is on pin 0 and 1. i really new to xbee, pls help me
Thank you in advance
im using xbee shield v03. so what pin shall i use on the SoftwareSerial Xbee(?,?); ?
Michael Nathaniel Hi Michael. At that time, I encountered some issues when I used the hardware serial ports of the arduino (pins 0 and 1) with the XBEE shield. Hence I used the “softwareserial” library to configure pins 2 and 3 to act as TX and RX so that I can receive serial data from the XBee radios. With the softwareserial library, you can configure any digital pin on the arduino to function as TX and RX, similarly to pins 0 and 1 and in this case I used pins 2 and 3.
@@mujtech4887 Thank you for replying.
i use pin 0 and 1 for the RX and TX, and i think it works. But something is wrong when i receive the data i send. when i print the received data, i got a bunch of number and i don't know what it is. here is my code for send data.
#include
#include
#include
SoftwareSerial XBee(0,1);
String data;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
XBee.begin(9600);
data = "test send data";
}
void loop() {
delay(3000);
// put your main code here, to run repeatedly:
static char *dataSend = data.c_str();
// need to use c_str() because the write function don't accept String
XBee.write(dataSend);
}
and her is the receive code
#include
#include
#include
SoftwareSerial XBee(0,1);
String data;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
XBee.begin(9600);
}
void loop() {
delay(3000);
// put your main code here, to run repeatedly:
while(XBee.available())
{
data = XBee.read();
Serial.print(data);
// Serial.print((char)data);
Serial.print(" ");
}
Serial.println();
Serial.println("====================");
}
can you help me?
in your tutorial, you just send a number(1 or 0). can you tell me how to send a String? or there is another way? i need to send some datas from sensors.
Michael Nathaniel I still haven’t tried to send string data via arduino. From what you’re telling me, the numbers that you are receiving are the ASCI codes of the characters that are sent from the transmitter and it’s showing like that because you’re printing them at the receiver using “serial.print”. Perhaps if you change it to “serial.write” it might work?
why my xctu cannot discover my xbee S2C module
Have you tried using the XCTU software to "Recover" your Xbee? It resets all the settings back to default and will bring your Xbee back to life :)
I have a question, why you use pin 2 and 3 in arduino for RX, TX from xbee?
it is possible if I use pin RX, TX in arduino directly to connect TX,RX from xbee?
Pins 0 and 1 are hardware serial ports that can only transmit and receive to one device at a time. Since we are using the serial commands in this code, we are communicating the Arduino with the computer via these pins so we can't also use them to communicate it with the XBee radios. Hence, the digital pins are used.
In the Arduino Mega however, you are given 3 hardware serial ports to choose from so you can use two ports at the same time without the need of using the digital pins like I did in this video.
mujTech ooh ok, I got it! Thankyou dude👍
ooh sir, i have another question. i wonder if i want to controll the LED intensity with potensiometer, can you explain it?
i've tried but still failed. thanks
which xbee library did u use?
Xbee.h (Arduino library)
Can I have the Code link please......
Check the comments, I posted the code
Whats the range
KRYPTONITE TEC Approximately 10 meters inside buildings and 20 meters outside. The signal will reach between 20 to 30 meters but there will be a delay
75m to 100m
@@mujtech4887
Can you help me with coding?
@@jigmie1797 Code has been posted in the comments
I need aurdino code
It's been posted in the comments
i need the codes
I posted the code in the comments
You have womens hands F’kn Panzy
And you have sh*t for brains, whats your point?