UART WiFi on single Serial setups

Hi,

I’ve been trying to get the UART-WiFi-module to work on my Seeeduino 4.2 for some time now, but to no avail. I got the SoftwareSerial working so that it can read data that comes from the module (although the data that is read seems to be little more than random numbers), but it seems that I can’t write anything to it or the commands that I send are not doing what they’re supposed to. Below is an edited version of the UART WiFi demo using SoftwareSerial to communicate with the module.

[code]#include <SoftwareSerial.h>

// test grove - uart wifi
// Loovee @ 2015-7-28

#include <Wire.h>

char ap_buf[30][16];
int ap_cnt = 0;
SoftwareSerial mySerial(2,3);

void setup()
{

mySerial.begin(115200);
Serial.begin(9600);
Serial.println("Starting");
delay(3000);
Wire.begin();

}

void loop()
{
ap_cnt = 0;

cmd_send("AT+CWLAP");
wait_result();

display_ap();
delay(5000);

}

// send command
void cmd_send(char *cmd)
{
if(NULL == cmd)return;
mySerial.println(cmd);
}

// wait result of ap scan
// +CWLAP:(3,“360WiFi-UZ”,-81,“08:57:00:01:61:ec”,1)
void wait_result()
{
mySerial.listen();
while(1)
{
LOOP1:
char c1=0;
if(mySerial.available()>=2)
{
c1 = mySerial.read();
if(c1 == ‘O’ && ‘K’ == mySerial.read()){
return; // OK means over
}
}

    if('('==c1)
    {
      
        while(mySerial.available()<3);
        mySerial.read();
        mySerial.read();
        mySerial.read();

        int d = 0;
        while(1)
        {
            if(mySerial.available() && '"' == mySerial.read());      // find "
            {
                while(1)
                {
                    if(mySerial.available())
                    {
                        char c = mySerial.read();
                        ap_buf[ap_cnt][d++] = c;
                        if(c == '"' || d==16)
                        {
                            ap_buf[ap_cnt][d-1] = '\0';
                            ap_cnt++;
                            goto LOOP1;
                        }
                    }
                }
            }
        }
    }
}

}

// display
void display_ap()
{
char strtmp[16];
sprintf(strtmp, “get %d ap”, ap_cnt);
Serial.println(strtmp); // Print the String

delay(2000);

int cnt = ap_cnt;
int offset = 0;
while(1)
{
    if(cnt>=8)
    {
        for(int i=0; i<8; i++)
        {
            Serial.println(ap_buf[8*offset+i]);        // Print the String
        }
        cnt-=8;
        offset++;
    }
    else 
    {
        for(int i=0; i<cnt; i++)
        {
            Serial.println(ap_buf[8*offset+i]);        // Print the String
        }
        
        return;
    }
    
    delay(2000);
}

}[/code]

Even trying something simple, like mySerial.println("AT+LEDON "); does not do anything, and the LED light doesn’t even flicker.

If anyone has any ideas, I’d be happy to try them out. I would hate to have to buy something like Mega to get this piece working…

EDIT: if it is relevant, I’m using the Seeeduino 4.2 + Grove Base Shield 2.0, and the WiFi module is plugged in D2. There are no other modules currently in use.

Hi,

Could you please check the following example for wifi module.

Thanks and Regards

Hi and thank you for the response.

Unfortunately, the link you provided didn’t really help me, since apparently their approach is to hook the PC to the software serial somehow, and I have no idea how this is done.

I’m starting to think that my WIFI-module is busted, since even the most simple code

[code]
void setup()
{

Serial.begin(115200);

}

void loop()
{
Serial.println(“AT+LEDON”);
delay(1000);
}[/code]

does not get the LED turned on.

Hi,

We have made few modifications to your code.

1.Upload the code to seeeduino 4.2 without connecting the grove UART wifi.
2.After uploading connect the grove uart wifi to the UART port in the Seeeduino 4.2
3.Reset the Seeeduino 4.2.



void setup()
{
    Serial.begin(115200);
    
    delay(3000);
   
}

void loop()
{
 
       LEDON(); // LED ON function
     
}
 
/*
* Name: LED ON()
*/
void LEDON()
{
  Serial.println("AT+LEDON/r/n");//Turn the blue LINK LED ON
  delay(100);
  Serial.println();
}

Use this code and let us know if it works.

Thanks for the help.

I uploaded the code and tested it per your instructions, but still the LED won’t turn on. Here’s what I’ve tried:
-The USB power from the PC and an mobile phone charger
-External power from a 9V battery
-5V and 3V3 modes

Even the RX/TX lights are not giving any signs of life when the board is not connected to the PC

Hi,

Are you still unable to solve this issue.Please follow the following procedure?

Sorry for the delayed reply.

1.Connect the Grove Uart Wifi to D2 port of Grove-Base shield V2.
2.Press the Switch in UART wifi for few seconds(until the Red LED in it glows).
3.Reset the arduino(The RED LED blinks in the Uart wifi in this step).
4.Upload the following code.

[code]//Grove UART WIFI Function : List of all available AP’s
//If Send ‘o’ or ‘f’ to serial monitor Turn the blue LINK led ON or OFF by Grove UART wifi
#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3); // RX, TX

void setup()
{
Serial.begin(115200);
mySerial.begin(115200);
delay(200);
Serial.println(“Enter the command ‘o’ or 'f”);

}

void loop()
{

if (Serial.available()){ // if there is incoming serial data
switch(Serial.read()) // read the character
{
case ‘o’: // If Send ‘o’ to serial monitor Turn the blue LINK led on by Grove UART wifi
LEDON();
break;
delay(200);

   case 'f': // If Send 'f' to serial monitor  Turn the blue LINK led off  by Grove UART wifi
   LEDOFF(); 
   break;
   delay(200);

}
}
if (mySerial.available()){ // If the grove uart wifi has something to say
Serial.write(mySerial.read()); // Display the output of the grove uart wifi
}
}

/* Name: LED ON/OFF function*/

void LEDON()
{
mySerial.println(“AT+LEDON”);//Comment for LED ON
delay(100);
mySerial.println();

}

void LEDOFF()
{
mySerial.println(“AT+LEDOFF”);//Comment for LED OFF
delay(100);
mySerial.println();

}
[/code]
5.Now using the serial monitor input type "o"to switch on the LED and “f” to switch off the LED.

Thanks and Regards

Yeah, still not working.

Tried with your example, here’s the output from the serial monitor:

Enter the command ‘o’ or 'f
AT+LEDON

ERROR

So seems like something is wrong with the module?