Tracking du dossier VHard (les différents code des ESP, matériels embarqués.. etc)
This commit is contained in:
parent
4b4060bc8b
commit
c75dc90ad4
97
VHard/buzzer/rgb_jaune/rgb_jaune.ino
Normal file
97
VHard/buzzer/rgb_jaune/rgb_jaune.ino
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
#include <ESP8266WiFi.h>
|
||||||
|
#include <PubSubClient.h>
|
||||||
|
#include <Adafruit_NeoPixel.h>
|
||||||
|
|
||||||
|
// Configurations WiFi et MQTT
|
||||||
|
const char* ssid = "SaucissonLand";
|
||||||
|
const char* password = "47C619A574D41311C811EB563C";
|
||||||
|
const char* mqtt_server = "192.168.73.20";
|
||||||
|
const char* mqtt_topic = "vulture/buzzer/pressed/3";
|
||||||
|
const char* mqtt_message = "{\"buzzer_id\": 3, \"color\": \"#D4D100\"}";
|
||||||
|
//hostname wifi et client id mqtt
|
||||||
|
const char* esp_name = "BUZZER-3";
|
||||||
|
|
||||||
|
#define PIN D2 // Pin de données connectée à la bande WS2812B
|
||||||
|
#define NUM_LEDS 1 // Nombre de LEDs dans la bande
|
||||||
|
#define BRIGHTNESS 127 // Luminosité (127 = ~50%)
|
||||||
|
|
||||||
|
// Déclaration des broches
|
||||||
|
#define BUTTON_PIN D8
|
||||||
|
|
||||||
|
WiFiClient espClient;
|
||||||
|
PubSubClient client(espClient);
|
||||||
|
Adafruit_NeoPixel strip(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);
|
||||||
|
|
||||||
|
void blinkWhileConnecting() {
|
||||||
|
static unsigned long previousMillis = 0;
|
||||||
|
static bool ledState = false;
|
||||||
|
const long interval = 300; // clignotement toutes les 300ms
|
||||||
|
|
||||||
|
while (WiFi.status() != WL_CONNECTED) {
|
||||||
|
unsigned long currentMillis = millis();
|
||||||
|
if (currentMillis - previousMillis >= interval) {
|
||||||
|
previousMillis = currentMillis;
|
||||||
|
ledState = !ledState;
|
||||||
|
strip.setPixelColor(0, ledState ? strip.Color(255, 255, 255) : 0); // Jaune ON/OFF
|
||||||
|
strip.show();
|
||||||
|
}
|
||||||
|
yield(); // permet à l'ESP de ne pas bloquer le watchdog
|
||||||
|
}
|
||||||
|
|
||||||
|
// Une fois connecté, on allume la LED en fixe
|
||||||
|
strip.setPixelColor(0, strip.Color(0, 255, 0));
|
||||||
|
strip.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup_wifi() {
|
||||||
|
delay(10);
|
||||||
|
Serial.println();
|
||||||
|
Serial.print("Connexion au WiFi...");
|
||||||
|
WiFi.hostname(esp_name);
|
||||||
|
WiFi.begin(ssid, password);
|
||||||
|
|
||||||
|
blinkWhileConnecting(); // Clignotement pendant la connexion
|
||||||
|
|
||||||
|
Serial.println("\nWiFi connecté");
|
||||||
|
Serial.print("Adresse IP: ");
|
||||||
|
Serial.println(WiFi.localIP());
|
||||||
|
}
|
||||||
|
|
||||||
|
void reconnect() {
|
||||||
|
while (!client.connected()) {
|
||||||
|
Serial.print("Connexion au broker MQTT...");
|
||||||
|
if (client.connect(esp_name)) {
|
||||||
|
Serial.println("connecté");
|
||||||
|
} else {
|
||||||
|
Serial.print("échec, rc=");
|
||||||
|
Serial.print(client.state());
|
||||||
|
Serial.println("; nouvelle tentative dans 5 secondes");
|
||||||
|
delay(5000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Serial.begin(115200);
|
||||||
|
pinMode(BUTTON_PIN, INPUT_PULLUP);
|
||||||
|
strip.begin();
|
||||||
|
strip.setPixelColor(0, strip.Color(255, 255, 255));
|
||||||
|
strip.show();
|
||||||
|
|
||||||
|
setup_wifi();
|
||||||
|
client.setServer(mqtt_server, 1883);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
if (!client.connected()) {
|
||||||
|
reconnect();
|
||||||
|
}
|
||||||
|
client.loop();
|
||||||
|
|
||||||
|
// Vérifier si le bouton est pressé
|
||||||
|
if (digitalRead(BUTTON_PIN) == HIGH) {
|
||||||
|
Serial.println("Bouton pressé, envoi du message...");
|
||||||
|
client.publish(mqtt_topic, mqtt_message);
|
||||||
|
delay(200); // Anti-rebond pour éviter les publications multiples
|
||||||
|
}
|
||||||
|
}
|
73
VHard/buzzer/standard_bleu/standard_bleu.ino
Normal file
73
VHard/buzzer/standard_bleu/standard_bleu.ino
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
#include <ESP8266WiFi.h>
|
||||||
|
#include <PubSubClient.h>
|
||||||
|
|
||||||
|
// Configurations WiFi et MQTT
|
||||||
|
const char* ssid = "fablab";
|
||||||
|
const char* password = "geek make code do";
|
||||||
|
//const char* ssid = "SaucissonLand";
|
||||||
|
//const char* password = "47C619A574D41311C811EB563C";
|
||||||
|
const char* mqtt_server = "192.168.73.20";
|
||||||
|
const char* mqtt_topic = "vulture/buzzer/pressed/1";
|
||||||
|
const char* mqtt_message = "{\"buzzer_id\": 1, \"color\": \"#2867D4\"}";
|
||||||
|
//hostname wifi et client id mqtt
|
||||||
|
const char* esp_name = "BUZZER-1";
|
||||||
|
|
||||||
|
// Déclaration des broches
|
||||||
|
#define BUTTON_PIN D8
|
||||||
|
|
||||||
|
WiFiClient espClient;
|
||||||
|
PubSubClient client(espClient);
|
||||||
|
|
||||||
|
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) {
|
||||||
|
delay(500);
|
||||||
|
Serial.print(".");
|
||||||
|
}
|
||||||
|
|
||||||
|
Serial.println("");
|
||||||
|
Serial.println("WiFi connecté");
|
||||||
|
Serial.print("Adresse IP: ");
|
||||||
|
Serial.println(WiFi.localIP());
|
||||||
|
}
|
||||||
|
|
||||||
|
void reconnect() {
|
||||||
|
while (!client.connected()) {
|
||||||
|
Serial.print("Connexion au broker MQTT...");
|
||||||
|
if (client.connect(esp_name)) {
|
||||||
|
Serial.println("connecté");
|
||||||
|
} else {
|
||||||
|
Serial.print("échec, rc=");
|
||||||
|
Serial.print(client.state());
|
||||||
|
Serial.println("; nouvelle tentative dans 5 secondes");
|
||||||
|
delay(5000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Serial.begin(115200);
|
||||||
|
pinMode(BUTTON_PIN, INPUT_PULLUP);
|
||||||
|
|
||||||
|
setup_wifi();
|
||||||
|
client.setServer(mqtt_server, 1883);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
if (!client.connected()) {
|
||||||
|
reconnect();
|
||||||
|
}
|
||||||
|
client.loop();
|
||||||
|
|
||||||
|
// Vérifier si le bouton est pressé
|
||||||
|
if (digitalRead(BUTTON_PIN) == HIGH) {
|
||||||
|
Serial.println("Bouton pressé, envoi du message...");
|
||||||
|
client.publish(mqtt_topic, mqtt_message);
|
||||||
|
delay(200); // Anti-rebond pour éviter les publications multiples
|
||||||
|
}
|
||||||
|
}
|
73
VHard/buzzer/standard_jaune/standard_jaune.ino
Normal file
73
VHard/buzzer/standard_jaune/standard_jaune.ino
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
#include <ESP8266WiFi.h>
|
||||||
|
#include <PubSubClient.h>
|
||||||
|
|
||||||
|
// Configurations WiFi et MQTT
|
||||||
|
const char* ssid = "fablab";
|
||||||
|
const char* password = "geek make code do";
|
||||||
|
//const char* ssid = "SaucissonLand";
|
||||||
|
//const char* password = "47C619A574D41311C811EB563C";
|
||||||
|
const char* mqtt_server = "192.168.73.20";
|
||||||
|
const char* mqtt_topic = "vulture/buzzer/pressed/4";
|
||||||
|
const char* mqtt_message = "{\"buzzer_id\": 4, \"color\": \"#D4D100\"}";
|
||||||
|
//hostname wifi et client id mqtt
|
||||||
|
const char* esp_name = "BUZZER-4";
|
||||||
|
|
||||||
|
// Déclaration des broches
|
||||||
|
#define BUTTON_PIN D8
|
||||||
|
|
||||||
|
WiFiClient espClient;
|
||||||
|
PubSubClient client(espClient);
|
||||||
|
|
||||||
|
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) {
|
||||||
|
delay(500);
|
||||||
|
Serial.print(".");
|
||||||
|
}
|
||||||
|
|
||||||
|
Serial.println("");
|
||||||
|
Serial.println("WiFi connecté");
|
||||||
|
Serial.print("Adresse IP: ");
|
||||||
|
Serial.println(WiFi.localIP());
|
||||||
|
}
|
||||||
|
|
||||||
|
void reconnect() {
|
||||||
|
while (!client.connected()) {
|
||||||
|
Serial.print("Connexion au broker MQTT...");
|
||||||
|
if (client.connect(esp_name)) {
|
||||||
|
Serial.println("connecté");
|
||||||
|
} else {
|
||||||
|
Serial.print("échec, rc=");
|
||||||
|
Serial.print(client.state());
|
||||||
|
Serial.println("; nouvelle tentative dans 5 secondes");
|
||||||
|
delay(5000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Serial.begin(115200);
|
||||||
|
pinMode(BUTTON_PIN, INPUT_PULLUP);
|
||||||
|
|
||||||
|
setup_wifi();
|
||||||
|
client.setServer(mqtt_server, 1883);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
if (!client.connected()) {
|
||||||
|
reconnect();
|
||||||
|
}
|
||||||
|
client.loop();
|
||||||
|
|
||||||
|
// Vérifier si le bouton est pressé
|
||||||
|
if (digitalRead(BUTTON_PIN) == HIGH) {
|
||||||
|
Serial.println("Bouton pressé, envoi du message...");
|
||||||
|
client.publish(mqtt_topic, mqtt_message);
|
||||||
|
delay(200); // Anti-rebond pour éviter les publications multiples
|
||||||
|
}
|
||||||
|
}
|
73
VHard/buzzer/standard_rouge/standard_rouge.ino
Normal file
73
VHard/buzzer/standard_rouge/standard_rouge.ino
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
#include <ESP8266WiFi.h>
|
||||||
|
#include <PubSubClient.h>
|
||||||
|
|
||||||
|
// Configurations WiFi et MQTT
|
||||||
|
const char* ssid = "fablab";
|
||||||
|
const char* password = "geek make code do";
|
||||||
|
//const char* ssid = "SaucissonLand";
|
||||||
|
//const char* password = "47C619A574D41311C811EB563C";
|
||||||
|
const char* mqtt_server = "192.168.73.20";
|
||||||
|
const char* mqtt_topic = "vulture/buzzer/pressed/2";
|
||||||
|
const char* mqtt_message = "{\"buzzer_id\": 2, \"color\": \"#D42828\"}";
|
||||||
|
//hostname wifi et client id mqtt
|
||||||
|
const char* esp_name = "BUZZER-2";
|
||||||
|
|
||||||
|
// Déclaration des broches
|
||||||
|
#define BUTTON_PIN D8
|
||||||
|
|
||||||
|
WiFiClient espClient;
|
||||||
|
PubSubClient client(espClient);
|
||||||
|
|
||||||
|
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) {
|
||||||
|
delay(500);
|
||||||
|
Serial.print(".");
|
||||||
|
}
|
||||||
|
|
||||||
|
Serial.println("");
|
||||||
|
Serial.println("WiFi connecté");
|
||||||
|
Serial.print("Adresse IP: ");
|
||||||
|
Serial.println(WiFi.localIP());
|
||||||
|
}
|
||||||
|
|
||||||
|
void reconnect() {
|
||||||
|
while (!client.connected()) {
|
||||||
|
Serial.print("Connexion au broker MQTT...");
|
||||||
|
if (client.connect(esp_name)) {
|
||||||
|
Serial.println("connecté");
|
||||||
|
} else {
|
||||||
|
Serial.print("échec, rc=");
|
||||||
|
Serial.print(client.state());
|
||||||
|
Serial.println("; nouvelle tentative dans 5 secondes");
|
||||||
|
delay(5000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Serial.begin(115200);
|
||||||
|
pinMode(BUTTON_PIN, INPUT_PULLUP);
|
||||||
|
|
||||||
|
setup_wifi();
|
||||||
|
client.setServer(mqtt_server, 1883);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
if (!client.connected()) {
|
||||||
|
reconnect();
|
||||||
|
}
|
||||||
|
client.loop();
|
||||||
|
|
||||||
|
// Vérifier si le bouton est pressé
|
||||||
|
if (digitalRead(BUTTON_PIN) == HIGH) {
|
||||||
|
Serial.println("Bouton pressé, envoi du message...");
|
||||||
|
client.publish(mqtt_topic, mqtt_message);
|
||||||
|
delay(200); // Anti-rebond pour éviter les publications multiples
|
||||||
|
}
|
||||||
|
}
|
73
VHard/buzzer/standard_vert/standard_vert.ino
Normal file
73
VHard/buzzer/standard_vert/standard_vert.ino
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
#include <ESP8266WiFi.h>
|
||||||
|
#include <PubSubClient.h>
|
||||||
|
|
||||||
|
// Configurations WiFi et MQTT
|
||||||
|
const char* ssid = "fablab";
|
||||||
|
const char* password = "geek make code do";
|
||||||
|
//const char* ssid = "SaucissonLand";
|
||||||
|
//const char* password = "47C619A574D41311C811EB563C";
|
||||||
|
const char* mqtt_server = "192.168.73.20";
|
||||||
|
const char* mqtt_topic = "vulture/buzzer/pressed/3";
|
||||||
|
const char* mqtt_message = "{\"buzzer_id\": 3, \"color\": \"#28D42E\"}";
|
||||||
|
//hostname wifi et client id mqtt
|
||||||
|
const char* esp_name = "BUZZER-3";
|
||||||
|
|
||||||
|
// Déclaration des broches
|
||||||
|
#define BUTTON_PIN D8
|
||||||
|
|
||||||
|
WiFiClient espClient;
|
||||||
|
PubSubClient client(espClient);
|
||||||
|
|
||||||
|
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) {
|
||||||
|
delay(500);
|
||||||
|
Serial.print(".");
|
||||||
|
}
|
||||||
|
|
||||||
|
Serial.println("");
|
||||||
|
Serial.println("WiFi connecté");
|
||||||
|
Serial.print("Adresse IP: ");
|
||||||
|
Serial.println(WiFi.localIP());
|
||||||
|
}
|
||||||
|
|
||||||
|
void reconnect() {
|
||||||
|
while (!client.connected()) {
|
||||||
|
Serial.print("Connexion au broker MQTT...");
|
||||||
|
if (client.connect(esp_name)) {
|
||||||
|
Serial.println("connecté");
|
||||||
|
} else {
|
||||||
|
Serial.print("échec, rc=");
|
||||||
|
Serial.print(client.state());
|
||||||
|
Serial.println("; nouvelle tentative dans 5 secondes");
|
||||||
|
delay(5000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Serial.begin(115200);
|
||||||
|
pinMode(BUTTON_PIN, INPUT_PULLUP);
|
||||||
|
|
||||||
|
setup_wifi();
|
||||||
|
client.setServer(mqtt_server, 1883);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
if (!client.connected()) {
|
||||||
|
reconnect();
|
||||||
|
}
|
||||||
|
client.loop();
|
||||||
|
|
||||||
|
// Vérifier si le bouton est pressé
|
||||||
|
if (digitalRead(BUTTON_PIN) == HIGH) {
|
||||||
|
Serial.println("Bouton pressé, envoi du message...");
|
||||||
|
client.publish(mqtt_topic, mqtt_message);
|
||||||
|
delay(200); // Anti-rebond pour éviter les publications multiples
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user