Wifi Shield - EiFi [Urgent]

Hello everyone ,

I am computer engineer student.I have a graduation project.But I have a problem.

I bought this shield http://www.elecfreaks.com/wiki/index.php?title=Wifi_Shield_-_EiFi.

wifi shield pin DOUT-D2 , DIN-D3. arduino code tx-pin 2 rx-pin 3 , use software serial lib.

#include <SoftwareSerial.h>

#define rxPin 2
#define txPin 3

SoftwareSerial mySerial(rxPin, txPin);

void setup()
{
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  mySerial.begin(9600);                             // setting baud to 9600
  Serial.begin(9600);
}

void loop()
{
  
  mySerial.write("AT\r\n");
  
  char rcv;
  
  if(mySerial.available())
  {
    rcv = mySerial.read();
  }
 
  
  Serial.print(rcv);
  
  delay(1000);
}

but I wan unable to use this shield with arduino. Send AT Command and receive ÿ this char.

Did anyone use this shield ?

Where is the problem ?

Typically, ÿ (char 255) means nothing to read.

You might want to think about how your sketch is arranged. Send command to device, declare variable, see if anything on serial (the response might not have arrived yet?), print out contents of variable regardless? Wait, and then repeat, and repeat...

You aren't reading the device properly. You read one character, if available, but print it whether you read anything or not. Try changing this:

  if(mySerial.available())
  {
    rcv = mySerial.read();
  }

  
  Serial.print(rcv);

to this:

  while(mySerial.available())
  {
    rcv = mySerial.read();
    Serial.print(rcv);
  }

Pete

Hi ,

el_supremo change the code as you said after result is same receive ÿ this char.

What do you recommend ?

Which Arduino are you using?

Hi ,

I use arduino uno

Try this:

#include <SoftwareSerial.h>

#define rxPin 2
#define txPin 3

SoftwareSerial mySerial(rxPin, txPin);

void setup()
{
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  mySerial.begin(9600);                             // setting baud to 9600
  Serial.begin(9600);
}

void loop()
{

  mySerial.write("AT\r\n");

  char rcv;
  while (mySerial.available()==0) // Sit in a loop awaiting some input
  {
  }

  if(mySerial.available()) // Which it will be
  {
    rcv = mySerial.read();
    Serial.print(rcv);
  }

  delay(1000);
}

It’s just a modification of your code, not the way I would do it. It will only print out the first character of any response. You might also wish to consider printing out the ASCII value of what is received just in case it’s a control character.