buzzer: Envoi un message complet sur le bon topic
This commit is contained in:
parent
9147b40d47
commit
2a5fb6c613
@ -5,7 +5,8 @@
|
||||
const char* ssid = "Redmi Note 13 Pro 5G";
|
||||
const char* password = "1234567890";
|
||||
const char* mqtt_server = "192.168.127.208";
|
||||
const char* mqtt_topic = "bouton/etat";
|
||||
const char* mqtt_topic = "brainblast/buzzer/pressed/1";
|
||||
const char* mqtt_message = "{\"buzzer_id\": 1, \"color\": \"#FF7518\"}";
|
||||
|
||||
// Déclaration des broches
|
||||
#define BUTTON_PIN D8
|
||||
@ -61,7 +62,7 @@ void loop() {
|
||||
// Vérifier si le bouton est pressé
|
||||
if (digitalRead(BUTTON_PIN) == HIGH) {
|
||||
Serial.println("Bouton pressé, envoi du message...");
|
||||
client.publish(mqtt_topic, "Bouton presse");
|
||||
client.publish(mqtt_topic, mqtt_message);
|
||||
delay(200); // Anti-rebond pour éviter les publications multiples
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user