how controll relay with esp8266?

Everything about esp8266 and more.

Moderator: leecollings

reza
Posts: 112
Joined: Tuesday 13 September 2016 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Contact:

how controll relay with esp8266?

Post by reza »

hi friend
i want controll relay with nodemcu. can you help me how i can do it ?
User avatar
heggink
Posts: 972
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 12451
Location: NL
Contact:

Re: how controll relay with esp8266?

Post by heggink »

Espeasy also ok?
Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
reza
Posts: 112
Joined: Tuesday 13 September 2016 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Contact:

Re: how controll relay with esp8266?

Post by reza »

heggink wrote:Espeasy also ok?
can i use espeasy for relay control (in stable version) ? i dont know . if yes , please help me for relay control with espeasy.

i think espeasy (nodemcu) pinouts is 3.3v . so can i use this pins for control 5v relay modules?
zak45
Posts: 952
Joined: Sunday 22 January 2017 11:37
Target OS: Windows
Domoticz version: V2024.4
Contact:

Re: how controll relay with esp8266?

Post by zak45 »

they are plenty example in web...
https://www.letscontrolit.com/wiki/index.php/Relais
User avatar
heggink
Posts: 972
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 12451
Location: NL
Contact:

Re: how controll relay with esp8266?

Post by heggink »

I have 3 different relays from Aliexpress and all behave differently. 1 likes 5v, one is listed as 5v but only works with 3.3 and one is 3.3 but only uses an inverted signal (which was not stated on the site) so ymmv. I managed to get all to work on one of those nodemcu things, powered via micro usb and flashed with Espeasy. Even the inverted one. Most accept a 3.3 signal but some need 5v power.
Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
User avatar
heggink
Posts: 972
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 12451
Location: NL
Contact:

Re: how controll relay with esp8266?

Post by heggink »

Btw, there are plenty of esp/relay units integrated. And quite cheap.
Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: how controll relay with esp8266?

Post by Derik »

buy a linknode in China..
Flash ESPeasy..
And you have a great board!!
When you build it self cost more, and not working so wel as a linknode!!
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
reza
Posts: 112
Joined: Tuesday 13 September 2016 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Contact:

Re: how controll relay with esp8266?

Post by reza »

zak45 wrote:they are plenty example in web...
https://www.letscontrolit.com/wiki/index.php/Relais
thank you dear zak.i didn't see this page before. i read and build. i connect a 8channel relay module to nodemcu.this is interesting. thank you. but there is a problem . when i send command for on all relay , suddenly after 3 or 4 relay (turn on) so nodemcu reset and stop working. for a 2channel relay dont any problem. but for 8channel....
i think nodemcu can not support Amp for 8 pinouts for turn on .
also i have same problem with mysensors node. and i see that problem is related to WDT in arduino . after remove WDT problem solved , but in nodemcu dont use WDT .
reza
Posts: 112
Joined: Tuesday 13 September 2016 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Contact:

Re: how controll relay with esp8266?

Post by reza »

heggink wrote:I have 3 different relays from Aliexpress and all behave differently. 1 likes 5v, one is listed as 5v but only works with 3.3 and one is 3.3 but only uses an inverted signal (which was not stated on the site) so ymmv. I managed to get all to work on one of those nodemcu things, powered via micro usb and flashed with Espeasy. Even the inverted one. Most accept a 3.3 signal but some need 5v power.
thank you for help my friend
reza
Posts: 112
Joined: Tuesday 13 September 2016 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Contact:

Re: how controll relay with esp8266?

Post by reza »

Derik wrote:buy a linknode in China..
Flash ESPeasy..
And you have a great board!!
When you build it self cost more, and not working so wel as a linknode!!
thank you, this is good idea but i like build :)
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: how controll relay with esp8266?

Post by Derik »

reza wrote:
zak45 wrote:they are plenty example in web...
https://www.letscontrolit.com/wiki/index.php/Relais
thank you dear zak.i didn't see this page before. i read and build. i connect a 8channel relay module to nodemcu.this is interesting. thank you. but there is a problem . when i send command for on all relay , suddenly after 3 or 4 relay (turn on) so nodemcu reset and stop working. for a 2channel relay dont any problem. but for 8channel....
i think nodemcu can not support Amp for 8 pinouts for turn on .
also i have same problem with mysensors node. and i see that problem is related to WDT in arduino . after remove WDT problem solved , but in nodemcu dont use WDT .

I think you have the check the pinout ...
There are pins u cannot use, for a relay
Perhaps you can set in the hardware of espeasy the hardware pins to a other gpio, so you can switch 9 channels.
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
reza
Posts: 112
Joined: Tuesday 13 September 2016 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Contact:

Re: how controll relay with esp8266?

Post by reza »

Derik wrote:
reza wrote:
zak45 wrote:they are plenty example in web...
https://www.letscontrolit.com/wiki/index.php/Relais
thank you dear zak.i didn't see this page before. i read and build. i connect a 8channel relay module to nodemcu.this is interesting. thank you. but there is a problem . when i send command for on all relay , suddenly after 3 or 4 relay (turn on) so nodemcu reset and stop working. for a 2channel relay dont any problem. but for 8channel....
i think nodemcu can not support Amp for 8 pinouts for turn on .
also i have same problem with mysensors node. and i see that problem is related to WDT in arduino . after remove WDT problem solved , but in nodemcu dont use WDT .

I think you have the check the pinout ...
There are pins u cannot use, for a relay
Perhaps you can set in the hardware of espeasy the hardware pins to a other gpio, so you can switch 9 channels.
thank you dear derik . which pins can i use for relay ? i use and test GPIO 0,2,4,5,9,10,12,13,14,15,16 . some time and when i test slow this is ok , but when i send quick command so nodemcu reset and stop.
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: how controll relay with esp8266?

Post by Derik »

@ reza:

Very complex..
Some pins u cannot use for switching, but you can use them for temp sensors:
Image

So you can see that some pins are not to use for the switches.


Quick command?
I need to see more settings..
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
reza
Posts: 112
Joined: Tuesday 13 September 2016 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Contact:

Re: how controll relay with esp8266?

Post by reza »

Derik wrote:@ reza:

Very complex..
Some pins u cannot use for switching, but you can use them for temp sensors:
Image

So you can see that some pins are not to use for the switches.


Quick command?
I need to see more settings..
your image can not open for me , please give me a link of your pic.
send quick command means i turn on relay fast with domoticz(touch on relay1 , on relay2 , on relay3 , on relay4 .... quick . so nodemcu reset.)
i want use nodemcu for just 8channel relay control without convertor.are there 8 pin on nodemcu for relay ?(sorry for my english friend)
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: how controll relay with esp8266?

Post by Derik »

https://pradeepsinghblog.files.wordpres ... .png?w=616
Or rightclick the image and copy paste url..


That is what i say 8 pins to use is hard to get and trial and error
Some puns are needed by the esp for booting.
When you power the pin, the esp is not booting or reboot loop.

You need te switch the gpio on the bord with a dummy:
And there you place like:
ScreenShot025.jpg
ScreenShot025.jpg (139.96 KiB) Viewed 18506 times
For every pin u try to switch...
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
reza
Posts: 112
Joined: Tuesday 13 September 2016 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Contact:

Re: how controll relay with esp8266?

Post by reza »

Derik wrote:https://pradeepsinghblog.files.wordpres ... .png?w=616
Or rightclick the image and copy paste url..


That is what i say 8 pins to use is hard to get and trial and error
Some puns are needed by the esp for booting.
When you power the pin, the esp is not booting or reboot loop.

You need te switch the gpio on the bord with a dummy:
And there you place like:
ScreenShot025.jpg
For every pin u try to switch...
you are right. i test one by one . i see D4 and D8 and GPIO 9 and GPIO10 i can not use for relay. i use other pins and this is true apparently.

but just 2 questions.
nodemcu have feedback ? means if relay cannot turn on so in domoticz i see error and relay can not turn on?
and can i use 2 command for a device? for example a dummy in domoticz, in "on action" can use 2 command : http://192.168.1.120/control?cmd=GPIO,13,1 ; http://192.168.1.120/control?cmd=GPIO,5,1 ?
reza
Posts: 112
Joined: Tuesday 13 September 2016 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Contact:

Re: how controll relay with esp8266?

Post by reza »

Derik wrote:https://pradeepsinghblog.files.wordpres ... .png?w=616
Or rightclick the image and copy paste url..


That is what i say 8 pins to use is hard to get and trial and error
Some puns are needed by the esp for booting.
When you power the pin, the esp is not booting or reboot loop.

You need te switch the gpio on the bord with a dummy:
And there you place like:
ScreenShot025.jpg
For every pin u try to switch...
i have some error with mysensors and nrf radio. can i replace espeasy with mysensors? is not there any problem and bug with espeasy ? also can i use repeater in espeasy ?
randytsuch
Posts: 90
Joined: Sunday 20 March 2016 18:56
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: LA, Ca USA
Contact:

Re: how controll relay with esp8266?

Post by randytsuch »

I would add a fairly large (greater than 1000 uf) capacitor on the relay module power line to ground.

If it works slowly, but not quickly, sounds like your power supply is having trouble keeping up, and a cap would help. But you might need a bigger power supply, and maybe better wiring for the relay module.

Also, wire relay module power directly to the power supply, don't wire it through the ESP card.

I now have a couple Wemos mini ESP cards running ESP Easy, seem to be working fine.

With the ESP cards, I don't think you need mysensors and the nrf radio, they would replace those. ESP use wifi for the wireless communication.
I have one ESP outside, and am using the Wemos mini d1 pro because it has an external antenna connection. But the internal antenna is working fine. But I would get the pro for any locations where you are worried about the wifi signal.

Randy
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: how controll relay with esp8266?

Post by Derik »

Lisa wrote:Just order this one, then you're all set: https://nl.aliexpress.com/item/Sonoff-S ... 22442.html
Here's the instruction to flash it with ESPEasy: https://www.rutg3r.nl/sonoff/
And the hookup to domoticz: https://www.domoticz.com/forum/viewtopic.php?t=15171

That is for 1 esp... try this very good stuff

After that buy the linknode :lol: :D :D
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
reza
Posts: 112
Joined: Tuesday 13 September 2016 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Contact:

Re: how controll relay with esp8266?

Post by reza »

randytsuch wrote:I would add a fairly large (greater than 1000 uf) capacitor on the relay module power line to ground.

If it works slowly, but not quickly, sounds like your power supply is having trouble keeping up, and a cap would help. But you might need a bigger power supply, and maybe better wiring for the relay module.

Also, wire relay module power directly to the power supply, don't wire it through the ESP card.

I now have a couple Wemos mini ESP cards running ESP Easy, seem to be working fine.

With the ESP cards, I don't think you need mysensors and the nrf radio, they would replace those. ESP use wifi for the wireless communication.
I have one ESP outside, and am using the Wemos mini d1 pro because it has an external antenna connection. But the internal antenna is working fine. But I would get the pro for any locations where you are worried about the wifi signal.

Randy
thank you friends for help me . but if you can , please help me to found my questions.
i can not buy from ebay and aliexpress and etc for some reason. so i have to build my nodes and devices.
until now i use mysensors for some relay and sensors. but mysensors have some problem for me and i can not resolve . for example in communication. sometime devices dont work and connection was lost and i have to reset devices or gateway. now there is not this problem with esp ? when a esp device connect to network so there is not "connect and disconnect" some time ? when network is busy and use more devices so there is collision and lost packet ? if a packet was lost , for example send command for turn on relay A and command is lost , what happen ? there is a feedback and ack until i understand relay could not turn on ?
for repeater and extend can i use "usual wifi repeater" that i use in wifi network for extend ?
for a star network (espeasy is star ?!) we have more collision!? is that true ?
also about espeasy, we can not change code and sketch. for example i want use two relay in one node for a simple roller shutter. this simple code:

Code: Select all

message.type == V_UP
        digitalWrite(message.sensor + 2, HIGH);
        delay(500);
        digitalWrite(message.sensor + 3, LOW);
message.type == V_STOP
        digitalWrite(message.sensor + 2, HIGH);
        delay(500);
        digitalWrite(message.sensor + 3, HIGH);
message.type == V_DOWN
        digitalWrite(message.sensor + 3, HIGH);
        delay(500);
        digitalWrite(message.sensor + 2, LOW);
also espeasy can not support some module for example MQ2 module and etc...
but in end of this page (https://www.domoticz.com/wiki/ESP8266_WiFi_module) i see we can programming for node with esp.but i test this and dont work , i dont know how change this code for connect to network. also i dont know how control relay with this code!?
sorry for long text but please help me .

in the end , are you think esp is better than mysensors and with esp my problem solve for always ? i am tired for mysensors and bad connection...
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest