clignotante.ino

ESP8266 (ESP-12E module) · File : clignotante.ino · Language : Arduino · Use case : Faire clignoter la LED du module ESP-12E

The ESP-12E blue LED is active LOW — the classic first-sketch trap. millis() keeps the loop free for Wi-Fi, and the monitor prints free heap on every blink.

Hardware required

An ESP-12E module (ESP8266EX, 2.4 GHz Wi-Fi) mounted on a NodeMCU / Wemos D1 mini board, powered over micro-USB. None: the module user LED is enough.

Wiring

Nothing to wire (LED on GPIO2/D4). For an external LED: pin Dx through 330 Ω to GND, power over the board micro-USB.

How it works

digitalWrite inverts LOW/HIGH because the LED is wired active-low. The loop compares millis() with the last change, no blocking delay. In the Arduino IDE, install the « esp8266 » package, select « NodeMCU 1.0 (ESP-12E Module) » then Upload (hold GPIO0 LOW if flashing fails). The A0 ADC reads 0-1 V (NodeMCU divider: 0-3.3 V).

Going further

Modulate the period with an LDR on A0 (dedicated sketch), or blink faster when Wi-Fi drops.

clignotante.ino

// Clignotement non bloquant — LED bleue de l'ESP-12E (D4, active a LOW).
const unsigned long PERIODE = 500;

bool etat = false;
unsigned long precedent = 0;

void setup() {
  pinMode(BUILTIN_LED, OUTPUT);   // D4 = GPIO2
  Serial.begin(115200);
  Serial.println("\nClignotement demarre (LED inverse : ON = broche LOW)");
}

void loop() {
  unsigned long t = millis();
  if (t - precedent >= PERIODE) {
    precedent = t;
    etat = !etat;
    digitalWrite(BUILTIN_LED, etat ? LOW : HIGH);   // active a LOW !
    Serial.printf("%s — heap %u o, wifi %d dBm\n",
                  etat ? "ON " : "OFF", ESP.getFreeHeap(), WiFi.Rssi());
  }
}

← Back to the board