logo elektroda
logo elektroda
X
logo elektroda

ESP8266 and Tasmota - controlling the WiFi relay step by step

p.kaczmarek2 25872 37

TL;DR

  • Builds a Sonoff-style WiFi relay using ESP8266-01, a 5V supply, a 5V relay, and Tasmota firmware for local Internet or LAN control.
  • Programs the ESP8266 with esptool.py, flashes tasmota.bin, then configures WiFi, module pins, and relay control through Tasmota’s web interface.
  • Measured consumption reached 140mA at 5V with the relay on and 70mA with it off, varying with WiFi traffic.
  • Controls the relay from the Tasmota Control phone app over HTTP without MQTT or a cloud broker, using the device’s IP or hostname.
  • DHCP can change the device’s IP, so a static address is recommended; the circuit also contains dangerous mains voltages and needs a proper enclosure.
Generated by the language model.
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
📢 Listen (AI):
  • #31 21923174
    inot
    Level 38  
    Posts: 3558
    Help: 439
    Rate: 799
    How do the LEDs on the USB converter react when an attempt is made to transmit data or when power is supplied to the ESP module?
  • ADVERTISEMENT
  • #32 21923381
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14612
    Help: 655
    Rate: 12630
    What is the error shown by esptool?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #33 21923490
    Blisk
    Level 7  
    Posts: 33
    >>21923174 When I connect it with no 3.3V red light is on and middle blue, when I connect 3.3V than middle blue is off and third blue is blinking and than I get error no connection

    Added after 44 [seconds]:

    >>21923381 error is connection time out
  • ADVERTISEMENT
  • #34 21923547
    inot
    Level 38  
    Posts: 3558
    Help: 439
    Rate: 799
    >>21923381
    I meant the LEDs on the USB adapter (marked with a circle).
    Red USB-to-TTL module with USB-A plug and header pins labeled RXD, TXD, GND, +5V
  • ADVERTISEMENT
  • #35 21923580
    Blisk
    Level 7  
    Posts: 33
    >>21923547 I meant that too, one red and 2 blue.
    when I disconnect 3.3v middle blue is light when I connect 3.3V middle blue is gone and last blue is blinking. after that I get connection time out.
  • #36 21924364
    inot
    Level 38  
    Posts: 3558
    Help: 439
    Rate: 799
    >>21923547 It follows from this that the ESP8266 is not transmitting any information. If possible, it would be worth measuring the signals using an oscilloscope.
  • #37 21924367
    Blisk
    Level 7  
    Posts: 33
    >>21924364 you mean TX and RX? I will meassure that
  • #38 21924371
    inot
    Level 38  
    Posts: 3558
    Help: 439
    Rate: 799
    Blisk wrote:
    you mean TX and RX?

    Yes.
📢 Listen (AI):

Topic summary

✨ The discussion focuses on building a DIY IoT WiFi controller using the ESP8266 module and Tasmota firmware, allowing users to control devices over the Internet. The project is aimed at less experienced users, providing a step-by-step guide to assembling the controller with a relay and power supply. Key topics include the use of DNS names for device identification, the importance of unique MAC addresses for IoT devices, and methods for remote control, such as port forwarding and using MQTT with Node-RED. The conversation also touches on the flexibility of Tasmota and the potential for future projects involving Tuya-based devices.
Generated by the language model.

FAQ

TL;DR: A single-relay ESP8266 with Tasmota draws only 0.7 W at 5 V (“almost like a Sonoff”)[Elektroda, p.kaczmarek2, post #19130883] "Sonoff is not a magic black box"[Elektroda, p.kaczmarek2, post #19132603] Set static IP or hostname, then control via HTTP or MQTT—no cloud needed.

Why it matters: DIY Wi-Fi switching costs little, keeps data local and scales with open-source firmware.

Quick Facts

• ESP8266-01 must run at 3.3 V; 5 V will destroy it[Elektroda, p.kaczmarek2, post #19130883] • Relay SRD-05VDC-SL-C coil voltage: 5 V[Elektroda, p.kaczmarek2, post #19130883] • Total current: 140 mA (0.7 W) relay on; 70 mA (0.35 W) off[Elektroda, p.kaczmarek2, post #19130883] • Tasmota config AP appears as “tasmota_xxxx”; browse 192.168.4.1 after flash[Elektroda, p.kaczmarek2, post #19130883] • Static address via console: IPAddress 192.168.x.y, or rely on hostname[Elektroda, khoam, post #19131175]

What parts do I need for a basic Wi-Fi relay?

You need an ESP8266-01 module, 5 V 500 mA flyback PSU, 3.3 V LDO, SRD-05VDC-SL-C relay, NPN transistor (BC547 or 2N7002), flyback diode, button, capacitors and resistors[Elektroda, p.kaczmarek2, post #19130883] Total hardware fits on a small perf-board and costs under €5 in retail parts.

How do I flash Tasmota onto the ESP8266-01?

  1. Connect USB-UART (3.3 V logic) to TX/RX.
  2. Tie GPIO0 to GND, then power the board.
  3. Run “esptool.py write_flash 0x0 tasmota.bin”.
  4. Remove GPIO0 from GND and reset.[Elektroda, p.kaczmarek2, post #19130883] Flash time is about 8 s over 921 600 baud.

Why do I need a 3.3 V regulator when I already have 5 V?

The ESP8266 core tolerates max 3.6 V. Supplying 5 V permanently damages the RF front-end—an irreversible failure edge-case[Elektroda, p.kaczmarek2, post #19130883] Use an LDO such as MCP1702 to drop 5 V to 3.3 V.

How do I map the relay and button inside Tasmota?

Open 192.168.x.x → Configuration → Configure Module. Assign GPIO0 or GPIO2 as “Relay1”, and another pin as “Button1”. Save and reboot; a toggle button appears on the web UI[Elektroda, p.kaczmarek2, post #19130883]

Can I control the relay from my phone without MQTT?

Yes. Apps such as Tasmota Control send plain HTTP commands (e.g., /cm?cmnd=Power%%20TOGGLE). They poll status every few seconds, so no broker is required[Elektroda, p.kaczmarek2, post #19130883]

Is internet-wide access possible?

Local control is default. For global reach, forward port 80, run a VPN, or expose an MQTT broker then use Node-RED dashboards[Elektroda, xury, post #19133954]

What power does the circuit consume?

With Wi-Fi active and relay on, draw peaks at 140 mA (0.7 W). Relay off sinks about 70 mA (0.35 W)[Elektroda, p.kaczmarek2, post #19130883] Idle Wi-Fi sleep can drop current to 20 mA, extending PSU headroom.

What happens if I leave GPIO0 grounded after flashing?

The ESP stays in bootloader mode and never runs Tasmota, appearing “dead” on Wi-Fi. Lift GPIO0, reset, and it boots normally[Elektroda, p.kaczmarek2, post #19130883]

How do I reserve an IP via DHCP?

Locate the ESP MAC in the router’s client list, then add a DHCP reservation linking that MAC to your chosen IP[Elektroda, p.kaczmarek2, post #19133249] Most SOHO routers expose this under LAN → DHCP Settings.

Can I change the ESP8266 MAC address?

Yes, call wifi_set_macaddr() in the Arduino Core. "Useful when cloning devices for testing"[Elektroda, khoam, post #19133412] Remember to keep it unique to avoid network conflicts.

How can I scale to multiple inputs and outputs?

Add I²C GPIO expanders (e.g., PCF8574) and map their pins in Tasmota’s Configure Template menu. Eight devices give 64 lines without firmware changes. Control remains through the same HTTP or MQTT endpoints.“}]}
Generated by the language model.
ADVERTISEMENT