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.