Sonoff 4CH R3 GPIO
Moderators: grovkillen, Stuntteam, TD-er
-
- Normal user
- Posts: 45
- Joined: 17 Jan 2018, 18:43
Sonoff 4CH R3 GPIO
I have bought a couple of Sonoff 4CH R3 switches.
I have flashed ESPEasy and now I want to make it suitable for mij Domoticz system.
Google tells me the folowing GPIO declarations:
Button 1 = GPIO 0
Button 2 = GPIO 9
Button 3 = GPIO 10
Button 4 = GPIO 14
Relay 1 = GPIO 12
Relay 2 = GPIO 5
Relay 3 = GPIO 4
Relay 4 = GPIO 15
In ESPEasy I get by devices the folowing GPIO possibilities:
That is totally different then what Sonoff wants
How can I use this Sonoff 4 channel relay box with ESPEasy?
I have flashed ESPEasy and now I want to make it suitable for mij Domoticz system.
Google tells me the folowing GPIO declarations:
Button 1 = GPIO 0
Button 2 = GPIO 9
Button 3 = GPIO 10
Button 4 = GPIO 14
Relay 1 = GPIO 12
Relay 2 = GPIO 5
Relay 3 = GPIO 4
Relay 4 = GPIO 15
In ESPEasy I get by devices the folowing GPIO possibilities:
That is totally different then what Sonoff wants
How can I use this Sonoff 4 channel relay box with ESPEasy?
Re: Sonoff 4CH R3 GPIO
Disable I2C by setting the GPIOs to "none".
After that you can choose the missing GPIOs
After that you can choose the missing GPIOs
Re: Sonoff 4CH R3 GPIO
The greyed out options are now set to some other feature, like I2C.
On the Hardware tab, you can set the SDA/SCL pins for I2C to "not set" and then they are available to select in your select options.
The same for the "ESPEasy console" on the Tools->Advanced page.
If you uncheck that option, you can pick GPIO 1 and 3.
On the Hardware tab, you can set the SDA/SCL pins for I2C to "not set" and then they are available to select in your select options.
The same for the "ESPEasy console" on the Tools->Advanced page.
If you uncheck that option, you can pick GPIO 1 and 3.
-
- Normal user
- Posts: 45
- Joined: 17 Jan 2018, 18:43
Re: Sonoff 4CH R3 GPIO
Thanks for the very very fast respons.
The relays are working.
Super, super, super.
One 'but' left.
I also want to use the buttons of the Sonoff.
Button 1 = GPIO 0
Button 2 = GPIO 9
Button 3 = GPIO 10
Button 4 = GPIO 14
Button 1, 3,and 4 are directed to the proper GPIO's
Button 2 wants to be directed to GPIO 9 and GPIO 9 is not in the list of ESPEasy.
How can I use button 2?
The relays are working.
Super, super, super.
One 'but' left.
I also want to use the buttons of the Sonoff.
Button 1 = GPIO 0
Button 2 = GPIO 9
Button 3 = GPIO 10
Button 4 = GPIO 14
Button 1, 3,and 4 are directed to the proper GPIO's
Button 2 wants to be directed to GPIO 9 and GPIO 9 is not in the list of ESPEasy.
How can I use button 2?
Re: Sonoff 4CH R3 GPIO
You can add several switch input tasks.
Each with their own set GPIO and name the tasks with their own unique task name. (e.g. "Button1" ... "Button4")
Then in the rules you can simply act on the events when a button is pressed.
Example rule to couple "button1" to GPIO-12:
Just make sure to set the Switch task to "Push Button Active Low" and set the debounce to something like 100 msec.
Each with their own set GPIO and name the tasks with their own unique task name. (e.g. "Button1" ... "Button4")
Then in the rules you can simply act on the events when a button is pressed.
Example rule to couple "button1" to GPIO-12:
Code: Select all
on Button1#switch do
gpio,12,%eventvalue1%
endon
Re: Sonoff 4CH R3 GPIO
As GPIO is missing from the list, you can set up a monitor for that pin:
To start the monitor without a reboot, you can type that "monitor,gpio,9" command (it's not case-sensitive) on the Tools page to activate it immediately.
Code: Select all
on System#Boot do
monitor,GPIO,9
endon
on GPIO#9 do
// Act for Button 2, %eventvalue1% is holding the state 0/1
endon
/Ton (PayPal.me)
Re: Sonoff 4CH R3 GPIO
What build of ESPEasy do you have installed? (name of the .bin file please) as most likely the ESP on board is an ESP8285, that should have GPIO 9 available for use, but only a somewhat recent build (max 1 year old) has the auto-detect feature for ESP8266 vs ESP8285, enabling the few extra pins. You can see the detected ESP on the System Info page.
/Ton (PayPal.me)
Re: Sonoff 4CH R3 GPIO
And also the actual size of the flash memory.
There should exist some ESP8285 with 2MB flash and according to some model nr I found in the documentation there might even exist a 4M version of the ESP8285.
If you happen to have one with 2MB or more flash memory, then you could also use a build for 2M flash which makes updating to a newer build a lot simpler.
There should exist some ESP8285 with 2MB flash and according to some model nr I found in the documentation there might even exist a 4M version of the ESP8285.
If you happen to have one with 2MB or more flash memory, then you could also use a build for 2M flash which makes updating to a newer build a lot simpler.
Re: Sonoff 4CH R3 GPIO
TD-er has deployed a new build on https://td-er.nl/ESPEasy/latest/ that has a fix to allow selection of GPIO 9 on an ESP8285 unit like this Sonoff 4CH R3 seems to be.
You can install and test that when using Chrome or Edge browsers and the unit is connected to your USB Serial connection ( !!! DON'T connect the unit to mains power when also connecting to USB Serial !!! )
Feedback is welcome
You can install and test that when using Chrome or Edge browsers and the unit is connected to your USB Serial connection ( !!! DON'T connect the unit to mains power when also connecting to USB Serial !!! )
Feedback is welcome

/Ton (PayPal.me)
-
- Normal user
- Posts: 45
- Joined: 17 Jan 2018, 18:43
Re: Sonoff 4CH R3 GPIO
I am out for a few days.
After the weekend I wil try the rules thing and the TD binarie.
After the weekend I wil try the rules thing and the TD binarie.
-
- Normal user
- Posts: 45
- Joined: 17 Jan 2018, 18:43
Re: Sonoff 4CH R3 GPIO
I had a few minutes extra so I flashed with th TD binarie:
ESP_Easy_mega_20231107_normal_ESP8266_1M
And it works, super.
The only small disadvantage is yhat after a reboot relay 1 and relay 2 are activated.
After pressing the buttons the are de-activated.
I have changed the 'Send Boot State' and also the 'Internal Pull Up' and also the 'Inversed Logic'.
I will look further into it to find out what is the solution.
TD,
Thanks for this binarie, super.
ESP_Easy_mega_20231107_normal_ESP8266_1M
And it works, super.
The only small disadvantage is yhat after a reboot relay 1 and relay 2 are activated.
After pressing the buttons the are de-activated.
I have changed the 'Send Boot State' and also the 'Internal Pull Up' and also the 'Inversed Logic'.
I will look further into it to find out what is the solution.
TD,
Thanks for this binarie, super.
Re: Sonoff 4CH R3 GPIO
Do you also use some external service/server like Domoticz or HomeAssistant or anything like those?
In other words, do you need to keep the relay state in sync with some external service?
In other words, do you need to keep the relay state in sync with some external service?
-
- Normal user
- Posts: 45
- Joined: 17 Jan 2018, 18:43
Re: Sonoff 4CH R3 GPIO
Yes, I use Domoticz.
I was a little too enthousiastic.
When I again pluged in the module it was not reachenable.
I will find out later what is the problem.
I was a little too enthousiastic.
When I again pluged in the module it was not reachenable.
I will find out later what is the problem.
Re: Sonoff 4CH R3 GPIO
Please also have a look at this one:
https://espeasy.readthedocs.io/en/lates ... #p029-page
When you need to keep a relay/switch in sync with Domoticz, you need to take care to not end up with lots of on/off/on/off flipping of the relay when you boot ESPEasy while Domoticz assumes a different state.
https://espeasy.readthedocs.io/en/lates ... #p029-page
When you need to keep a relay/switch in sync with Domoticz, you need to take care to not end up with lots of on/off/on/off flipping of the relay when you boot ESPEasy while Domoticz assumes a different state.
Who is online
Users browsing this forum: No registered users and 15 guests