Control ESP32 from ANYWHERE in the World - Step-By-Step Tutorial
ฝัง
- เผยแพร่เมื่อ 5 พ.ค. 2024
- Learn how to control ESP32 GPIO pins in real-time with AWS API Gateway WebSockets. I will show you step-by-step how to create and build:
- PlatformIO project with ESP32 WebSocket Client (C/C++)
- Serverless Framework project utilizing AWS API Gateway WebSockets, AWS Lambda, and AWS DynamoDB to handle the communication between clients (TypeScript)
- Web Application to control ESP32 from the browser (ReactJS)
👍 Subscribe for more IoT and programming tutorials like this: / @tomasztarnowski4434
Link to the code:
ESP32 Project - github.com/ttarnowski/esp32-w...
WebSocket Server Code - github.com/ttarnowski/esp32-w...
ESP32 Control Panel (React) - github.com/ttarnowski/esp32-c...
Serverless, AWS, TypeScript v2 template project - github.com/ttarnowski/serverl...
React, TypeScript, TailwindCSS, Vite template project - github.com/ttarnowski/vite-re...
How to get started with Serverless Framework:
• Getting started with A...
How to connect ESP32 to WiFi:
• Connect ESP32 to WiFi ...
How to build Web Chat with Serverless Framework and AWS API Gateway Websockets:
• How to Build a Realtim...
ESP32 Datasheet Specification: www.espressif.com/sites/defau...
NodeMCU 32S Development Board Specification:
circuits4you.com/2018/12/31/e...
Parts and components used in this video (affiliate links):
- NodeMCU-32S Development Board:
eBay UK - ebay.us/fpZEVO
eBay USA - ebay.us/7TqjQu
eBay DE - ebay.us/SUf9t1
AliExpress - s.click.aliexpress.com/e/_Dc9...
- USB Type-C to Micro USB cable (tested and working):
eBay UK - ebay.us/7z9AF6
eBay USA - ebay.us/cwrWGo
eBay DE - ebay.us/ixcU7P
AliExpress - s.click.aliexpress.com/e/_Dm6...
- LED Diode:
eBay UK - ebay.us/8y6xEz
eBay USA - ebay.us/38nwTv
eBay DE - ebay.us/UQNXy5
AliExpress - s.click.aliexpress.com/e/_DBE...
- Resistor equal to or greater than 75Ω:
eBay UK - ebay.us/a3nJTv
eBay USA - ebay.us/4fSgND
eBay DE - ebay.us/uael4z
AliExpress - s.click.aliexpress.com/e/_Ddu...
- Breadboard:
eBay UK - ebay.us/Mcsgpn
eBay USA - ebay.us/9Xr8uH
eBay DE - ebay.us/lQJ4XI
AliExpress - s.click.aliexpress.com/e/_Dlf...
- Wires:
eBay UK - ebay.us/jqCLLG
eBay USA - ebay.us/7p2Bjj
eBay DE - ebay.us/7MZ3Dc
AliExpress - s.click.aliexpress.com/e/_Dms...
Software used in the video:
Visual Studio Code IDE: code.visualstudio.com/
PlatformIO Extension: platformio.org/platformio-ide
Clang-Format Extensions (Code Formatter): marketplace.visualstudio.com/...
Social Media:
Twitter: / t_tarnowski
Linkedin: / tomasz-ta...
GitHub: github.com/ttarnowski
Thank you for watching and see you soon!
00:00 Intro
00:11 What I'm going to build
00:53 Hardware presentation
01:10 ESP32 Project - Creating Project with PlatformIO
02:11 ESP32 Project - Using ESP32 WiFi Connect Template
03:49 ESP32 Project - Adding WebSocket Client to the Code
07:55 ESP32 Project - Listening to WebSocket Client Events
09:29 ESP32 Project - Handling WebSocket Events
13:49 ESP32 Project - How to Validate and Parse WebSocket Message Event
27:49 ESP32 Project - Handle Pin Mode Command
33:20 ESP32 Project - Handle Digital Read&Write Commands
36:14 ESP32 Project - Additional Error Handling
37:38 ESP32 Project - Acknowledgement Message
39:39 AWS WebSocket Server - Creating the Project
41:57 AWS WebSocket Server - Infrastructure Configuration
46:30 AWS WebSocket Server - Implementing WebSocket Handler with TypeScript
51:15 AWS WebSocket Server - Client Connect Implementation
53:36 AWS WebSocket Server - Client Disconnect Implementation
55:40 AWS WebSocket Server - Pass the Message Implementation
01:08:04 AWS WebSocket Server - Walk-through the code
01:11:13 AWS WebSocket Server - Deployment to AWS
01:11:37 ESP32 Project - Updating the Code with URL to WebSocket Server
01:12:28 ESP32 Project - Deploying the Code to ESP32
01:13:29 ReactJS Control Panel - Creating the Project
01:16:23 ReactJS Control Panel - Importing WebSocket Client Hook
01:18:09 ReactJS Control Panel - Building UI
01:23:16 ReactJS Control Panel - Behaviour Implementation
01:26:41 ReactJS Control Panel - Sending a Digital Write Message to the WebSocket Server
01:29:00 ReactJS Control Panel - Pin Mode and Digital Read Behaviour
01:41:11 Hardware - Wiring up the LED Diode
01:42:16 Testing the Project Locally
01:44:02 ReactJS Control Panel - Deployment to AWS S3
01:47:50 Testing Newly Deployed Website
01:48:35 The End - วิทยาศาสตร์และเทคโนโลยี
thank you so much I spend whole 24 hours to get it to work and it works you saved my life man good luck
I'm very very glad that I managed to find your video. This will be of great help to my current project. Awesome work Tomasz, keep it up!
Thank you, Paulo!
I just started to see this video
and can say PERFECT, PERFECT, PERFECT
wish best for you and good luck 🍀
Thank you so much, Hamid TB!!
Very nice websocket tutorial, love your video quality!
Thank you, Hizbi!
Thank you so much. Very educated and professional coding. Could you also provide a documentation for controlling multiple ESP32s?
Браво братле!
amazing, thank you
Nice video. Just want to know if there is any limit on the max number of esp32 (at various locations) that we can connect using your explained method?
You are such an Angel thanks
Love it :) more sucg tutorials please :)
Novamente parabéns, conteúdo excelente, obrigado
Thank you for this it’s great thank you
Parabéns excelente vídeo
Awesome tutorial! Thanks alot
Thanks! I'm glad it helped!
Hello Tomasz! One question. When you started the project you selected "NodeMCU-32" board. The setup and the code Is the same if I use another ESP32 like ESP32 from espressif? I have a ESP32 devkit-v1
Thanks, great video!
Real good video, thanks. I think you lost a lot of people on the json part. It can be confusing if people do not know json format. Maybe do a video on json format and sending back and forth between client and host
Stary, ratujesz mi życie, teraz jestem biedny, ale po wypłacie aż wynagrodzę Ci to jakimś szeklem, tylko prosze dalej rób to co robisz :D
hej dzieki, ciesze sie ze pomoglem
Great Video And Good Explaination 😁😁
Thanks, Rizmy Abdulla :)
Hey, Why didnt you use AsyncWebServer or AsyncWebServerSocket? are there separate use cases for async one?
Hi Tomasz,
Thanks for your video and it very interest project .I was programing the three project and I had core problem the three program it the same project but the esp project I modify the program for esp8266 .
But the api gateway websokets server not connect .
The Wi-Fi connect is done already
On the esp8266 on monitor the massage show : WS disconnect
Dziękuje ci, pomogłeś mi ogarnąć sterowanie robota przez telefon na olimpiadę z mechatroniki.
Hi Tomasz,
hope you're well.
I am facing some issues when it comes to creating a path for the serverless AWS template. 00:41:00
Hi Tomasz , thanks a lot for your great video, I learned a lot from you
- do you have a tutorial how to make LittelFS run on ESP32 step by step (not ESP8266) from PlatformIO, I don't see any video for it on the network
Hey Eran, I don't have yet but I've managed to configure LittleFS with ESP32 and I will make a video about it soon.
Hello! Do you have the exact version of the .yml file for serverless on github? I am getting the error: "Cannot resolve variable at "resources.Resources.ClientsTable.Properties.TableName": Value not found at "self" source" when I use yard deploy and I think my code is the same as yours
thanks for uploading this video, can you make update for this video using azure
hey ,can we establish a websockets connection using only soft AP on a esp32 without internet ?
Hi, I need to make this with ESP-IDF. Could you show this implementation, or just code?
very helpful video. thanks you
Nice walkthrough and explanation. Why don’t you have more subscribers and views? Is it too complex for most viewers? Is it too involved? Don’t you match what people are searching for?
Thank you, Edwin. I think the channel is still too young as it's only been 16 months since I've started uploading videos. I hope the algorithms pick it up soon :)
As of today 16th January 2024, this code is no longer working. I have spent all day trying to make it work but no response. I went ahead to copy your code base, but still won't work. I think something has broken with the aws serverless
Do you have any other solution? Need some help
Hi Tomasz, I'm fairly new to this IOT stuff, i've one query, is all these web server using AWS, websocket free or we need to purchase some stuff? You didn't mention anything so it seems this all is free and we just need to purchase esp 32, led , resistor & breadboard.
In addition to above, if I wish to create cool IOT interfaces controlling stuff online, I need to learn JavaScript, aws & Esp 32 languages with their several libraries etc, is that right, or something else is required?
You have to establish an AWS account. It has a small number of free connections per month but as volume goes up so does cost.
Panie Tomaszu, panski project "Control ESP32 from Anywhere in the world" zwrocil moja uwage w zwiazku z tym ze tej zimy padly moje lithium battery zasilane przez solar panels i calkowicie stracilem mozliwosc wgladu na moja polane kilkaset kilometrow od domu. Postanowilem wiec kupic generator ktory moze byc odpalany przez remote control a to daje mozliwosc zainstalowania w nim ESP32 bo start jest automatyczny i choke jest automatyczny ....calosc zasilana z bateri 12v. Nie jestem z zawodu programista, kiedys naprawialem telewizory a arduino traktuje jako hobby . Moze to bylby jakis pomysl na przyszly projekt...dziekuje
Witam, pomysl jak najbardziej ciekawy, dziekuje za zainteresowanie kanalem :)
Hi, I have a question about at 41:07, I do not use macbook, I use code in window 11 so where should I paste the template in vscode?, I also download git for windows, but still dont know how to paste it, since it says --template-url not command found
Same problem...... I didn't understand..... Hay if you solved it can you please tell me....
@@jagdish9533
for windows
npm install -g serverless
npx serverless create --template-url github.com/ttarnowski/serverless-aws-nodejs-typescript-v2/tree/main --path websocket-server-api-gw
Hi sir, I don't really have experience in Arduino, but can I apply what you explained in this video by using esp8266?
Hi HUSSIN, yeah I think connecting to WiFi and using WebSocket client should be almost identical on ESP8266. You can also check my old videos about ESP8266 they might come useful to you.
40:56
Sir how to get that VS Code terminal in windows?
Pls help
hello,
try either gitforwindows.org/ or ubuntu subsystem on windows: ubuntu.com/wsl
sir WS disconnected is poping again and again
any alternative for aws?
can use normal server?
yeah, you can use a simple websocket server hosted somewhere on the internet to achieve the same results. BTW I'm working on something to simplify it so AWS won't be required :)
@@tomasztarnowski4434 thanks alot
I'm waiting for it...
How do I know my current home IP address? Without it I can't access my home network from anywhere...
I keep getting this error and not sure how to handle it:
[128400][E][WiFiClient.cpp:313] setSocketOption(): fail on -1, errno: 9, "Bad file number"
WS Disconnected
Hi Aaron,
this error: [128400][E][WiFiClient.cpp:313] setSocketOption(): fail on -1, errno: 9, "Bad file number"
is most likely unrelated to "WS Disconnected"
is your board connected to WiFi?
@@tomasztarnowski4434 Yes it is connected to wifi
Hi Aaron,
try to compile the project with the debug flags:
in you platformio.ini file add:
build_flags =
-D DEBUG_WEBSOCKETS
-D DEBUG_ESP_PORT=Serial
and check what serial monitor returns
where's the code of serverless.yml?
bookmark: 23:00
Oh man, u are to late, i need this knowledge 3month ago
there's more coming
maybe you'll find something useful :)
Sorry but for beginners this is complety crazy...😢
I can tell a full beginners video for me would be a titanic masterclass on the inputs and outputs of the tcp/ip layers of like 20 hours series
Me, a lazy dude, would have made everything a function used one time 🤣 just for beginners legibility
Or a full library 😂
I justo do a DHT temperature and humidity being see on an internet Pages acessível to all.
I give up! This is such a disastrous tutorial for a beginnner. It is ridiculously hard to follow with various components that you expect the viewer to know without ever specifying them.
After sinking about 5 hours in this video, trying to understand what you say and then solving all the errors you haven't mentioned including how you have to setup an AWS account, configure that information with your personal computer and so on.
At @42:16 , you just paste in code without every explaining where you got it from or how I can get it. Looking over your github repo, that code doesn't match as it contains addtional functions and leads to further several errors.
I still have multitudes of questions and errors. For example, when I deploy program, I keep getting erros like secret-key is not defined and etc. I would try to solve it but I don't even know where to start. Only by watching your other vidoes can I even begin to complete the puzzle.
As a self-learner with no knowledge of these concepts, you complete ruined the fun of the video. I have self-taught programming through online tutorials and I have never been left this confused and exhausted.
Instead of learning something new, I want to cry from frustration sinking so much time into a video while nothing to show for it.
What's most disappointing is that seeing your earlier video regarding hooking your esp32 to wifi and about platformio, I got so excited, but wasted my limited time on this 2 hour confusion fest.
This was a lot to know. Besides esp32, C and json, you have to know react, javascript and AWS. Thats a lot. One thing at a time then integrate them one by one.
I'm not sure that this video was geared towards beginners because of @noweare1's point
at least from what I can tell by looking for a solution like this, trying to control the device from anywhere in the world is quite an advanced concept as I can't find a lot of people that have done it from absolutely anywhere. Mostly just on local networks.
So if you are still into the IoT stuff I recommend starting a bit simpler than this. like trying to make it work with Low Bluetooth Energy.