Różnice
Różnice między wybraną wersją a wersją aktualną.
| Poprzednia rewizja po obu stronach Poprzednia wersja Nowa wersja | Poprzednia wersja | ||
| programowanie:esp32:wifi [2024/08/10 00:13] – sases | programowanie:esp32:wifi [2024/09/08 12:11] (aktualna) – sases | ||
|---|---|---|---|
| Linia 1: | Linia 1: | ||
| - | ====== WiFi na ESP 32 ====== | + | ====== WiFi na ESP32 ====== |
| Obsługa WiFi na ESP32.\\ | Obsługa WiFi na ESP32.\\ | ||
| \\ | \\ | ||
| - | |||
| - | === Kod === | ||
| \\ | \\ | ||
| - | Deklaracje | + | |
| + | ===== Deklaracje | ||
| <code c> | <code c> | ||
| #include " | #include " | ||
| #include < | #include < | ||
| - | const String WiFi_SSID = " | + | const String WiFi_SSID = " |
| - | const String WiFi_password = " | + | const String WiFi_password = " |
| - | String WiFi_IP = ""; | + | String WiFi_IP = ""; |
| WiFiClient wifiClient; | WiFiClient wifiClient; | ||
| Linia 19: | Linia 19: | ||
| </ | </ | ||
| \\ | \\ | ||
| - | Połączenie podczas uruchomienia | + | \\ |
| + | |||
| + | ===== Połączenie podczas uruchomienia | ||
| <code c> | <code c> | ||
| void setup() | void setup() | ||
| Linia 27: | Linia 30: | ||
| </ | </ | ||
| \\ | \\ | ||
| - | Ponowne łączenie w przypadku rozłączenia | + | \\ |
| + | |||
| + | ===== Ponowne łączenie w przypadku rozłączenia | ||
| <code c> | <code c> | ||
| void loop() | void loop() | ||
| Linia 36: | Linia 42: | ||
| </ | </ | ||
| \\ | \\ | ||
| - | Funkcja | + | \\ |
| + | |||
| + | ===== Funkcja | ||
| <code c> | <code c> | ||
| void connectWiFi() | void connectWiFi() | ||
| - | { // ustanawianie połączenia WiFi | + | { |
| digitalWrite(BUILT_LED, | digitalWrite(BUILT_LED, | ||
| WiFi.hostname(myHostname); | WiFi.hostname(myHostname); | ||
| Linia 55: | Linia 64: | ||
| } | } | ||
| ++attempt; | ++attempt; | ||
| - | vTaskDelay(pdMS_TO_TICKS(200)); | + | vTaskDelay(pdMS_TO_TICKS(500)); |
| wl_status_t status = WiFi.status(); | wl_status_t status = WiFi.status(); | ||
| Linia 78: | Linia 87: | ||
| </ | </ | ||
| \\ | \\ | ||
| - | === Kody błędów === | + | [[inne: |
| + | \\ | ||
| + | \\ | ||
| + | |||
| + | ===== Kody błędów ===== | ||
| ^ WL_NO_SHIELD | 255 | assigned when no WiFi shield is present | | ^ WL_NO_SHIELD | 255 | assigned when no WiFi shield is present | | ||
| ^ WL_IDLE_STATUS | 0 | it is a temporary status assigned when WiFi.begin() is called and remains active until the number of attempts expires (resulting in WL_CONNECT_FAILED) or a connection is established (resulting in WL_CONNECTED) | | ^ WL_IDLE_STATUS | 0 | it is a temporary status assigned when WiFi.begin() is called and remains active until the number of attempts expires (resulting in WL_CONNECT_FAILED) or a connection is established (resulting in WL_CONNECTED) | | ||