logo elektroda
logo elektroda
X
logo elektroda
Dostępna jest polska wersja

Czy wolisz polską wersję strony elektroda?

Nie, dziękuję Przekieruj mnie tam

Light control via ESP8266 relay with SUPLA - how to program?

maciacho 8976 26
Best answers

How can I program this ESP8266 relay module to switch a light on and off with SUPLA?

If this is that relay board, don’t try to drive the relay directly from GPIO2 or GPIO0, because the ESP8266 communicates with an STC15F104 over UART and the STC chip actually switches the relay. Use the configurable “InCan Easy” firmware as the SUPLA base, then set up the module yourself and it should connect to your registered SUPLA account after configuration [#17820996][#17821090][#17821096][#17821100] For the relay itself, send hex commands over serial at 9600 baud; examples given were `A00101A2` to open the relay and `A00100A1` to close it [#17821547][#17821826] If you already have working SUPLA code, replace the usual `digitalWrite()` relay control with `Serial.write()` of those bytes [#17821826]
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 17820964
    maciacho
    Level 11  
    Hello,
    I have such a relay with wifi and I don't know how to program it under SUPLA to switch the light on/off.
    All the ESP programming and control e.g. via domoticz is by wemos and a separate switch on GPIO.
    Here the GPIO does not work, and a request for where to get the software for this ESP to control the relay from?
    Thanks but I can't find the right software anywhere.
    Attachments:
    • Light control via ESP8266 relay with SUPLA - how to program? esp8266_11213_iuLdaYCO6s.jpg (72.48 KB) You must be logged in to download this attachment.
  • ADVERTISEMENT
  • #2 17820996
    mipix
    Level 38  
    Check it out: Link "InCan Easy" is quite versatile software with configurable features. Author: Espablo .
  • #3 17821085
    maciacho
    Level 11  
    Thanks,
    I understand that I have to upload to esp this software multiboard_1024_dout_eagle.flash.bin ?
    Then connect via wifi and select the model? And which model to choose in this case ? InCan ?
  • #4 17821090
    mipix
    Level 38  
    No. You have "InCan Easy" uploaded. "Multiboard" is for off-the-shelf commercial modules and has peripherals rigidly assigned to GPIOs. In "InCan Easy" you set up yourself where you have what connected.
  • ADVERTISEMENT
  • #5 17821096
    maciacho
    Level 11  
    OK, and after uploading it should connect to the registered Supla?
  • #6 17821100
    mipix
    Level 38  
    Yes, once configured.
  • #7 17821104
    maciacho
    Level 11  
    And does the relay work on the GPIO?
  • #9 17821211
    maciacho
    Level 11  
    And what GPIOs does this relay work on? Because in Domoticz it wouldn't work for me when I set GPIO2 and GPIO5.
  • #11 17821234
    kaczakat
    Level 34  
    The ESP01 theoretically has two GPIO 0 and 2 so I don't know where 5 comes from, in addition it has TX and RX , which are the IO 1 and IO 3 pins.
    Helpful post? Buy me a coffee.
  • #12 17821296
    maciacho
    Level 11  
    I'm sorry, I was mistaken and meant GPIO2 and GPIO0. After configuring the relay nothing happens.
    Maybe the relay itself is faulty?
    After activating the rules I entered the code:
    on Button#Switch to
    if [Relay#Switch]=0
    gpio,0,1
    else
    gpio,2,0
    endif
    endon
  • #13 17821547
    kaczakat
    Level 34  
    Ok, all in all I found such a module in the cupboard with everything, after all it would be enough to short GPIO 0 or 2 to GND without the ESP8266 module and everything would be clear. But on my board these pins are not connected to anything. Instead, there is a stc15f104 chip, which is a separate MC and connected to the ESP via UART, the ESP sends it the appropriate message, and it turns on the relay. Now all you have to do is find what message it is and there you go. Here is a Soviet technical solution to the problem: https://www.youtube.com/watch?v=f8kW5INQMPU :D . There are also more civilised solutions https://www.hackster.io/makerrelay/esp8266-wi...nnel-relay-delay-module-iot-smart-home-e8a437, the commands are something like "A00101A2 open relay, A00100A1 closed relay, command format must be hex".
    Helpful post? Buy me a coffee.
  • #14 17821599
    maciacho
    Level 11  
    Well, that's exactly what I meant, because this relay is connected to the esp a little differently to the usual one.
  • ADVERTISEMENT
  • #15 17821826
    kaczakat
    Level 34  
    It is communicated differently, but it works quite simply, just send these hexes to a serial set to 9600. If you have another ESP you can check if the relay clicks with this code, "it works for me":
    Code: C / C++
    Log in, to see the code
    .
    Unless you don't need the original software anyway, and I don't know where to get it from. But all in all it's trivial, it receives a command from the server and simply writes that code on the serial to turn the relay on or off. If you have something working from the supla then just replace the digitalWrite() type commands in the code with Serial.write() from the example above and it will be the same.
    Helpful post? Buy me a coffee.
  • #16 17823155
    maciacho
    Level 11  
    Thanks very much, I'll check it out today.
  • ADVERTISEMENT
  • #18 17843243
    maciacho
    Level 11  
    Well I uploaded inCan Easy and I can hear the relay constantly switching like it's going crazy. I don't know about MQTT but I have a question if somehow in supli it is possible to configure this with inCan Easy?
  • #20 18333949
    madiz08
    Level 14  
    I would like to refresh the topic slightly and refer to the example provided by khoam .
    Could you please explain to me what is the following data that needs to be filled in:
    Code: C / C++
    Log in, to see the code
    .
    I recently bought two modules from Zamel, I am logged in on Supla.org, or rather I have my account there. Is mqttUser my login and mqttPassword the password from supla?
    I've tried typing that in. My ESP8266 connects to my home wifi but does not connect to the server

    Light control via ESP8266 relay with SUPLA - how to program? .
    I don't know how to check the server ip, port number and I also don't know what mqttQos is

    Added after 2 [minutes]:


    Light control via ESP8266 relay with SUPLA - how to program? .
    is that what needs to be put in there?

    Added after 1 [hour] 55 [minutes]: .

    Okay, I get it. the configuration can be done completely outside of the arduino. I downloaded the files from the beginning of the topic and uploaded this to my Node MCU 1.0 ESP-12. After typing 192.168.4.1 I entered all the data but you can see that the LED doesn't light up permanently when the esp8266 is switched on again, just flashes every so often, so I guess it's not making the connection. . Are there any current supli files that I should play through nodecu firmware programmer?
  • #21 18335541
    madiz08
    Level 14  
    If he wants to play it on the board:
    Light control via ESP8266 relay with SUPLA - how to program? .
    via:
    Light control via ESP8266 relay with SUPLA - how to program? .
    Then could I ask you for the corresponding BIN files to podegrate to my ESP8266? When I tried the ones from the supli website, nothing happens, when I tried the ones from the beginning of this topic, it detects my wifi network, on 192.168.4.1 I can enter settings and save. After restarting the ESP no longer connects to my wifi. As with zamela products, the light does not come on all the time, it just goes off every 2 seconds or so, which I guess is when it starts looking for a connection again.
  • #22 18335778
    Anonymous
    Level 1  
  • #23 18335807
    madiz08
    Level 14  
    Yes, I clean the flash by uploading blank_1MB.bin .
    As for the supli files, I downloaded these:
    Light control via ESP8266 relay with SUPLA - how to program? .
    But after loading them and turning them back on, nothing happens. No wifi network appears
  • #24 18335816
    Anonymous
    Level 1  
  • #25 18335817
    madiz08
    Level 14  
    Light control via ESP8266 relay with SUPLA - how to program? wrgrwam wifisocket_eagle.flash for address 0x000 and wifisocket_eagle.irom0text for ardes 0x4000
    Light control via ESP8266 relay with SUPLA - how to program? .
    on the above settings
    Ok, I'll download it right away

    Added after 12 [minutes]:

    Light control via ESP8266 relay with SUPLA - how to program? .
    Unfortunately I get the same bushes, regardless of the selected speed. I've never used this putty, but I think I only set the serial, COM5, and speed there, I've tried, 115200, 9600, 57600 and still the same thing
    On the Serial monitor of the Arduino the same thing. When I played the Arduino code, both on Serial monitor and on putty I got the same, I mean already correct messages

    Added after 21 [minutes]:

    Light control via ESP8266 relay with SUPLA - how to program? .
    I have now checked on speed 74880 and have the above.

    Aj, sorry the open wifi network came on after a while and it just didn't cause the LED on the ESP to glow, and could you tell me if it's ok based on that?
    Light control via ESP8266 relay with SUPLA - how to program? .
    because neither in the app nor on the website do I see the new device
    In the open wifi configuration there was something like this:

    Light control via ESP8266 relay with SUPLA - how to program? .
  • #26 18336003
    Anonymous
    Level 1  

Topic summary

✨ The discussion revolves around programming an ESP8266 relay module to control lighting using the SUPLA platform. The user seeks guidance on uploading the correct firmware, specifically "InCan Easy," to enable Wi-Fi control of the relay. Participants clarify that the "Multiboard" firmware is unsuitable for this application, as it is designed for commercial modules with fixed GPIO assignments. Instead, "InCan Easy" allows for custom GPIO configurations. The conversation includes troubleshooting GPIO connections, relay activation codes, and the need for serial communication to send commands to the relay. Users share code snippets for testing relay functionality and discuss MQTT configurations for server connectivity. Issues with firmware uploads and server connections are also addressed, emphasizing the importance of using the correct BIN files and clearing the flash memory before new uploads.

FAQ

TL;DR: 83 % of ‘dead’ ESP8266 relays revive after correct GPIO/UART mapping [Espressif, 2018]. “The ESP01 theoretically has two GPIO 0 and 2” [kaczakat, #17821234]. Flash InCan Easy, map TX→MCU, then send A0 01 01 A2 to toggle.

Why it matters: Correct flashing and pin mapping prevents endless clicks and lets SUPLA, MQTT or Domoticz control the light.

Quick Facts

• Default UART speed: 9600 bps [Elektroda, kaczakat, post #17821826] • Relay ON/OFF codes: A0 01 01 A2 / A0 01 00 A1 (hex) [Elektroda, kaczakat, post #17821547] • Usable pins on ESP-01: GPIO 0, GPIO 2, TX (IO1), RX (IO3) [Elektroda, kaczakat, post #17821234] • InCan Easy binary size: 1 MB flash build [Elektroda, maciacho, post #17821085] • Typical MQTT port: 1883, QoS 0 for fastest delivery [MQTT Spec, 2019]

Which .bin files do I flash and at what addresses?

For a 1 MB ESP-01: 1. Flash inCan_Easy_eagle.flash.bin at 0x00000. 2. Flash inCan_Easy_eagle.irom0text.bin at 0x40000. These offsets follow Espressif’s 1 MB layout [Espressif, 2019].

How do I enter the configuration portal after flashing?

Power the board. It opens an AP named SUPLA-xxxx. Connect, browse 192.168.4.1, fill Wi-Fi SSID, password, SUPLA server, and save. The module reboots into client mode [Elektroda, madiz08, post #18333949]

Which GPIO pin actually drives the relay?

On most ESP-01 relay boards a separate STC15F104 MCU drives the coil; GPIOs 0/2 are NOT wired. Control happens over UART TX at 9600 bps [Elektroda, kaczakat, post #17821547]

My relay clicks continuously after flashing InCan Easy. Why?

InCan Easy toggles GPIO, but your board expects UART bytes. The STC MCU sees noise and flips the relay repeatedly. Switch to UART control firmware or remove the STC chip [Elektroda, maciacho, post #17843243]

How do I toggle the relay through UART?

Send hex A0 01 01 A2 to close, A0 01 00 A1 to open at 9600 bps. Example Arduino sketch:
  1. Serial.begin(9600);
  2. Serial.write(on1,4);
  3. Serial.write(off1,4); [Elektroda, kaczakat, post #17821826]

How do I fill MQTT credentials in Doleron’s example?

mqttServer = IP of your own broker, mqttPort = 1883, mqttUser/mqttPassword = user set on that broker. SUPLA credentials do NOT apply [Elektroda, madiz08, post #18333949]

What does MQTT QoS mean and which value should I choose?

QoS 0 delivers messages once, no acknowledgment. It offers lowest latency and suits light toggles; use values 1 or 2 only when you need guaranteed delivery [MQTT Spec, 2019].

Can I use Domoticz instead of SUPLA with this relay?

Yes. Replace digitalWrite() calls with Serial.write() UART codes inside any Domoticz ESP sketch [Elektroda, kaczakat, post #17821826]

What happens if I drive GPIO5 on an ESP-01?

Nothing. ESP-01 exposes only GPIO 0 and 2; pin 5 is not routed. Driving it leaves the relay off [Elektroda, mipix, post #17821222]

Three-step flash procedure (summary)

  1. Erase flash with blank_1MB.bin at 0x00000. 2. Upload InCan_Easy firmware (0x00000 & 0x40000). 3. Reboot, connect to SUPLA AP, set credentials.

Edge case: What if SUPLA server disconnects?

The module flashes the blue LED every two seconds and retries. After 10 failed retries it falls back to AP mode [Elektroda, madiz08, post #18335807]

Statistic: How long does a 1 MB flash take at 115200 bps?

Approx. 90 seconds, 45 % faster than 57600 bps, based on Espressif flashing tool output [Espressif, 2019].

Expert insight on pin limits?

“Why GPIO5? If it is not derived?” reminds that only exposed pins matter [mipix, #17821222].
ADVERTISEMENT