// 04 · un capteur en Bluetooth (ESP32) : xerbot › ⌁ trouver › ◈ Bluetooth (Chrome / Edge, aussi sur Android). L'USB marche en même temps. #include #include Xerbot xb("cube-ble", "capteur"); void commande(Xerbot& x, const XerbotCommande& c) { if (strcmp(c.cmd, "led") == 0) { digitalWrite(LED_BUILTIN, c.booleen("on") ? HIGH : LOW); x.ack(c.id, true); } else x.ack(c.id, false, "commande inconnue"); } void setup() { Serial.begin(115200); pinMode(LED_BUILTIN, OUTPUT); xb.begin(Serial); xb.onCommande(commande); xerbotBLE(xb, "cube-ble"); } void loop() { xb.loop(); static unsigned long t = 0; if (millis() - t > 2000) { t = millis(); xb.telemetrie().add("t_puce", (double)temperatureRead(), 1).envoyer(); } }