Blinky ESP8266

dev board WeMos D1 Mini
chip ESP8266

Before starting

Dependancies

Ensure the following requirements are available:

Buy the components

Description

LED_BUILTIN can be referred as the pin for the on-board LED. It has a reverse logic.

  • HIGH is LED off
  • LOW is LED on

Big Sur MacOSX update

Error on uploading:

pyserial or esptool directories not found next to this upload.py tool.
An error occurred while uploading the sketch

The solution is to edit the file ~/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.4/tools/pyserial/serial/tools/list_ports_osx.py L29-L30. Fix the relative paths for IOKit and CoreFoundation to absolute paths.

Code

Download code
void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, LOW);

  Serial.begin(115200);
  Serial.println("Start blinky");
}

void loop() {
  ledON();
  delay(1000);

  ledOFF();
  delay(1000);
}

void ledON() {
  Serial.println("LED ON");
  digitalWrite(LED_BUILTIN, LOW);
}

void ledOFF() {
  Serial.println("LED OFF");
  digitalWrite(LED_BUILTIN, HIGH);
}

Makefile

BOARD?=esp8266:esp8266:d1_mini
PORT?=/dev/cu.usbserial-14*
BUILD=build

.PHONY: default lint all flash clean

default: lint all flash clean

lint:
	cpplint --extensions=ino --filter=-legal/copyright *.ino

all:
	arduino-cli compile --fqbn $(BOARD) --output-dir $(BUILD) ./

flash:
	arduino-cli upload --fqbn $(BOARD) --port $(PORT) --input-dir $(BUILD)

clean:
	rm -r build

Serial console

Serial output from the firmware.

Blinky ESP8266 serial console

Prototype

A photo of the actual setup.

Blinky ESP8266 prototype

Watch