Connecting WiFi to esp32

How can I connect my Wi-Fi to this microcontroller using c++ on the https://platformio.org/? https://www.digikey.ca/en/products/detail/espressif-systems/ESP32-S2-DEVKITC-1U/15222558

https://platformio.org/ does not support this board out of the box: Request for Espressif ESP32-S2-DevKitC-1-N8R2 Board · Issue #1502 · platformio/platform-espressif32 · GitHub

Regards,

1 Like

ESP32 Sketch: Web Dashboard Control

#include <Keypad.h>
#include <WiFi.h>
#include <WebServer.h>

// Wi-Fi credentials
const char* ssid = "YourSSID";
const char* password = "YourPassword";

// RGB LED pins
#define RED_PIN    5
#define GREEN_PIN  6
#define BLUE_PIN   7
#define BUZZER_PIN 4

String enteredCode = "";
const String correctPasscode = "1234";

// Web server
WebServer server(80);

// Setup RGB/Buzzer
void setColor(bool r, bool g, bool b) {
  digitalWrite(RED_PIN, r);
  digitalWrite(GREEN_PIN, g);
  digitalWrite(BLUE_PIN, b);
}

void beep(int times) {
  for (int i = 0; i < times; i++) {
    tone(BUZZER_PIN, 1000);
    delay(200);
    noTone(BUZZER_PIN);
    delay(200);
  }
}

// Handle virtual keypress
void handleKeypress() {
  if (!server.hasArg("key")) {
    server.send(400, "text/plain", "Missing key");
    return;
  }
  char key = server.arg("key")[0];
  enteredCode += key;

  if (enteredCode.length() == 4) {
    if (enteredCode == correctPasscode) {
      setColor(0, 1, 0);
      beep(3);
      server.send(200, "text/plain", "Access Granted");
    } else {
      setColor(1, 0, 0);
      beep(1);
      server.send(403, "text/plain", "Access Denied");
    }
    delay(2000);
    setColor(0, 0, 1);
    enteredCode = "";
  } else {
    server.send(200, "text/plain", "Key Received");
  }
}

void setup() {
  Serial.begin(115200);
  pinMode(RED_PIN, OUTPUT);
  pinMode(GREEN_PIN, OUTPUT);
  pinMode(BLUE_PIN, OUTPUT);
  pinMode(BUZZER_PIN, OUTPUT);
  setColor(0, 0, 1); // Blue waiting

  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("\nWiFi Connected. IP: " + WiFi.localIP().toString());

  server.on("/keypress", handleKeypress);
  server.on("/", []() {
    server.send(200, "text/html", "<h2>ESP32 Keypad Control</h2>");
  });
  server.begin();
}

void loop() {
  server.handleClient();
}

Dashboard (HTML Page)

Virtual Keypad button { width: 60px; height: 60px; font-size: 24px; margin: 5px; }

IoT Virtual Keypad

1 2 3
4 5 6
7 8 9
0