如何在Arduino中使用ESP32創建Web伺服器(帶有WebSocket)



這是ESP32 WebSocket伺服器視頻的延續:https://www.youtube.com/watch?v=ZbX-l1Dl4N4。讓我們再上一個台階!我們首先使用Arduino在ESP32上託管Web伺服器和WebSocket伺服器。接下來,我們使用SPIFFS上傳一個單獨編寫的簡單index.html頁面。該頁面將打開一個與ESP32的WebSocket連接,在這裡我們可以使用頁面的按鈕來切換LED(相對較快)。

請注意,此處我們將ESP32用作接入點(AP)以簡化過程。如果希望將Web伺服器放置在本地網路上,則可以取消訪問點。

WebSocket在客戶端和伺服器之間提供了持久的連接,因此任何一方都可以隨時發送數據。它們在聯網視頻遊戲等方面非常有用,但如果我們需要通過網路快速控制硬體,它們也可以應用於IoT設備。

視頻中的Arduino和HTML代碼可以在以下位置找到:http://shawnhymel.com/1882/how-to-create-a-web-server-with-websockets-using-an-esp32-in-arduino/。

14 comments
  1. Hi, I would like to ask the way around. How about create a node websocket server and client, and esp32 as an endpoint just to send data to server. Is that possible?

  2. „A few months ago「 – man, feels more like ages. But as always, great work, clean code. Minor improvement could be made trough the use of a captive portal, which opens directly after connecting to the access point. thumbs up

Comments are closed.