Set MQTT username and password

This commit is contained in:
2025-12-09 10:02:47 +01:00
parent 9bad1790a7
commit c53783072e
2 changed files with 7 additions and 0 deletions
+5
View File
@@ -3,10 +3,15 @@
// TODO: make this a config.h
// WI-FI
#define SSID "your_wifi_ssid"
#define PASSWORD "your_wifi_password"
#define AUTH_MODE WIFI_AUTH_WPA2_PSK
// MQTT
#define MQTT_ADDR "mqtt://yourmqttserver"
#define MQTT_PORT 1883
#define MQTT_USER "your_username"
#define MQTT_PASS "your_password"
#endif
+2
View File
@@ -66,6 +66,8 @@ static void mqtt_init(void) {
mqtt_cfg.broker.address.uri = MQTT_ADDR;
mqtt_cfg.broker.address.port = MQTT_PORT;
mqtt_cfg.credentials.username = MQTT_USER;
mqtt_cfg.credentials.authentication.password = MQTT_PASS;
mqtt_client = esp_mqtt_client_init(&mqtt_cfg);