Grove - UART WiFi V2
UART Wifi V2[edit]
WiFi Chip = ESP8285
Antenna Type = On-board
images[edit]
Assemblage[edit]
Dans le wiki le code est écrit pour Seeeduino Lite, qui utilisé Serial1
pour les autres contrôleurs mentionnés ici il faut remplacer par Serial
le code ici indiqué est compatible pour les 3 contrôleurs
Seeeduino V4.2
Seeeduino Nano
Seeeduino Cortex-M0+
Le code a besoin
OLED Display 0.96 inches connecté au port I2C
Grove-UART Wifi connecté au port SERIAL
Code[edit]
// test grove - uart wifi
// scan ap and display on Grove - OLED 0.96'
// Loovee @ 2015-7-28
#include <Wire.h>
#include <SeeedOLED.h>
char ap_buf[30][16];
int ap_cnt = 0;
void setup()
{
Serial.begin(115200);
delay(3000);
Wire.begin();
SeeedOled.init(); // initialze SEEED OLED display
SeeedOled.clearDisplay(); // clear the screen and set start position to top left corner
SeeedOled.setNormalDisplay(); // Set display to normal mode (i.e non-inverse mode)
SeeedOled.setPageMode(); // Set addressing mode to Page Mode
}
void loop()
{
ap_cnt = 0;
SeeedOled.clearDisplay();
SeeedOled.setTextXY(3,0);
SeeedOled.putString("Wifi Scan...");
cmd_send("AT+CWLAP");
wait_result();
display_ap();
delay(5000);
}
// send command
void cmd_send(char *cmd)
{
if(NULL == cmd)return;
Serial.println(cmd);
}
// wait result of ap scan
// +CWLAP:(3,"360WiFi-UZ",-81,"08:57:00:01:61:ec",1)
void wait_result()
{
while(1)
{
LOOP1:
char c1=0;
if(Serial.available()>=2)
{
c1 = Serial.read();
if(c1 == 'O' && 'K' == Serial.read())return; // OK means over
}
if('('==c1)
{
while(Serial.available()<3);
Serial.read();
Serial.read();
Serial.read();
int d = 0;
while(1)
{
if(Serial.available() && '"' == Serial.read()); // find "
{
while(1)
{
if(Serial.available())
{
char c = Serial.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);
SeeedOled.clearDisplay(); // clear
SeeedOled.setTextXY(3,3); // Set the cursor to Xth Page, Yth Column
SeeedOled.putString(strtmp); // Print the String
delay(2000);
int cnt = ap_cnt;
int offset = 0;
while(1)
{
SeeedOled.clearDisplay();
if(cnt>=8)
{
for(int i=0; i<8; i++)
{
SeeedOled.setTextXY(i,0); // Set the cursor to Xth Page, Yth Column
SeeedOled.putString(ap_buf[8*offset+i]); // Print the String
}
cnt-=8;
offset++;
}
else
{
for(int i=0; i<cnt; i++)
{
SeeedOled.setTextXY(i,0); // Set the cursor to Xth Page, Yth Column
SeeedOled.putString(ap_buf[8*offset+i]); // Print the String
}
return;
}
delay(2000);
}
}
Liens[edit]
www.seeedstudio.com/Grove-UART-WiFi-V2-ESP8285.html shop bazar
wiki.seeedstudio.com/Grove-UART_Wifi_V2 wiki