WiFi connection

This commit is contained in:
Pfeifer 2025-07-04 12:40:35 +02:00
parent b400e5be3c
commit 7d13db4c1b

25
esp/main/main.ino Normal file
View File

@ -0,0 +1,25 @@
#include <WiFi.h>
#include <PubSubClient.h>
// WiFi
const char *ssid = "xxxxx"; // Enter your WiFi name
const char *password = "xxxxx"; // Enter WiFi password
// MQTT Broker
const char *mqtt_broker = "";
const char *topic = "reinhold/test";
const int mqtt_port = 1883;
const char *client_id = "m5-esp";
Wifi.begin(ssid, password);
client.setServer(mqtt_broker, mqtt_port);
client.setCallback(callback);
client.connect(client_id.c_str());
void callback(char *topic, byte *payload, unsigned int length) {
for (int i = 0; i < length; i++) {
Serial.print((char) payload[i]);
}
}