· 6 months ago · Mar 19, 2025, 04:26 PM
1/********* Pleasedontcode.com **********
2
3 Pleasedontcode thanks you for automatic code generation! Enjoy your code!
4
5 - Terms and Conditions:
6 You have a non-exclusive, revocable, worldwide, royalty-free license
7 for personal and commercial use. Attribution is optional; modifications
8 are allowed, but you're responsible for code maintenance. We're not
9 liable for any loss or damage. For full terms,
10 please visit pleasedontcode.com/termsandconditions.
11
12 - Project: **Wi-Fi Server**
13 - Source Code NOT compiled for: ESP32 DevKit V1
14 - Source Code created on: 2025-03-19 15:30:23
15
16********* Pleasedontcode.com **********/
17
18/****** SYSTEM REQUIREMENTS *****/
19/****** SYSTEM REQUIREMENT 1 *****/
20 /* I want to connect my esp32 to MIT app inventor so */
21 /* i could control my system via app */
22/****** END SYSTEM REQUIREMENTS *****/
23
24/* START CODE */
25
26/****** DEFINITION OF LIBRARIES *****/
27#include <WiFi.h>
28#include <ESPAsyncWebServer.h>
29#include <ArduinoJson.h>
30
31/****** FUNCTION PROTOTYPES *****/
32void setup(void);
33void loop(void);
34
35// WiFi credentials
36const char* ssid = "your_SSID"; // Replace with your network SSID
37const char* password = "your_PASSWORD"; // Replace with your network password
38
39// Create an instance of the server on port 80
40AsyncWebServer server(80);
41
42void setup(void)
43{
44 // Initialize Serial for debugging
45 Serial.begin(115200);
46
47 // Connect to Wi-Fi
48 WiFi.begin(ssid, password);
49 while (WiFi.status() != WL_CONNECTED) {
50 delay(1000);
51 Serial.println("Connecting to WiFi...");
52 }
53 Serial.println("Connected to WiFi");
54
55 // Define a route for the root URL
56 server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
57 request->send(200, "text/plain", "Hello from ESP32");
58 });
59
60 // Start the server
61 server.begin();
62}
63
64void loop(void)
65{
66 // put your main code here, to run repeatedly:
67}
68
69/* END CODE */