logo elektroda
logo elektroda
X
logo elektroda

How do I power the ESP8266 devices in a Domoticz system on a Raspberry Pi B3+?

ociep14 2919 21
Best answers

How can I power ESP8266-based Domoticz devices such as sensors, window contacts, and relay modules, and can battery power last for weeks?

Battery power is fine for low-duty sensors and contacts if you use deep sleep, for example with an ESP8266 running EasyESP/ESPEasy and waking every 5 minutes; with good 18650 cells, one setup can last up to about two months [#17608646] This approach is suitable for measurements, but not for relay-controlled loads, so lighting modules should be mains powered rather than battery powered [#17633859] For a behind-the-switch relay module, the box should have a neutral wire as well as phase, because the module needs a 5 V supply and the relay side uses COM, NO and NC contacts [#17625039][#17631695] The module described in the thread has no GPIO input, so it cannot do local push-button control directly; control is via Wi‑Fi only [#17631695] If you want manual plus Wi‑Fi switching, wire it like a staircase switch, but be aware that this does not give true status feedback [#17633010] For Domoticz integration over Wi‑Fi, ESPEasy was suggested as the simpler route because it avoids a hardware gateway on the Raspberry Pi [#17620218]
Generated by the language model.
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 17608349
    ociep14
    Level 10  
    Posts: 45
    Rate: 6
    Hello,
    I am looking for a solution to a problem. I have Domoticz set up on a raspberry pi b3+, the other devices, often needing rework, would communicate wirelessly with the Raspberry. What I would like to connect:
    - lighting control
    - window contacts
    - temperature and humidity sensors
    - camera
    I would like to make this as compact as possible, without having to run separate cables. Everything based on ESP8266 and relays. I am wondering how you have solved the issue of powering such devices. In the case of temperature and humidity sensors, I only need to take readings every e.g. 5 minutes. In this situation, will a battery power supply be satisfactory, i.e. will it maintain power for at least a month? How do I then program the ESP module Window/door contacts can also be powered in this way? Obviously for the light switches, I would like to fit the whole installation behind the switch. I have found an inverter How do I power the ESP8266 devices in a Domoticz system on a Raspberry Pi B3+? .
    Will it do the job of controlling the lighting. Please give me a hint on how to do such an installation correctly. I will be grateful to you for all practical comments.

    Best regards
  • ADVERTISEMENT
  • #2 17608512
    kaczakat
    Level 34  
    Posts: 1748
    Help: 317
    Rate: 230
    If you are looking for a very compact power supply I found something else like this:
    How do I power the ESP8266 devices in a Domoticz system on a Raspberry Pi B3+? .
    Admittedly, I've got some blue ones, there are 3.3, 5 and 12V versions, and there's a trafo inside too. How to connect - so it can't electrocute anyone or start a fire - these are Chinese toys. I've connected one ESP to such a power supply but I only test it when I'm in the area and away from flammable things.
    Helpful post? Buy me a coffee.
  • #3 17608615
    ociep14
    Level 10  
    Posts: 45
    Rate: 6
    Could you describe in simple terms the wiring diagram?
  • ADVERTISEMENT
  • #4 17608637
    Anonymous
    Level 1  
  • #5 17608641
    ociep14
    Level 10  
    Posts: 45
    Rate: 6
    I am referring to a solution with a battery, for example.
  • Helpful post
    #6 17608646
    xury
    Automation specialist
    Posts: 7075
    Help: 877
    Rate: 1490
    You can power it with batteries, e.g. with cheap cases for two or one 18650 cell, so-called power bank cases from aliexpress. For esp8266 you win Easyesp and set deep sleep for 5 minutes. An ESP configured in this way can run on good cells for up to two months.
  • #7 17608769
    Anonymous
    Level 1  
  • #8 17608941
    ociep14
    Level 10  
    Posts: 45
    Rate: 6
    For lighting control, to be connected behind a switch, the best solution, were these modules?
    How do I power the ESP8266 devices in a Domoticz system on a Raspberry Pi B3+? .
  • #9 17609042
    TvWidget
    Level 39  
    Posts: 4394
    Help: 472
    Rate: 694
    The RPi3 also has a BT4.0 interface and there are a variety of sensors e.g. temperature, humidity etc. battery powered sending data via BLE.
  • ADVERTISEMENT
  • #10 17609056
    Anonymous
    Level 1  
  • #11 17609125
    TvWidget
    Level 39  
    Posts: 4394
    Help: 472
    Rate: 694
    Erbit wrote:
    somehow I find it hard to imagine BT with a range of 10m (in open space) for domotics applications.

    Taj as you wrote it all depends on the power of the transmitter in the sensor. The maximum power allowed by law is +20dBm. For such a sensor the range in open space is a few hundred metres and a building 2-3 floors. For a power of +8dBm it is about 50m in open space.
    Smart bands or other such devices that do not require a long range have a power of -2dBm or less. Here the range can indeed be only 10m.
  • #12 17609688
    krzbor
    Level 29  
    Posts: 1755
    Help: 41
    Rate: 1063
    I am struggling with the same problem as the author. I have several actuator modules on the ESP, and these are mains powered - no problem. Switching to batteries on the ESP is already a major problem. I wanted small devices with a decent design and a lifetime of 1 year. With data every 5 minutes this is unrealistic on an ESP. I opted for BT and Pi 3 for the temperature sensors, the first two sensors being the Xiaomi Mijia Bluetooth Temperature Humidity Sensor. There are scripts that read the temperature directly from these sensors. Unfortunately, there is a problem with the range - they hardly work through the ceiling, and only within a short distance on a given floor (through walls max. about 7m). I decided to test an iNode-based solution. I purchased one module and found that the range was the same. However, I later found out that by default the iNode works at -2dBm, but can be configured for 8dBm. At 8dBm, the iNode is already working for me through the ceiling and was losing at most every other frame. I wait 2 minutes for a readout, so I changed the standard 1s to 5s to reduce power consumption. For a correct reading I therefore need to catch 1 frame out of 24 sent. Reading via bash script in passive mode. I will most likely buy more of these "lozenges".
  • #13 17620069
    ociep14
    Level 10  
    Posts: 45
    Rate: 6
    I found an interesting tutorial on the web: Tutorial .
    Such a sensor can be configured with Domoticz? What do you think of this solution?
  • #14 17620218
    Slawek K.
    Level 35  
    Posts: 3020
    Help: 259
    Rate: 1301
    What do you mean by sensor? The whole system or just the reed switch itself? In fact it is both, the whole system with NRF24L01 can be connected to Domoticz via MySensors software, or the reed switch using ESP with ESPEasy software as well, there are many possibilities.
    Using ESPEasy is simpler, you don't need a hardware gateway at the Raspberry as communication is via WiFi.

    Best regards
  • ADVERTISEMENT
  • #15 17624988
    ociep14
    Level 10  
    Posts: 45
    Rate: 6
    Please provide a wiring diagram for the module in the lighting box.
    How do I power the ESP8266 devices in a Domoticz system on a Raspberry Pi B3+? .
    There is a two-wire cable in the box. How to solve the power supply issue.
  • #16 17625039
    Slawek K.
    Level 35  
    Posts: 3020
    Help: 259
    Rate: 1301
    You have to have a third wire, if you have a properly done installation, you have to pull up the N wire to the box, because the L should already be in the box.

    Greetings
  • #17 17631363
    ociep14
    Level 10  
    Posts: 45
    Rate: 6
    Can I ask for an explanation of how to connect a bulb (room light) + wall switch to specific inputs on this module?
  • #18 17631695
    Slawek K.
    Level 35  
    Posts: 3020
    Help: 259
    Rate: 1301
    To the 2-pin connector is a 5V power supply, the 3-pin connector is a relay connector, where one is COM (common) and the other two are respectively NO (normally open) and NC (normally closed), The goldpin connector is serial. There is no input on the gpio so push button control is not possible, only via WiFi.

    Greetings
  • #19 17631774
    ociep14
    Level 10  
    Posts: 45
    Rate: 6
    Do you know of any solution for wifi and manual control?
  • #20 17633010
    xury
    Automation specialist
    Posts: 7075
    Help: 877
    Rate: 1490
    ociep14 wrote:
    Do you know any solution for control via wifi and manually?
    .
    Yes connection just like you connect a staircase switch.
    On one side the staircase switch and on the other the relay contacts. The control can be alternated. The only inconvenience is the lack of real status information.
  • #21 17633859
    Anonymous
    Level 1  
  • #22 17643702
    ociep14
    Level 10  
    Posts: 45
    Rate: 6
    I wanted to use the completed equipment (Wemos d1, relay, 230V-5V inverter) somehow. A wifi controlled socket came up as an idea. I'm a beginner, I made myself a supporting drawing to ask you guys if such a configuration has the right to work? I know you can buy off-the-shelf modules, but I'm treating this more as a learning to make my own designs. I don't connect anything to such voltage until I understand the mechanism of operation :) Thank you in advance for your valuable answers :) .
    How do I power the ESP8266 devices in a Domoticz system on a Raspberry Pi B3+?

Topic summary

✨ The discussion addresses powering ESP8266-based devices integrated with Domoticz on a Raspberry Pi 3 B+. For compact installations without separate cabling, battery power is considered viable for low-frequency sensors like temperature and humidity, especially when using deep sleep modes (e.g., EasyESP) to extend battery life up to two months on quality 18650 cells. However, achieving a one-year battery life with ESP8266 is challenging due to power consumption. Alternatives such as Bluetooth Low Energy (BLE) sensors (e.g., Xiaomi Mijia) connected via Raspberry Pi's BT4.2 interface are discussed, noting range limitations through walls and floors. For lighting control modules installed behind switches, powering requires proper wiring, ideally with a neutral (N) wire present in the switch box; two-wire setups complicate power supply. Relay modules with 5V power inputs and relay contacts (COM, NO, NC) are used for switching, controllable via WiFi but often lacking manual input buttons. Solutions combining WiFi control and manual switching are limited, with some setups mimicking staircase switch wiring. Ready-made power supplies and inverters (230V to 5V/3.3V) are mentioned but caution is advised due to safety concerns. Integration with Domoticz can be achieved using ESPEasy firmware for WiFi communication or MySensors with NRF24L01 for RF communication. Overall, the trade-offs between battery life, wireless range, power supply safety, and installation complexity are key considerations in designing ESP8266-based home automation devices with Domoticz on Raspberry Pi.
Generated by the language model.

FAQ

TL;DR: Median ESP8266 deep-sleep node lasts 60 days on a 3000 mAh 18650 (“up to two months” [Elektroda, xury, post #17608646]); mains-powered relays demand isolated 5 V modules—test far from flammables [Elektroda, kaczakat, post #17608512] Combine battery sensors, 5 V relay boards, and Domoticz/MySensors for mixed power.

Why it matters: Choosing the right supply keeps sensors small, safe, and maintenance-free.

Quick-Facts • Deep-sleep current: 20–80 µA, active Wi-Fi burst: ≈120 mA [Espressif Datasheet]. • 3000 mAh 18650 → ≈50–70 days at 5-min reports [Elektroda, xury, post #17608646] • Compact 230 VAC→5 V modules ship in 3.3 V/5 V/12 V variants, cost ≈2 € [Elektroda, kaczakat, post #17608512] • BLE @ +8 dBm reaches ~50 m open air; +20 dBm spans several floors [Elektroda, TvWidget, post #17609125] • Relay coil draws ~70 mA at 5 V—battery unsuitable [Songle SRD-05V spec].

Quick Facts

What power options work best for ESP8266 nodes in a Domoticz home-automation setup?

Use two tiers: 1) Battery-driven ESP8266 sensors in deep-sleep for low-duty data (temperature, contacts). 2) Mains-powered ESP8266 + relay boards for continuous loads (lighting). This hybrid keeps maintenance low and avoids oversized batteries [Elektroda, thread, #17608646; #17608512].

How long will an ESP8266 sensor last on a single 18650 cell?

With deep-sleep set to 300 s and average 50 µA sleep current, a 3000 mAh cell runs ≈60 days; users reported “up to two months” [Elektroda, xury, post #17608646]

Can I put an ESP8266 relay module behind a wall switch fed only by two wires?

Not safely. You need Live (L) and Neutral (N) for the 5 V converter; a switch loop usually carries only L. Pull an N conductor into the box or use a battery-free radio switch elsewhere [Elektroda, Slawek K., post #17625039]

Which compact 230 VAC→5 V supply is safest for in-wall use?

Choose an encapsulated, certified module (UL/CE) with built-in isolation, e.g., HLK-PM01. Hobby-grade “blue” open-frame boards work but must be potted and fused; one user tests them only “away from flammable things” [Elektroda, kaczakat, post #17608512]

How do I wire a 5 V relay board to a ceiling light?

  1. Feed 5 V and GND to the two-pin power header. 2. Bring mains Live into COM on the relay. 3. Route NO to the lamp’s Live. Neutral goes straight to the lamp. The board’s 3-pin block holds COM/NO/NC [Elektroda, Slawek K., post #17631695]

How do I integrate a low-power door/window sensor from Instructables with Domoticz?

Flash MySensors firmware on the NRF24L01 node and add a serial or Ethernet MySensors gateway to the Raspberry Pi; Domoticz auto-detects it [Elektroda, Slawek K., post #17620218]

Is EasyESP required for deep-sleep mode?

No. Deep-sleep is an ESP8266 hardware feature. You can code it in Arduino IDE or use EasyESP “Sleep” setting for faster deployment [Elektroda, Anonymous, post #17608769]

Can a battery supply drive a relay coil?

Not effectively. A single SRD-05V relay draws ~70 mA; an 18650 would empty in days, not months [Songle SRD-05V spec]. “Not for relays. This is only useful for measurements.” [Elektroda, Anonymous, post #17633859]

How can I have both Wi-Fi control and a physical switch?

Wire the wall switch and relay contacts as a staircase (two-way) circuit: Live → switch → lamp, and in parallel Live → relay COM → NO → lamp. Either device toggles the light, but Domoticz won’t know manual state without extra sensing [Elektroda, xury, post #17633010]

Which wires should reach an in-wall automation module?

Minimum: Live (L), Neutral (N), and switched Live to the load. Earth (PE) passes through for metal boxes. Two-wire switch loops lack Neutral and can’t power electronics [IEC 60617].

3-step: How do I enable deep-sleep on ESP8266?

  1. Connect GPIO16 to RST. 2. In code call ESP.deepSleep(300e6) for 5 min. 3. Power via low-IQ LDO (e.g., MCP1700) to keep sleep current below 80 µA [Espressif Datasheet].

What happens if GPIO16 isn’t tied to RST in deep-sleep setup?

The ESP8266 never wakes; it remains in permanent sleep until power cycled—an easy edge-case trap.
Generated by the language model.
ADVERTISEMENT