BLUNO to BLUNO communication

Hello,
I was trying to setup a basic communication between two BLUNOs but so far I am unsuccesful. I cannot wrap my head around it. I am running a very simple code the master BLUNO sends a letter C via the BLE link and the slave BLUNO responds with letter E. This is sent back to master device where it should trigger a led blinking. The problem is that the letter C is correctly processed by the slave device and the letter E sent back but on the master device the letter E is not processed at all and the value of the received byte is 255 all the time instead of 69 for the letter E which it should be. Am I missing something? Here is the codes I am using. I will be really grateful for any piece of advice.
Master code
__________________________________________
byte received = 0;
void setup()
{
Serial.begin(115200);
pinMode(7,OUTPUT);
}
void loop()
{
Serial.println('C');
delay(20);
received = Serial.read();
switch (received)
case 'E':
{
digitalWrite(7,HIGH);
delay(50);
digitalWrite(7,LOW);
}
delay(1000);
}
________________________________________
Slave code
________________________________________
byte incoming = 0;
void setup() {
Serial.begin(115200); //initial the Serial
pinMode(13,OUTPUT);
}
void loop()
{
if(Serial.available())
{
incoming = Serial.read();
switch(incoming)
{
case 'C':
Serial.println('E');
digitalWrite(13, HIGH);
delay(10);
digitalWrite(13,LOW);
break;
}
}
}
I was trying to setup a basic communication between two BLUNOs but so far I am unsuccesful. I cannot wrap my head around it. I am running a very simple code the master BLUNO sends a letter C via the BLE link and the slave BLUNO responds with letter E. This is sent back to master device where it should trigger a led blinking. The problem is that the letter C is correctly processed by the slave device and the letter E sent back but on the master device the letter E is not processed at all and the value of the received byte is 255 all the time instead of 69 for the letter E which it should be. Am I missing something? Here is the codes I am using. I will be really grateful for any piece of advice.
Master code
__________________________________________
byte received = 0;
void setup()
{
Serial.begin(115200);
pinMode(7,OUTPUT);
}
void loop()
{
Serial.println('C');
delay(20);
received = Serial.read();
switch (received)
case 'E':
{
digitalWrite(7,HIGH);
delay(50);
digitalWrite(7,LOW);
}
delay(1000);
}
________________________________________
Slave code
________________________________________
byte incoming = 0;
void setup() {
Serial.begin(115200); //initial the Serial
pinMode(13,OUTPUT);
}
void loop()
{
if(Serial.available())
{
incoming = Serial.read();
switch(incoming)
{
case 'C':
Serial.println('E');
digitalWrite(13, HIGH);
delay(10);
digitalWrite(13,LOW);
break;
}
}
}
2014-04-11 20:15:49 I think maybe you misunderstand what I said.
I mean it lost the checking step in your master code: " if(Serial.available())"
But your salve code have this line. Not switching mater and slave.
Anyway, I will draw a picture to explain the USB, Serial port and Bluetooth relationship
Grey.CC
I mean it lost the checking step in your master code: " if(Serial.available())"
But your salve code have this line. Not switching mater and slave.
Anyway, I will draw a picture to explain the USB, Serial port and Bluetooth relationship

2014-04-11 20:15:49 I think maybe you misunderstand what I said.
I mean it lost the checking step in your master code: " if(Serial.available())"
But your salve code have this line. Not switching mater and slave.
Anyway, I will draw a picture to explain the USB, Serial port and Bluetooth relationship
Grey.CC
I mean it lost the checking step in your master code: " if(Serial.available())"
But your salve code have this line. Not switching mater and slave.
Anyway, I will draw a picture to explain the USB, Serial port and Bluetooth relationship

2014-04-11 03:49:38 Ahhhh now it makes complete sense thanks for explaining
I am still a bit new into this so I am approaching it very easily not seeing all the processes in the background. Yea the master was printing 'E' all the time. I looked into the AT commands and I am aware of this but I need the serial monitor for setting up simple counter to count how many letters has been missed in a certain period of time.
Based on what you are saying the switching of master/slave would not help at all the problem would appear again in the same manner as before. The AT+USBDEBUG command is irrelevant for me because I am using the communication between two blunos so only the AT+BLUNODEBUG is relevant. And if I understand it correctly I can turn it off and count the letters anyway right? This command only influences the printing of what is sent through the link to the serial monitor not what is printed by the MCU itself do I understand it correctly?
Dyna

Based on what you are saying the switching of master/slave would not help at all the problem would appear again in the same manner as before. The AT+USBDEBUG command is irrelevant for me because I am using the communication between two blunos so only the AT+BLUNODEBUG is relevant. And if I understand it correctly I can turn it off and count the letters anyway right? This command only influences the printing of what is sent through the link to the serial monitor not what is printed by the MCU itself do I understand it correctly?

2014-04-11 03:49:38 Ahhhh now it makes complete sense thanks for explaining
I am still a bit new into this so I am approaching it very easily not seeing all the processes in the background. Yea the master was printing 'E' all the time. I looked into the AT commands and I am aware of this but I need the serial monitor for setting up simple counter to count how many letters has been missed in a certain period of time.
Based on what you are saying the switching of master/slave would not help at all the problem would appear again in the same manner as before. The AT+USBDEBUG command is irrelevant for me because I am using the communication between two blunos so only the AT+BLUNODEBUG is relevant. And if I understand it correctly I can turn it off and count the letters anyway right? This command only influences the printing of what is sent through the link to the serial monitor not what is printed by the MCU itself do I understand it correctly?
Dyna

Based on what you are saying the switching of master/slave would not help at all the problem would appear again in the same manner as before. The AT+USBDEBUG command is irrelevant for me because I am using the communication between two blunos so only the AT+BLUNODEBUG is relevant. And if I understand it correctly I can turn it off and count the letters anyway right? This command only influences the printing of what is sent through the link to the serial monitor not what is printed by the MCU itself do I understand it correctly?

2014-04-11 01:02:26 Yeah, but BLE is very complicated.
There are three data direction: Bluetooth, USB and Serial port.
Last time you said, the master is print "E" all the time. It meas BLE is communicating with USB directly. It was showing what BLE received all the time.
And master BLUNO hadn't deal with the receive data.
There are some AT command about this in the wiki:
AT+BLUNODEBUG
AT+USBDEBUG
You'd better to check it first. You also could tell me your doubt here.
Grey.CC
There are three data direction: Bluetooth, USB and Serial port.
Last time you said, the master is print "E" all the time. It meas BLE is communicating with USB directly. It was showing what BLE received all the time.
And master BLUNO hadn't deal with the receive data.
There are some AT command about this in the wiki:
AT+BLUNODEBUG
AT+USBDEBUG
You'd better to check it first. You also could tell me your doubt here.

2014-04-11 01:02:26 Yeah, but BLE is very complicated.
There are three data direction: Bluetooth, USB and Serial port.
Last time you said, the master is print "E" all the time. It meas BLE is communicating with USB directly. It was showing what BLE received all the time.
And master BLUNO hadn't deal with the receive data.
There are some AT command about this in the wiki:
AT+BLUNODEBUG
AT+USBDEBUG
You'd better to check it first. You also could tell me your doubt here.
Grey.CC
There are three data direction: Bluetooth, USB and Serial port.
Last time you said, the master is print "E" all the time. It meas BLE is communicating with USB directly. It was showing what BLE received all the time.
And master BLUNO hadn't deal with the receive data.
There are some AT command about this in the wiki:
AT+BLUNODEBUG
AT+USBDEBUG
You'd better to check it first. You also could tell me your doubt here.

2014-04-10 22:53:11 The hardware version is 1.6. It is a shame because I need to test properly the stability of the link for 2 to 3 hours to see properly how it behaves. And for that I need the data from the master which reacts on the sendback. But wait a minute on BLE it does not depend on the Master/Slave role. The communication is bidirectional so I can keep the slave connected and do everything there is that right?
Dyna

2014-04-10 22:53:11 The hardware version is 1.6. It is a shame because I need to test properly the stability of the link for 2 to 3 hours to see properly how it behaves. And for that I need the data from the master which reacts on the sendback. But wait a minute on BLE it does not depend on the Master/Slave role. The communication is bidirectional so I can keep the slave connected and do everything there is that right?
Dyna

2014-04-10 02:29:35 Hey, Dyna
I modify the code a little.
It works on two bluno with two batteries.
What is your hardware version on the board? 1.6 or 1.5?
Grey.CC
I modify the code a little.
It works on two bluno with two batteries.
What is your hardware version on the board? 1.6 or 1.5?

2014-04-10 02:29:35 Hey, Dyna
I modify the code a little.
It works on two bluno with two batteries.
What is your hardware version on the board? 1.6 or 1.5?
Grey.CC
I modify the code a little.
It works on two bluno with two batteries.
What is your hardware version on the board? 1.6 or 1.5?

2014-04-09 23:05:41 Thanks for the code but not even that worked... On the serial monitor (Im using SSCOM) it shows that the letter is received by the slave Bluno but it never gets inside the while loop. I tried to write the value of the inbyte to the serial monitor (the blunodebug in AT commands is ON) and it does not return any value to the monitor. Thus assuming that it does not even get into the loop. I will try to interchange the roles and see what happens. Thanks for the effort.
Edit: Ok interchanging helped and I am back at the beginning. The slave reacts but the central does not react to the letter being send back. It definitely receives it but does not enter the while loop after receiving the letter. It is also wierd that the received letter E is even printed to the serial monitor by the central device... There is no line in the code that is supposed to do that...
Edit No.2: Ok problem solved. If the central device is connected by the USB cable to the computer it is somehow not able to process the data from serial port. Or at least it seems that way because when I connected the master device directly to the wall socket using iPhone USB charging adapter it all started to work like a charm. It is strange that with a peripheral device this problem does not occur.
Dyna
Edit: Ok interchanging helped and I am back at the beginning. The slave reacts but the central does not react to the letter being send back. It definitely receives it but does not enter the while loop after receiving the letter. It is also wierd that the received letter E is even printed to the serial monitor by the central device... There is no line in the code that is supposed to do that...
Edit No.2: Ok problem solved. If the central device is connected by the USB cable to the computer it is somehow not able to process the data from serial port. Or at least it seems that way because when I connected the master device directly to the wall socket using iPhone USB charging adapter it all started to work like a charm. It is strange that with a peripheral device this problem does not occur.

2014-04-09 23:05:41 Thanks for the code but not even that worked... On the serial monitor (Im using SSCOM) it shows that the letter is received by the slave Bluno but it never gets inside the while loop. I tried to write the value of the inbyte to the serial monitor (the blunodebug in AT commands is ON) and it does not return any value to the monitor. Thus assuming that it does not even get into the loop. I will try to interchange the roles and see what happens. Thanks for the effort.
Edit: Ok interchanging helped and I am back at the beginning. The slave reacts but the central does not react to the letter being send back. It definitely receives it but does not enter the while loop after receiving the letter. It is also wierd that the received letter E is even printed to the serial monitor by the central device... There is no line in the code that is supposed to do that...
Edit No.2: Ok problem solved. If the central device is connected by the USB cable to the computer it is somehow not able to process the data from serial port. Or at least it seems that way because when I connected the master device directly to the wall socket using iPhone USB charging adapter it all started to work like a charm. It is strange that with a peripheral device this problem does not occur.
Dyna
Edit: Ok interchanging helped and I am back at the beginning. The slave reacts but the central does not react to the letter being send back. It definitely receives it but does not enter the while loop after receiving the letter. It is also wierd that the received letter E is even printed to the serial monitor by the central device... There is no line in the code that is supposed to do that...
Edit No.2: Ok problem solved. If the central device is connected by the USB cable to the computer it is somehow not able to process the data from serial port. Or at least it seems that way because when I connected the master device directly to the wall socket using iPhone USB charging adapter it all started to work like a charm. It is strange that with a peripheral device this problem does not occur.

2014-04-09 19:31:51 Really? Master code hasn't checked the receive data, so when it is empty, it will send "FF" in decimalism, it is "255"
Try this one:
Master:
Grey.CC
Try this one:
Master:
Code: Select all
Salve:void setup()
{
Serial.begin(115200);
pinMode(13,OUTPUT);
}
void loop()
{
Serial.println('C');
delay(50);
while(Serial.available())
{
char inbyte = Serial.read();
if('E'==inbyte){
digitalWrite(13,HIGH);
delay(250);
digitalWrite(13,LOW);
}
}
}
Code: Select all
void setup()
{
Serial.begin(115200);
pinMode(13,OUTPUT);
}
void loop()
{
while(Serial.available())
{
char inbyte = Serial.read();
if('C'==inbyte){
digitalWrite(13,HIGH);
Serial.println('E');
delay(250);
digitalWrite(13,LOW);
delay(250);
}
}
}

2014-04-09 19:31:51 Really? Master code hasn't checked the receive data, so when it is empty, it will send "FF" in decimalism, it is "255"
Try this one:
Master:
Grey.CC
Try this one:
Master:
Code: Select all
Salve:void setup()
{
Serial.begin(115200);
pinMode(13,OUTPUT);
}
void loop()
{
Serial.println('C');
delay(50);
while(Serial.available())
{
char inbyte = Serial.read();
if('E'==inbyte){
digitalWrite(13,HIGH);
delay(250);
digitalWrite(13,LOW);
}
}
}
Code: Select all
void setup()
{
Serial.begin(115200);
pinMode(13,OUTPUT);
}
void loop()
{
while(Serial.available())
{
char inbyte = Serial.read();
if('C'==inbyte){
digitalWrite(13,HIGH);
Serial.println('E');
delay(250);
digitalWrite(13,LOW);
delay(250);
}
}
}

2014-04-09 01:33:54 Thanks Grey for answering but it did not help at all... The Bluno is acting really weird. Now even if I upload the code listed above and when the link is established the peripheral Bluno does not react to the letter C anymore. The strange thing is that when I shut down the central Bluno thus disabling the link a try to send the letter via serial monitor then the code works fine and returns the E as it is supposed to. The strangest thing is that when I returned to the office after work and I turned the both Blunos on they were behaving as they were supposed to for approximately 5 minutes. Both LEDs blinking so the letters were received correctly even with the basic code. And then after 5 minutes the central device stopped blinking and came back to the state when it does not save the value that is coming through the serial port anymore. And now this. Something is very wrong here do you think it could be the firmware? I will try to reupload it and see if it solves my problem. Hopefully yes because there is nothing to mess up in such simple code at least I think that it is like that.
PS: okay so not even the firmware update helped... I am in the dark a little bit. Could this be a hardware problem with my Blunos?
Dyna
PS: okay so not even the firmware update helped... I am in the dark a little bit. Could this be a hardware problem with my Blunos?

2014-04-09 01:33:54 Thanks Grey for answering but it did not help at all... The Bluno is acting really weird. Now even if I upload the code listed above and when the link is established the peripheral Bluno does not react to the letter C anymore. The strange thing is that when I shut down the central Bluno thus disabling the link a try to send the letter via serial monitor then the code works fine and returns the E as it is supposed to. The strangest thing is that when I returned to the office after work and I turned the both Blunos on they were behaving as they were supposed to for approximately 5 minutes. Both LEDs blinking so the letters were received correctly even with the basic code. And then after 5 minutes the central device stopped blinking and came back to the state when it does not save the value that is coming through the serial port anymore. And now this. Something is very wrong here do you think it could be the firmware? I will try to reupload it and see if it solves my problem. Hopefully yes because there is nothing to mess up in such simple code at least I think that it is like that.
PS: okay so not even the firmware update helped... I am in the dark a little bit. Could this be a hardware problem with my Blunos?
Dyna
PS: okay so not even the firmware update helped... I am in the dark a little bit. Could this be a hardware problem with my Blunos?

2014-04-04 19:01:22 Hello Dyna,
It looks like you missed "if(Serial.available())" in your master code. (Like your slave one)
This code will check your serial received data.
Bluno is very interesting.
Grey.CC
It looks like you missed "if(Serial.available())" in your master code. (Like your slave one)
This code will check your serial received data.
Bluno is very interesting.

2014-04-04 19:01:22 Hello Dyna,
It looks like you missed "if(Serial.available())" in your master code. (Like your slave one)
This code will check your serial received data.
Bluno is very interesting.
Grey.CC
It looks like you missed "if(Serial.available())" in your master code. (Like your slave one)
This code will check your serial received data.
Bluno is very interesting.

2014-04-04 01:07:49 Hello,
I was trying to setup a basic communication between two BLUNOs but so far I am unsuccesful. I cannot wrap my head around it. I am running a very simple code the master BLUNO sends a letter C via the BLE link and the slave BLUNO responds with letter E. This is sent back to master device where it should trigger a led blinking. The problem is that the letter C is correctly processed by the slave device and the letter E sent back but on the master device the letter E is not processed at all and the value of the received byte is 255 all the time instead of 69 for the letter E which it should be. Am I missing something? Here is the codes I am using. I will be really grateful for any piece of advice.
Master code
__________________________________________
byte received = 0;
void setup()
{
Serial.begin(115200);
pinMode(7,OUTPUT);
}
void loop()
{
Serial.println('C');
delay(20);
received = Serial.read();
switch (received)
case 'E':
{
digitalWrite(7,HIGH);
delay(50);
digitalWrite(7,LOW);
}
delay(1000);
}
________________________________________
Slave code
________________________________________
byte incoming = 0;
void setup() {
Serial.begin(115200); //initial the Serial
pinMode(13,OUTPUT);
}
void loop()
{
if(Serial.available())
{
incoming = Serial.read();
switch(incoming)
{
case 'C':
Serial.println('E');
digitalWrite(13, HIGH);
delay(10);
digitalWrite(13,LOW);
break;
}
}
}
Dyna
I was trying to setup a basic communication between two BLUNOs but so far I am unsuccesful. I cannot wrap my head around it. I am running a very simple code the master BLUNO sends a letter C via the BLE link and the slave BLUNO responds with letter E. This is sent back to master device where it should trigger a led blinking. The problem is that the letter C is correctly processed by the slave device and the letter E sent back but on the master device the letter E is not processed at all and the value of the received byte is 255 all the time instead of 69 for the letter E which it should be. Am I missing something? Here is the codes I am using. I will be really grateful for any piece of advice.
Master code
__________________________________________
byte received = 0;
void setup()
{
Serial.begin(115200);
pinMode(7,OUTPUT);
}
void loop()
{
Serial.println('C');
delay(20);
received = Serial.read();
switch (received)
case 'E':
{
digitalWrite(7,HIGH);
delay(50);
digitalWrite(7,LOW);
}
delay(1000);
}
________________________________________
Slave code
________________________________________
byte incoming = 0;
void setup() {
Serial.begin(115200); //initial the Serial
pinMode(13,OUTPUT);
}
void loop()
{
if(Serial.available())
{
incoming = Serial.read();
switch(incoming)
{
case 'C':
Serial.println('E');
digitalWrite(13, HIGH);
delay(10);
digitalWrite(13,LOW);
break;
}
}
}
