Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By b8dm0j0
#37110
Barnabybear wrote:https://github.com/marcoschwartz/aREST/blob/master/aREST.h
Lines 750 & 751.
Code: Select all       // Apply on the pin
       digitalWrite(pin,value);

Change to.
Code: Select all       // Apply on the pin
       digitalWrite(pin,High); // sets output pin high to simulate button press.
       delay(1000); // delay for length of button press.
       digitalWrite(pin,LOW); // sets output pin bak to low to end button press.

I have this setup on GPIO2 so to opperate I can go to ESP IP (192.168.1.xx) and press the button or
go to ESP IP and attach the command (192.168.1.xx/digital/2/1)
format < ESP IP address > / < type of operation (digital write) > / < GPIO to affect (2) > / < effect ( set as 1) >

Mine has just started to hang sometimes (reset fixes it) I'll look into it later.

not sure whats wrong, but after i make those changes to arest.h there is an error compiling, maybe there is also another step you forgot to tell me?

Code: Select allArduino: 1.6.5 (Windows 8.1), Board: "NodeMCU 0.9 (ESP-12 Module), 80 MHz, 115200"

In file included from ESP8266.ino:5:0:
C:\Users\Isaac\Documents\Arduino\libraries\aREST-master/aREST.h: In member function 'bool aREST::send_command(bool)':
C:\Users\Isaac\Documents\Arduino\libraries\aREST-master/aREST.h:745:25: error: 'High' was not declared in this scope
        digitalWrite(pin,High); // sets output pin high to simulate button press.
                         ^
In file included from ESP8266.ino:6:0:
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h: In member function 'virtual void aREST_UI::root_answer()':
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:71:69: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     addToBuffer("HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n");
                                                                     ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:72:31: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     addToBuffer("<html><head>");
                               ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:73:91: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     addToBuffer("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">");
                                                                                           ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:74:27: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     addToBuffer("<script ");
                           ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:75:70: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     addToBuffer("src=\"http://code.jquery.com/jquery-2.1.3.min.js\">");
                                                                      ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:76:28: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     addToBuffer("</script>");
                            ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:77:118: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     addToBuffer("<script type='text/javascript' src='http://cdn.rawgit.com/Foliotek/AjaxQ/master/ajaxq.js'></script>");
                                                                                                                      ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:78:112: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     addToBuffer("<style>.row {margin-top: 30px;} .indicator {font-size: 30px; vertical-align: middle;}</style>");
                                                                                                                ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:79:123: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     addToBuffer("<link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css\">");
                                                                                                                           ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:80:32: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     addToBuffer("</head><body>");
                                ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:81:44: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     addToBuffer("<div class=\"container\">");
                                            ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:85:25: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       addToBuffer("<h1>");
                         ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:87:26: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       addToBuffer("</h1>");
                          ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:90:39: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       addToBuffer("<h1>Interface</h1>");
                                       ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:95:40: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       addToBuffer("<div class=\"row\">");
                                        ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:96:106: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       addToBuffer("<div class=\"col-md-2\"><button class=\"btn btn-block btn-lg btn-primary\" id='btn_on");
                                                                                                          ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:98:40: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       addToBuffer("'>On</button></div>");
                                        ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:99:106: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       addToBuffer("<div class=\"col-md-2\"><button class=\"btn btn-block btn-lg btn-danger\" id='btn_off");
                                                                                                          ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:101:41: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       addToBuffer("'>Off</button></div>");
                                         ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:102:27: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       addToBuffer("</div>");
                           ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:107:40: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       addToBuffer("<div class=\"row\">");
                                        ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:109:113: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       addToBuffer("<div class=\"col-md-2\"><input type='range' value='0' max='1023' min='0' step='5' id='slider");
                                                                                                                 ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:114:29: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       addToBuffer("'></div>");
                             ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:115:27: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       addToBuffer("</div>");
                           ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:120:40: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       addToBuffer("<div class=\"row\">");
                                        ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:121:53: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       addToBuffer("<div class='col-md-3 indicator'>");
                                                     ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:123:29: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       addToBuffer(": </div>");
                             ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:124:57: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       addToBuffer("<div class='col-md-3 indicator' id='");
                                                         ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:126:29: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       addToBuffer("'></div>");
                             ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:127:27: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       addToBuffer("</div>");
                           ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:130:25: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     addToBuffer("</div>");
                         ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:132:59: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     addToBuffer("<script>$( document ).ready(function() {");
                                                           ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:136:31: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       addToBuffer("$('#btn_on");
                               ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:138:67: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       addToBuffer("').click(function() {$.getq('queue','/digital/");
                                                                   ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:140:29: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       addToBuffer("/1');});");
                             ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:141:32: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       addToBuffer("$('#btn_off");
                                ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:143:67: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       addToBuffer("').click(function() {$.getq('queue','/digital/");
                                                                   ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:145:29: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       addToBuffer("/0');});");   
                             ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:150:31: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       addToBuffer("$('#slider");
                               ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:152:64: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       addToBuffer("').mouseup(function() {var val = $('#slider");
                                                                ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:154:55: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       addToBuffer("').val(); $.getq('queue','/analog/");
                                                       ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:156:35: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       addToBuffer("/' + val); });");     
                                   ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:161:38: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       addToBuffer("$.getq('queue','/");
                                      ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:163:45: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       addToBuffer("', function(data) { $('#");
                                             ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:165:34: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       addToBuffer("').html(data.");
                                  ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:167:27: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
       addToBuffer("); });");
                           ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:170:31: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     addToBuffer("});</script>");
                               ^
C:\Users\Isaac\Documents\Arduino\libraries\aREST_UI-master/aREST_UI.h:172:37: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     addToBuffer("</body></html>\r\n");
                                     ^
ESP8266.ino: In function 'void setup()':
ESP8266.ino:30:18: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
ESP8266.ino:31:26: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
Error compiling.

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.
User avatar
By Frederico
#93777 This is a really old post, but I think it's worth it to revive with some refreshed ideas.
I managed to do something very similar and super easy with the Sonoff 4CH Pro that comes with no/com/nc and itching feature.
I was looking for a way to control my home electric gate over eWelink or similarly (google, alexia, etc.)
So what I did was purchase a Sonoff 4CH Pro, since I wanted to also replace my old basic sonoff with this one,
Channel1 Top Lights
Channel2 Gate lights
Channel3 Garden Lights
Channel4 Gate

The beauty of it is the simplicity and requires just the minimum soldering skills, and no need to open or hack with the gate controller, and works with any gate RF remote that has a button.


Step 1: solder 2 tiny cables to the remote button

Image

Step 2: Drill a hole in the box, bottom corner next to the CH4. Since this is an empty area inside the box.

Image

Step 3: Attach battery to remote and wrap in electric tape, and glue it to the box corner next to the LEDs.

Image

Step 4: close the box and connect the 2 cables to NO and COM.
Image

Step 5: Change Sonoff Settings for CH4 to be Iching for either 1.0 or 0.5 Seconds. To simulate a button press, as if you used your finger to press the button, so try either and see which one works best, I found no issue with either, but I feel 0.5s too short for the relay, so I am at 1.0s)
Image

Voila!