Home  >  Support  >  Support Forum  >  Can Xbee wifi models be connected through hardware serial ports of the Arduino Mega
Notice! We've recently migrated to using a new forum, we hope you enjoy it. If you are an existing member and this is your first time visiting our new forum, please reset your password to be able to sign in.

Can Xbee wifi models be connected through hardware serial ports of the Arduino Mega

0 votes
I am trying to connect the wifi model to the Serial1 port of the mega and its not responding. However it works with a software serial port. Is it normal?
asked Jul 2 in IEEE 802.11 by arif New to the Community (2 points)
I feel, the Xbee module has some sort of buffer size limit ( although data sheet says its 2083 bytes, and my total packet is 309 bytes). I am using UART.

Here is the data sent from the server ( got from wireshark)

Code:
HTTP/1.1 200 OK
Date: Wed, 02 Jul 2014 20:36:29 GMT
Server: Apache/2.4.9 (Win32) OpenSSL/1.0.1g PHP/5.5.11
X-Powered-By: PHP/5.5.11
Content-Length: 31
Connection: close
Content-Type: text/html
Arif, 0, 61, 0, 34, 0, 21, 0,

However, using a little delay after GET request, I consistently am receiving a part of it only :
Code:
HTTP/1.1 200 OK
Date: Thu, 03 Jul 2014 02:38:56 GMT
Server: A


This is consistent and I am getting this everytime (with change in timestamp).

Here is the code segment :
Code:
void loop()
{
  if (millis() > (lastUpdate + UPDATE_RATE))
  {
    xB.print(phant.get());
    delay(3000);
    lastUpdate=millis();
  
   while(xB.available())
         {
           c=char(xB.read());
           delay(1);
          Serial.print(c);
         }
     }
}

 Any input will help, again. Thanks.
Could you give a more complete code? Your 3 second delay may have something to do with the partial response. Arduino MEGA has 63 bytes of serial buffer. It implements the wine-rule. Any new content is discarded after the buffer is full. Count your characters, I got 61 but I don't think all the \r or \n are properly preserved on a forum post. I don't know about the software serial case or its buffer. You have to dig in arduino softwareserial port source code to answer that.

Please log in or register to answer this question.

4 Answers

0 votes
what are you trying to issue to the radio? what is the exact data you are sending out the serial port of the arduino? What is the radio connected to? is it connected direct or via a daughter board?
answered Jul 2 by mvut Veteran of the Digi Community (1,555 points)
0 votes
I am trying to receive data from a server with http GET.

this is exactly what the server is sending :

HTTP/1.1 200 OK
Date: Wed, 02 Jul 2014 20:36:29 GMT
Server: Apache/2.4.9 (Win32) OpenSSL/1.0.1g PHP/5.5.11
X-Powered-By: PHP/5.5.11
Content-Length: 31
Connection: close
Content-Type: text/html
Arif, 0, 61, 0, 34, 0, 21, 0,

The radio is Xb-wifi sb6. and I am connected directly to the mega without any daughter board.

My code works when I use softwareserial. however i can't make it work in the hardware serial ports.
answered Jul 2 by arif New to the Community (2 points)
0 votes
If you think removing the delay 3000 solves your problem, mark THIS as answer. Forgot how this forum works.

Could you give a more complete code? Your 3 second delay may have something to do with the partial response. Arduino MEGA has 63 bytes of serial buffer. It implements the wine-rule. Any new content is discarded after the buffer is full. Count your characters, I got 61 but I don't think all the \r or \n are properly preserved on a forum post. I don't know about the software serial case or its buffer. You have to dig in arduino softwareserial port source code to answer that.
answered Aug 22 by liudr New to the Community (40 points)
0 votes
I could connect it later using the hardware serial port. much better i would say. with software serial port, the buffer gets full really fast (as you mentioned). Thanks for the reply liudr.
answered Aug 22 by arif New to the Community (2 points)
Contact a Digi expert and get started today! CONTACT US
...