This small but powerful board features the ESP8266 SoC and is perfect for WiFi-connected sensor nodes, relay controllers, and Home Assistant integrations. It’s compatible with the Arduino IDE, PlatformIO, and ESPHome for easy integration into your projects.
Perfect for WiFi IoT sensors & controllers. This listing includes wiring & example code for connecting a BME280 (I²C temperature/humidity/pressure sensor) and a 4-channel 5V relay module.
ESP8266 D1 Mini Wemos — WiFi Dev Board — BME280 & Relay Example / IoT
| Brand | Wemos / Generic |
|---|---|
| Model | D1 Mini (ESP8266) |
| WiFi | 802.11 b/g/n (ESP8266) |
| Flash | 4MB (typical) |
| Operating Voltage | 3.3 V |
| Interface | USB (micro), GPIO, I²C, SPI |
| Condition | New |
| Compatible With | Arduino IDE, PlatformIO, ESPHome |
Below are two diagrams: (A) D1 Mini wiring to the BME280 (I²C), and (B) D1 Mini wiring to a 4-channel relay module. Use the wiring notes after the diagrams.
// Requirements: // - Install Adafruit BME280 library (Adafruit BME280 Library) and Adafruit Sensor // - Wire BME280 to I2C (SDA->D2 GPIO4, SCL->D1 GPIO5) // - Relays to D5 (GPIO14), D6 (GPIO12) etc. (active LOW typical) #include#include #include #define BME_SDA D2 // GPIO4 #define BME_SCL D1 // GPIO5 Adafruit_BME280 bme; // I2C const int RELAY1 = D5; // GPIO14 const int RELAY2 = D6; // GPIO12 void setup() { Serial.begin(115200); Wire.begin(BME_SDA, BME_SCL); if (!bme.begin(0x76)) { // try 0x76 then 0x77 depending on breakout Serial.println("Could not find a valid BME280 sensor, check wiring!"); while (1) delay(10); } pinMode(RELAY1, OUTPUT); pinMode(RELAY2, OUTPUT); // Many relay modules are ACTIVE LOW: HIGH = off, LOW = on digitalWrite(RELAY1, HIGH); digitalWrite(RELAY2, HIGH); } void loop() { float t = bme.readTemperature(); // °C float h = bme.readHumidity(); // % float p = bme.readPressure() / 100.0F; // hPa Serial.printf("T: %.2f °C H: %.2f %% P: %.2f hPa\n", t, h, p); // Example: turn relay on if temperature above threshold if (t > 28.0) { digitalWrite(RELAY1, LOW); // turn ON } else { digitalWrite(RELAY1, HIGH); // turn OFF } // Example toggling relay2 every 10s for demo digitalWrite(RELAY2, LOW); delay(200); digitalWrite(RELAY2, HIGH); delay(9800); delay(2000); }
esphome:
name: d1mini_bme_relay
platform: ESP8266
board: d1_mini
wifi:
ssid: "YOUR_SSID"
password: "YOUR_PASSWORD"
# Enable logging and OTA
logger:
ota:
api:
i2c:
sda: D2 # GPIO4
scl: D1 # GPIO5
scan: true
sensor:
- platform: bme280
temperature:
name: "BME280 Temperature"
pressure:
name: "BME280 Pressure"
humidity:
name: "BME280 Humidity"
address: 0x76
# Relays: many relay modules are ACTIVE LOW -> use inverted outputs
output:
- platform: gpio
pin: D5
id: relay1_out
inverted: true
- platform: gpio
pin: D6
id: relay2_out
inverted: true
switch:
- platform: output
name: "Relay 1"
output: relay1_out
- platform: output
name: "Relay 2"
output: relay2_out
# Optional automation: turn on Relay1 if temperature > 28C
automation:
- alias: "Turn on Relay1 on high temp"
trigger:
- platform: numeric_state
entity_id: sensor.bme280_temperature
above: 28.0
action:
- switch.turn_on: relay1
- delay: 10s
- switch.turn_off: relay1
# Ensure relays off on boot
on_boot:
then:
- switch.turn_off: relay1
- switch.turn_off: relay2