Hi
I'm using a WiFly bee mounted in a Bees Shield which is accessed using the SoftwareSerial library. I've had some success with it, but find the comms unreliable as the information read back from the bee is overlaid by what appears to be random noise. I'm hoping this will be familiar to someone here, and you'll be able to point me in the right direction to solving it.
To illustrate, I'll use a sequence of commands on the WiFly which generate no HTTP traffic to display, so this is simply command line stuff which . In terraterm, here's these commands and the responses:
CMD
show connection
8130
<2.31> lites
<2.31> lookup google.com
google.com=74.125.237.128
<2.31> lites
<2.31> exit
EXIT
The initial CMD is in response to $$$ to enter command mode, which isn't echoed. So I created a test script to send these same lines to the WiFly Bee, with a short delay and then echo the contents of the WiFly buffer out to the serial port. Sketch here :
#include <SoftwareSerial.h>
// WiFly bee is using pins 2 & 3 on the Arduino
SoftwareSerial WiFly(2, 3);
const int waitTime = 2000;
void setup(void) {
// start serial port
Serial.begin(9600);
WiFly.begin(9600); // set the data rate for the SoftwareSerial port
for (int i=0; i<15; i++) delay(1000); // allow 15 secs to reset WiFly bee manually
}
void doWiFlyCommand(char* commandString) {
// write string to WiFly bee's serial buffer,
// wait a small while,
// then read WiFly bee's serial output buffer for results
for(int idx = 0; commandString[idx] != '\0'; idx++) WiFly.write(commandString[idx]);
WiFly.println();
delay(waitTime);
while(WiFly.available()) Serial.write(WiFly.read());
Serial.println();
}
void loop(void) {
Serial.println("=============================================================================================");
delay(300); // 250ms delay either side of command mode signal
WiFly.print("$$");
delay(300); // 250ms delay in going into command mode in the WiFly
while (WiFly.available()) Serial.write(WiFly.read());
Serial.println();
doWiFlyCommand("show connection"); // status of WiFly bee
doWiFlyCommand("lites"); // on-board disco light show
doWiFlyCommand("lookup google.com"); // DNS lookup
doWiFlyCommand("lites"); // turn off light-show
doWiFlyCommand("exit"); // depart command mode
}
But the result is somewhat different. Note also that the unexpected characters change each loop through, so it's not predictable (or at least a pattern I recognise, but I'm really hoping you do?).
=============================================================================================
CMD
s½ÿeÿo+ÿctikÖL³Ì?
<2.31>
lÑÿe5ÖLf˳1>
l½ÿkÁÿ ½ÿÿle.cok¦ügoogle.com=74.125.237.134
<2.31>
Ñÿes5f?&æl³fÏ
e¥ÿt
)V
-µa?
=============================================================================================
CMD
shÝÿÿ¹ÿ+ÿctsÿ
S?6ÖL&æl³fÏ
¥ÿtÍÿ
SÆ&æl³fÏ
l½ÿkÁÿ ½ÿÿ?ÿÿom
SvÛÛÛ6mÙ?com=74.125.237.134
<2.31>
¥ÿtÍÿ
SÆ&æl³fÏ
e¥ÿt5V¬kÒª
=============================================================================================
CMD
s½ÿeÿsÿec{ÿn
8130
<2.31>
lÑÿe5ÖLfË?1>
l½ÿkÁÿ ½ÿÿ?ÿ.cok¦ì¶ÛÛ6mÙ?com=74.125.237.134
<2.31>
lÑÿe5ÖLfË31>
e¥ÿt5¦¬kÒª
=============================================================================================
CMD
sÝÿÿonneKÿon
8130
<2.31>
¥ÿtÍÿ
#Æ&æl³fÏ
½ÿokÁÿ ½ÿÿ?ÿÿµÿ
SvÛÛÛ6mÙ?com=74.125.237.134
<2.31>
lÑÿe5kLfË?1>
e¥ÿt5S¬kÒª
=============================================================================================
CMD
s½ÿeÿsÿeKÿon
8130
<2.31>
lÑÿe5ÖLfË?1>
l½ÿkÁÿ ½ÿÿ?ÿ.com
SvÛÛÛ6mÙ?com=74.125.237.134
<2.31>
¥ÿtÍÿ
SÆ&æl³fÏ
e¥ÿt5¦¬kÒª
I've tested this on two different WiFly Bees, on multiple Arduinos and two Bees Shields to try to eliminate hardware failings. You can also see the legitimate responses are in there, just not always identifiable, and the sequence of commands actually does run as evidenced by the DNS lookup and the LED light show each loop through.
Thanks for reading this far...any ideas?
Geoff