Grove - UART WiFi
Contents
UART Wifi
WiFi Chip = ESP8266
LEDs : 3 LEDs [Power] [WiFi] [AT Command]
1 Button: Short press to Reset | Long press to enter UART boot mode
Input voltage: 3V / 5V
Baud Rate: 115200
Antenna Type = On-board
images
Assemblage
<poem> 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
Template:Rouge connecté au port SERIAL
</poem>
Code
// 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
www.seeedstudio.com/Grove-Uart-Wifi-p-2495.html shop bazar
github.com/Seeed-Studio/OLED_Display_128X64 github
wiki.seeedstudio.com/Grove-UART_Wifi wiki