|
| 1 | +# WiFiClientConnect Example |
| 2 | + |
| 3 | +This example demonstrates how to connect to the WiFi and manage the status and disconnection from STA. |
| 4 | + |
| 5 | +# Supported Targets |
| 6 | + |
| 7 | +Currently, this example supports the following targets. |
| 8 | + |
| 9 | +| Supported Targets | ESP32 | ESP32-S2 | ESP32-C3 | |
| 10 | +| ----------------- | ----- | -------- | -------- | |
| 11 | + |
| 12 | +## How to Use Example |
| 13 | + |
| 14 | +* How to install the Arduino IDE: [Install Arduino IDE](https://github.com/espressif/arduino-esp32/tree/master/docs/arduino-ide). |
| 15 | + |
| 16 | +#### Using Arduino IDE |
| 17 | + |
| 18 | +* Before Compile/Verify, select the correct board: `Tools -> Board`. |
| 19 | +* Select the COM port: `Tools -> Port: xxx` where the `xxx` is the detected COM port. |
| 20 | + |
| 21 | +#### Using Platform IO |
| 22 | + |
| 23 | +* Select the COM port: `Devices` or set the `upload_port`` option on the `platformio.ini` file. |
| 24 | + |
| 25 | +## Example/Log Output |
| 26 | + |
| 27 | +``` |
| 28 | +[WiFi] Connecting to MyWiFiNetwork |
| 29 | +[ 66][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 0 - WIFI_READY |
| 30 | +[ 150][V][WiFiGeneric.cpp:338] _arduino_event_cb(): STA Started |
| 31 | +[ 151][V][WiFiGeneric.cpp:97] set_esp_interface_ip(): Configuring Station static IP: 0.0.0.0, MASK: 0.0.0.0, GW: 0.0.0.0 |
| 32 | +[ 151][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 2 - STA_START |
| 33 | +[WiFi] WiFi is disconnected |
| 34 | +[ 234][V][WiFiGeneric.cpp:353] _arduino_event_cb(): STA Connected: SSID: MyWiFiNetwork, BSSID: xx:xx:xx:xx:xx:xx, Channel: 8, Auth: WPA2_PSK |
| 35 | +[ 235][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 4 - STA_CONNECTED |
| 36 | +[ 560][V][WiFiGeneric.cpp:367] _arduino_event_cb(): STA Got New IP:192.168.68.114 |
| 37 | +[ 561][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 7 - STA_GOT_IP |
| 38 | +[ 564][D][WiFiGeneric.cpp:1004] _eventCallback(): STA IP: 192.168.68.114, MASK: 255.255.255.0, GW: 192.168.68.1 |
| 39 | +[WiFi] WiFi is connected! |
| 40 | +[WiFi] IP address: 192.168.68.114 |
| 41 | +[WiFi] Disconnecting from WiFi! |
| 42 | +[ 2633][V][WiFiGeneric.cpp:360] _arduino_event_cb(): STA Disconnected: SSID: MyWiFiNetwork, BSSID: xx:xx:xx:xx:xx:xx, Reason: 8 |
| 43 | +[ 2634][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 5 - STA_DISCONNECTED |
| 44 | +[ 2635][V][WiFiGeneric.cpp:341] _arduino_event_cb(): STA Stopped |
| 45 | +[ 2641][W][WiFiGeneric.cpp:953] _eventCallback(): Reason: 8 - ASSOC_LEAVE |
| 46 | +[ 2654][D][WiFiGeneric.cpp:975] _eventCallback(): WiFi the station is disconnected |
| 47 | +[ 2661][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 3 - STA_STOP |
| 48 | +[WiFi] Disconnected from WiFi! |
| 49 | +... |
| 50 | +``` |
| 51 | + |
| 52 | +## Troubleshooting |
| 53 | + |
| 54 | +***Important: Be sure you're using a good quality USB cable that has enough power for your project.*** |
| 55 | + |
| 56 | +* **Programming Fail:** If the programming/flash procedure fails, try to reduce the serial connection speed. |
| 57 | +* **COM port not detected:** Check the USB cable connection and the USB to Serial driver installation. |
| 58 | + |
| 59 | +If the error persists, you can ask for help at the official [ESP32 forum](https://esp32.com) or see [Contribute](#contribute). |
| 60 | + |
| 61 | +## Contribute |
| 62 | + |
| 63 | +To know how to contribute to this project, see [How to contribute.](https://github.com/espressif/arduino-esp32/blob/master/CONTRIBUTING.rst) |
| 64 | + |
| 65 | +If you have any **feedback** or **issue** to report on this example/library, please open an issue or fix it by creating a new PR. Contributions are more than welcome! |
| 66 | + |
| 67 | +Before creating a new issue, be sure to try Troubleshooting and check if the same issue was already created by someone else. |
| 68 | + |
| 69 | +## Resources |
| 70 | + |
| 71 | +* Arduino-ESP32 Official Repository: [espressif/arduino-esp32](https://github.com/espressif/arduino-esp32) |
| 72 | +* ESP32 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf) |
| 73 | +* ESP32-S2 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-s2_datasheet_en.pdf) |
| 74 | +* ESP32-C3 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-c3_datasheet_en.pdf) |
| 75 | +* Official ESP-IDF documentation: [ESP-IDF](https://idf.espressif.com) |
0 commit comments