RFbee communication help

wireless communication and related Bees.

Moderators: lily.li, violet, jessie

dechaumet.valerian
Pre-kindergarten
Pre-kindergarten
Posts: 6
Joined: Wed May 27, 2015 6:04 pm

RFbee communication help

Post by dechaumet.valerian » Wed May 27, 2015 7:00 pm

Hello,

First, sorry for my language, it can be average because it's not my native language.

I come here to find some help about RFbee. I want to make a wireless communication between 2 computers with 2 RFbee like that :
COMPUTER --> UNO --> I/O SHIELD --> RFBee --> ------air------> RFBee --> I/O SHIELD --> UNO --> COMPUTER

To do that, i have :
- 2 cards arduino uno
- 2 shields DFRobot I/O Expansion Shield V7.1
- 2 RFBee v1.1

I've searched much time but i just don't understand how it work and how to programate it. I found much and much sites (seedstudio limits the number of links for new users so i can't tell you which i visited)

But even with all that, i don't understand how to do to make it work. Scripts or exemple just doesn't work when i try them. I tried to modify them but nothing worked.

Someone could take some time to explain me clearly and the easiest possible how tu do it please? An exemple of basic codage for RFBee would be really great!

Tanmay.y12
Pre-kindergarten
Pre-kindergarten
Posts: 13
Joined: Fri May 29, 2015 5:54 pm

Re: RFbee communication help

Post by Tanmay.y12 » Fri May 29, 2015 6:07 pm

Hi,

What you can do at the receiver side is, upload a simple code in the UNO which sends some number, say '1' and is received by the Receiving Uno. The whole communication goes through the pair of RFBee modules both kept in either Rx-Tx mode or Transceiver modes.

Sender code:

Code: Select all

void setup()
{                
 Serial.begin(9600); // beginning the Serial Communication 

// Read the AT Commands section in RFBee Datasheet to understand AT Commands below
 //Start control mode in RFBEE using NUM's +++
 Serial.print("+++\r");
 delay(40);
 //Read firmware version (should be 1.1)
 Serial.print("ATFV\r");
 delay(10);
 //Read HW version (should be 1.0)
 Serial.print("ATHV\r");
 delay(10);
 //Read current baud setting (should be 0=9600bps)
 Serial.print("ATBD\r");
 delay(10);
 //set mode, initially it's transceiving
 Serial.write("ATMD0\r");
 delay(10);
 //Set Output format
 Serial.write("ATOF3\r"); // Check Datasheet
 delay(10);
 //Set My (source) Address
 Serial.write("ATMA2\r");
 delay(10);
 //Set Destination Address
 Serial.write("ATDA1\r");
 delay(10);
 Serial.write("ATAC2\r");
 delay(10);
 Serial.write("ATTH0\r");
 delay(10);
 Serial.write("ATPA7\r"); Maximum Power, can adjust as per requirement
 delay(10);
 Serial.write("ATCF5\r"); Least Data rate, can change as per requirement
 delay(10);
 

 //Go back to data mode
 Serial.print("ATo0\r");  
}

void loop()
{

     
     Serial.print('1');
     delay (2000); // delay 2 seconds
}
This code would serially send '1' every 2 seconds.

Similarly, you can make the receiving code using Serial.read() command of Arduino Serial library.

Thanks,
Tanmay Chaturvedi

dechaumet.valerian
Pre-kindergarten
Pre-kindergarten
Posts: 6
Joined: Wed May 27, 2015 6:04 pm

Re: RFbee communication help

Post by dechaumet.valerian » Tue Jun 02, 2015 4:16 pm

Thanks for your help.

I tried your code but data is not send from rfbees, it just prints in monitor but not send to the other one.

I don't understand, in your code, there only Serial.print. That only show what is between parentheses, i don't understand how it can configurate rfbees with just Serial.print.

I did that code with Serial.read() you adviced me :

Code: Select all

int incomingbyte = 1;

void setup()
{               
Serial.begin(9600); // beginning the Serial Communication

// Read the AT Commands section in RFBee Datasheet to understand AT Commands below
//Start control mode in RFBEE using NUM's +++
Serial.print("+++\r");
delay(40);
//Read firmware version (should be 1.1)
Serial.print("ATFV\r");
delay(10);
//Read HW version (should be 1.0)
Serial.print("ATHV\r");
delay(10);
//Read current baud setting (should be 0=9600bps)
Serial.print("ATBD\r");
delay(10);
//set mode, initially it's transceiving
Serial.write("ATMD0\r");
delay(10);
//Set Output format
Serial.write("ATOF3\r"); // Check Datasheet
delay(10);
//Set My (source) Address
Serial.write("ATMA2\r");
delay(10);
//Set Destination Address
Serial.write("ATDA1\r");
delay(10);
Serial.write("ATAC2\r");
delay(10);
Serial.write("ATTH0\r");
delay(10);
Serial.write("ATPA7\r"); //Maximum Power, can adjust as per requirement
delay(10);
Serial.write("ATCF5\r"); //Least Data rate, can change as per requirement
delay(10);


//Go back to data mode
Serial.print("ATo0\r"); 
}

void loop()
{

     
     incomingbyte =  Serial.read();
     Serial.println(incomingbyte);
     delay (1000); // delay 2 seconds
}
when i write something like "a" for exemple, it's show me a number "97" only in the monitor where i write it but not in the other one.

What should i do?

Tanmay.y12
Pre-kindergarten
Pre-kindergarten
Posts: 13
Joined: Fri May 29, 2015 5:54 pm

Re: RFbee communication help

Post by Tanmay.y12 » Wed Jun 03, 2015 12:48 pm

1.

Code: Select all

Serial.print() 
helps you to print the data currently on the Serial monitor.

Code: Select all

 Serial.write() 
helps you to write something on the serial monitor, where writing means sending data actually to the serial pins of any device which can be transmitted to any other peripheral connected serially.

So, in my code,

Code: Select all

 Serial.print("ATHV\r") 
only tells the Hardware Version. However, when I write

Code: Select all

Serial.write("ATMD0\r")
, it actually configures the mode of operation of RFBEE in Transceiver mode.

2. If Sender has its own Address 2

Code: Select all

 ATMA2 
and its Destination Address is 1

Code: Select all

 ATDA1 
then at the receiving side, it would just be opposite

Code: Select all

 ATMA1 
and

Code: Select all

 ATDA2 
I can see that you didn't change the address, infact kept both addresses same, so they wouldn't communicate.

3. It only sends a Byte, and is sent in form of an ASCII value. So, you may browse on converting ASCII into INT value and then send, or you may try to read the ASCII value first at the Receiving side and then convert into INT. As per what I remember, INT value is ASCII - '0' .

dechaumet.valerian
Pre-kindergarten
Pre-kindergarten
Posts: 6
Joined: Wed May 27, 2015 6:04 pm

Re: RFbee communication help

Post by dechaumet.valerian » Wed Jun 03, 2015 4:21 pm

a ok! I didn't understand it like that.

I changed it :

Code: Select all

int incomingbyte = 1;

void setup()
{               
Serial.begin(9600); // beginning the Serial Communication

// Read the AT Commands section in RFBee Datasheet to understand AT Commands below
//Start control mode in RFBEE using NUM's +++
Serial.print("+++\r");
delay(40);
//Read firmware version (should be 1.1)
Serial.print("ATFV\r");
delay(10);
//Read HW version (should be 1.0)
Serial.write("ATHV\r");
delay(10);
//Read current baud setting (should be 0=9600bps)
Serial.print("ATBD\r");
delay(10);
//set mode, initially it's transceiving
Serial.write("ATMD0\r");
delay(10);
//Set Output format
Serial.write("ATOF3\r"); // Check Datasheet
delay(10);
//Set My (source) Address
Serial.write("ATMA2\r");
delay(10);
//Set Destination Address
Serial.write("ATDA1\r");
delay(10);
Serial.write("ATAC2\r");
delay(10);
Serial.write("ATTH0\r");
delay(10);
Serial.write("ATPA7\r"); //Maximum Power, can adjust as per requirement
delay(10);
Serial.write("ATCF5\r"); //Least Data rate, can change as per requirement
delay(10);


//Go back to data mode
Serial.print("ATo0\r"); 
}

void loop()
{

     
     incomingbyte =  Serial.read();
     Serial.println(incomingbyte);
     delay (1000); // delay 2 seconds
}
and :

Code: Select all

int incomingbyte = 1;

void setup()
{               
Serial.begin(9600); // beginning the Serial Communication

// Read the AT Commands section in RFBee Datasheet to understand AT Commands below
//Start control mode in RFBEE using NUM's +++
Serial.print("+++\r");
delay(40);
//Read firmware version (should be 1.1)
Serial.print("ATFV\r");
delay(10);
//Read HW version (should be 1.0)
Serial.write("ATHV\r");
delay(10);
//Read current baud setting (should be 0=9600bps)
Serial.print("ATBD\r");
delay(10);
//set mode, initially it's transceiving
Serial.write("ATMD0\r");
delay(10);
//Set Output format
Serial.write("ATOF3\r"); // Check Datasheet
delay(10);
//Set My (source) Address
Serial.write("ATMA1\r");
delay(10);
//Set Destination Address
Serial.write("ATDA2\r");
delay(10);
Serial.write("ATAC2\r");
delay(10);
Serial.write("ATTH0\r");
delay(10);
Serial.write("ATPA7\r"); //Maximum Power, can adjust as per requirement
delay(10);
Serial.write("ATCF5\r"); //Least Data rate, can change as per requirement
delay(10);


//Go back to data mode
Serial.print("ATo0\r"); 
}

void loop()
{

     
     incomingbyte =  Serial.read();
     Serial.println(incomingbyte);
     delay (1000); // delay 2 seconds
}
So if i understand what you told me, with those configurations, both monitor should show me the text i wrote but for me, it didn't change anything.
here is what i have on one of my monitors :
when i start :
Image

when i write letter "a" :
Image

Tanmay.y12
Pre-kindergarten
Pre-kindergarten
Posts: 13
Joined: Fri May 29, 2015 5:54 pm

Re: RFbee communication help

Post by Tanmay.y12 » Wed Jun 03, 2015 4:34 pm

You have used Serial.read() in both Rx and Tx code. It would only read the values in the serial pins.

Since you are not using Serial.write() function at the Tx side, there would be no data being written on serial port and the serial port would read -1, which means NO DATA at the serial port.

First, at the Tx side, write say Serial.write("1"). If you will see the Serial monitor at Tx side, you would see a stream of 1s.
Please make note that this 1 is not at an integer.

Now, at the Receiver side, use Serial.read() function and see the output in Serial monitor.

dechaumet.valerian
Pre-kindergarten
Pre-kindergarten
Posts: 6
Joined: Wed May 27, 2015 6:04 pm

Re: RFbee communication help

Post by dechaumet.valerian » Wed Jun 03, 2015 5:21 pm

Ok, i changed for the sender's code : incomingbyte = Serial.read() to incomingbyte = Serial.write("1")

Now the Tx side read 11 (for value of "1" i suppose) and the Rx side read -1.

If i well understand, there is now one RFBee what is Tx and the other one is Rx, right? So after set source and destination addresses and set Serial.write on the Tx and Serial.read on the Rx, it should exchange datas, i don't see what where is the problem.

Tanmay.y12
Pre-kindergarten
Pre-kindergarten
Posts: 13
Joined: Fri May 29, 2015 5:54 pm

Re: RFbee communication help

Post by Tanmay.y12 » Thu Jun 04, 2015 12:05 am

1. No need to use the variable 'incomingbyte'. Directly write Serial.write('1');

2. When you see -1 on the serial monitor, it simply means there is NO DATA on serial pins. This occurred because data was NOT being written on the serial pins.

3. Do you have a UARTSBee?? For testing purpose, what you can do is, at the Receiver side:
a) use UARTSBee and connect RFBee to your computer using UARTSBee.
b)when you connect, you'll see 'OK', press +++ and then you would see 'Entering command mode'. [Refer DATASHEET]
c) the AT commands you use in the code, you have to manually enter it.
d) after configuring it, type 'ATo0' and press ENTER. You'd enter in DATA MODE.

As you can see in the Rx code also, DATA mode is used to transmit or receive any data

at the TX side, you have to use Arduino/any RFBee compatible board and burn the code given. If the connection goes proper, you would see the data over the Receiver side.

PS: you have to use any Serial Software like: TeraTerm, HyperTerminal or PuTTy at the Rx side to see data.

dechaumet.valerian
Pre-kindergarten
Pre-kindergarten
Posts: 6
Joined: Wed May 27, 2015 6:04 pm

Re: RFbee communication help

Post by dechaumet.valerian » Thu Jun 04, 2015 4:54 pm

i have only that :
- 2 cards arduino uno
- 2 shields DFRobot I/O Expansion Shield V7.1 (if i'm not wrong, it's an UARTSBee)
- 2 RFBee v1.1

and i can use only arduino IDE to programmate it.

Tanmay.y12
Pre-kindergarten
Pre-kindergarten
Posts: 13
Joined: Fri May 29, 2015 5:54 pm

Re: RFbee communication help

Post by Tanmay.y12 » Thu Jun 04, 2015 5:02 pm

It's not exactly UARTSBee but it's more than that. Further, it may serve the purpose.

So, you may try what I told you in the thread above.

Post Reply