Difference between revisions of "Grove - UART WiFi"

From
Jump to: navigation, search
(UART Wifi)
(Assemblage)
 
(25 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
=== UART Wifi ===
 
=== UART Wifi ===
  
WiFi Chip = ESP8266<br>
+
WiFi Chip = <b>ESP8266</b><br>
  
LEDs : 3 LEDs-Power/WiFi/AT Command<br>
+
LEDs : <b>3 LEDs</b> [Power] [WiFi] [AT Command]<br>
  
1 Button: <b>Short press</b> to Reset | Long press to enter UART boot mode
+
1 Button: <b>Short press</b> to Reset | <b>Long press</b> to enter UART boot mode
 +
 
 +
Input voltage: 3V / 5V<br>
 +
Baud Rate: 115200<br>
  
 
Antenna Type = On-board
 
Antenna Type = On-board
Line 11: Line 14:
 
=== images ===
 
=== images ===
  
[[File:Grove - UART Wifi V2 front.jpg | 300px]]
+
[[File:Grove_UART_WiFi_1.jpg | 400px]]
[[File:Grove - UART Wifi V2 back.jpg | 300px]]
+
[[File:Grove_UART_WiFi_2.jpg | 500px]]
 +
[[File:Grove_UART_WiFi_3.jpg | 400px]]
 +
 
 +
=== Assemblage ===
 +
 
 +
 
 +
Dans le wiki le code est écrit pour Seeeduino Lite, qui utilisé <font color=red>Serial1</font><br>
 +
pour les autres contrôleurs mentionnés ici il faut remplacer par <font color=red>Serial</font><br>
 +
 
 +
le code ici indiqué est compatible pour les 3 contrôleurs<br>
 +
 
 +
[[Seeeduino V4.2| Seeeduino V4.2]]<br>
 +
[[Seeeduino Nano| Seeeduino Nano]]<br>
 +
[[Seeeduino Cortex-M0+| Seeeduino Cortex-M0+]]<br>
 +
 
 +
Le code a besoin de :
 +
[[OLED Display 0.96| OLED Display 0.96 inches ]] connecté au <b>port I2C</b><br>
 +
et du <font color=red>Grove-UART Wifi</font> présenté ici connecté au <b>port SERIAL</b>
 +
 
 +
[[File:Grove_UART_WiFi_&_OLED_0.96_1.jpg | 300px]]
 +
[[File:Grove_UART_WiFi_&_OLED_0.96_2.jpg | 300px]]
 +
 
 +
=== Code ===
 +
 
 +
<pre>
 +
// test grove - uart wifi
 +
// scan ap and display on Grove - OLED 0.96'
 +
// Loovee @ 2015-7-28
  
[[File:Grove - UART Wifi V2.jpg | 400px]]
+
#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);
 +
    }
 +
}
 +
 
 +
</pre>
  
 
=== Liens ===
 
=== Liens ===
  
[https://www.seeedstudio.com/Grove-UART-WiFi-V2-ESP8285.html www.seeedstudio.com/Grove-UART-WiFi-V2-ESP8285.html] shop bazar
+
[https://www.seeedstudio.com/Grove-Uart-Wifi-p-2495.html www.seeedstudio.com/Grove-Uart-Wifi-p-2495.html] <b>shop bazar</b>
 +
 
 +
[http://wiki.seeedstudio.com/Grove-UART_Wifi/ wiki.seeedstudio.com/Grove-UART_Wifi] <b>wiki</b>
  
[https://github.com/Seeed-Studio/OLED_Display_128X64 github.com/Seeed-Studio/OLED_Display_128X64] github
+
=== Libraries ===
  
[http://wiki.seeedstudio.com/Grove-UART_Wifi_V2/ wiki.seeedstudio.com/Grove-UART_Wifi_V2] wiki
+
[https://github.com/Seeed-Studio/OLED_Display_128X64 github.com/Seeed-Studio/OLED_Display_128X64] <b>github</b>
  
=== Libraries ===
+
[https://github.com/Seeed-Studio/OLED_Display_128X64/archive/master.zip github.com/Seeed-Studio/OLED_Display_128X64/archive/master.zip] <b>ZIP</b>

Latest revision as of 21:01, 10 October 2024

UART Wifi[edit]

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[edit]

Grove UART WiFi 1.jpg Grove UART WiFi 2.jpg Grove UART WiFi 3.jpg

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 de : OLED Display 0.96 inches connecté au port I2C
et du Grove-UART Wifi présenté ici connecté au port SERIAL

Grove UART WiFi & OLED 0.96 1.jpg Grove UART WiFi & OLED 0.96 2.jpg

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-p-2495.html shop bazar

wiki.seeedstudio.com/Grove-UART_Wifi wiki

Libraries[edit]

github.com/Seeed-Studio/OLED_Display_128X64 github

github.com/Seeed-Studio/OLED_Display_128X64/archive/master.zip ZIP