1.. _esp32_wifi_station:
2
3Espressif ESP32 WiFi Station
4############################
5
6Overview
7********
8
9This sample demonstrates how to use ESP32 to connect to a WiFi network as a station device.
10To configure WiFi credentials, edit ``prj.conf``.
11Enabling the ``net_shell`` module provides a set of commands to test the connection.
12See :ref:`network shell <net_shell>` for more details.
13
14Building and Running
15********************
16
17Make sure you have the ESP32 connected over USB port.
18
19The sample can be built and flashed as follows:
20
21.. code-block:: console
22
23   west build -b esp32 samples/boards/esp32/wifi_station
24   west flash --esp-device /dev/ttyUSB0
25
26Sample Output
27=============
28
29To check output of this sample, any serial console program can be used (i.e. on Linux minicom, putty, screen, etc)
30This example uses ``picocom`` on the serial port ``/dev/ttyUSB0``:
31
32.. code-block:: console
33
34   $ picocom /dev/ttyUSB0 - 115200
35
36.. code-block:: console
37
38   I (288) boot: Loaded app from partition at offset 0x10000
39   I (288) boot: Disabling RNG early entropy source...
40   I (611) wifi:wifi driver task: 3ffb2be8, prio:2, stack:3584, core=0
41   I (613) wifi:wifi firmware version: 9c89486
42   I (613) wifi:wifi certification version: v7.0
43   I (614) wifi:config NVS flash: disabled
44   I (618) wifi:config nano formating: disabled
45   I (622) wifi:Init data frame dynamic rx buffer num: 32
46   I (627) wifi:Init management frame dynamic rx buffer num: 32
47   I (632) wifi:Init management short buffer num: 32
48   I (636) wifi:Init dynamic tx buffer num: 32
49   I (640) wifi:Init static rx buffer size: 1600
50   I (645) wifi:Init static rx buffer num: 10
51   I (648) wifi:Init dynamic rx buffer num: 32
52   phy_version: 4350, 18c5e94, Jul 27 2020, 21:04:07, 0, 2
53   I (783) wifi:mode : softAP (24:6f:28:80:32:e9)
54   I (784) wifi:Total power save buffer number: 16
55   I (784) wifi:Init max length of beacon: 752/752
56   I (788) wifi:Init max length of beacon: 752/752
57   *** Booting Zephyr OS build zephyr-v2.4.0-49-g4da59e1678f7  ***
58   I (798) wifi:mode : sta (24:6f:28:80:32:e8)
59   I (1046) wifi:new:<4,1>, old:<1,1>, ap:<255,255>, sta:<4,1>, prof:1
60   I (1694) wifi:state: init -> auth (b0)
61   I (1711) wifi:state: auth -> assoc (0)
62   I (1717) wifi:state: assoc -> run (10)
63   I (1745) wifi:connected with myssid, aid = 4, channel 4, 40U, bssid = d8:07:b6:dd:47:7a
64   I (1745) wifi:security: WPA2-PSK, phy: bgn, rssi: -57
65   I (1747) wifi:pm start, type: 1
66
67   esp_event: WIFI STA start
68   esp_event: WIFI STA connected
69   I (1813) wifi:AP's beacon interval = 102400 us, DTIM period = 1
70   net_dhcpv4: Received: 192.168.68.102
71   esp32_wifi_sta: Your address: 192.168.68.102
72   esp32_wifi_sta: Lease time: 7200 seconds
73   esp32_wifi_sta: Subnet: 255.255.255.0
74   esp32_wifi_sta: Router: 192.168.68.1
75
76Sample console interaction
77==========================
78
79If the :kconfig:`CONFIG_NET_SHELL` option is set, network shell functions
80can be used to check internet connection.
81
82.. code-block:: console
83
84   shell> net ping 8.8.8.8
85   PING 8.8.8.8
86   28 bytes from 8.8.8.8 to 192.168.68.102: icmp_seq=0 ttl=118 time=19 ms
87   28 bytes from 8.8.8.8 to 192.168.68.102: icmp_seq=1 ttl=118 time=16 ms
88   28 bytes from 8.8.8.8 to 192.168.68.102: icmp_seq=2 ttl=118 time=21 ms
89