This commit is contained in:
Jérémy CHOMAZ 2024-11-09 13:44:45 +01:00
commit b83aee3a6f

View File

@ -2,11 +2,13 @@
#include <PubSubClient.h>
// Configurations WiFi et MQTT
const char* ssid = "Redmi Note 13 Pro 5G";
const char* password = "1234567890";
const char* mqtt_server = "192.168.127.208";
const char* ssid = "fablab";
const char* password = "geek make code do";
const char* mqtt_server = "192.168.73.20";
const char* mqtt_topic = "brainblast/buzzer/pressed/1";
const char* mqtt_message = "{\"buzzer_id\": 1, \"color\": \"#FF7518\"}";
//hostname wifi et client id mqtt
const char* esp_name = "BUZZER-1";
// Déclaration des broches
#define BUTTON_PIN D8
@ -18,6 +20,7 @@ void setup_wifi() {
delay(10);
Serial.println();
Serial.print("Connexion au WiFi...");
WiFi.hostname(esp_name);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
@ -34,7 +37,7 @@ void setup_wifi() {
void reconnect() {
while (!client.connected()) {
Serial.print("Connexion au broker MQTT...");
if (client.connect("ESP8266Client")) {
if (client.connect(esp_name)) {
Serial.println("connecté");
} else {
Serial.print("échec, rc=");