logo elektroda
logo elektroda
X
logo elektroda

How to control the Sonoff MINI R3 with ESP8266 via WiFi with BL602?

Tuseras_09 1533 13
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 20903929
    Tuseras_09
    Level 12  
    Hey, I would like to use the simple input dependency logic of the ESP8266 to control two SONOFF MINI R3 modules via WIFI.
    I have already bought the hardware, because unfortunately it turned out that in the sonoffs sit BL602L20 and not ESP as I expected.
    I am completely green with both smarto home and arduino.

    I mean, for clarity, I have the ESP8266 in one location and it has to switch on the relay in the sonoffs depending on the signal given to the ESP input. And the MINI R3 is only supposed to receive a command over WiFi to switch the relay on or off. Can someone please explain this to me in a spatial way, what I need to do to make it work. I have already extracted the programming signals from the MINI R3, but I don't even know what to upload there since the BL602 is sitting there ;(
  • ADVERTISEMENT
  • Helpful post
    #2 20903970
    p.kaczmarek2
    Moderator Smart Home
    Here you have BL602 flashing tutorials:







    Are all devices on the same LAN?
    Helpful post? Buy me a coffee.
  • #3 20903987
    Tuseras_09
    Level 12  
    Thanks, I watched but didn't know what to upload there and if it would be suitable.

    Yes, all devices in one local network. Close enough that they could talk to each other, but to be sure I will use the APs that are in both rooms (mesh network).

    So on the BL602 I should upload as in the video? How do I further communicate the ESP8266 with the sonoffs with this uploaded software?
  • #4 20904068
    p.kaczmarek2
    Moderator Smart Home
    And what on ESP do you have uploaded?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #5 20904131
    Tuseras_09
    Level 12  
    Nothing yet, first I wanted to solve the control issues then I will divide with the logic (basically just the product of 3 input signals).
    For the moment hardware ready to flash, after downloading one BLDevCube.exe file, transferring to C:/ the message "Failed to execute script BLDevCube" pops up, so I guess I haven't downloaded something yet.
  • Helpful post
    #6 20904277
    p.kaczmarek2
    Moderator Smart Home
    I haven't seen this error yet. Where did you download from? Do you have administrator rights?
    Helpful post? Buy me a coffee.
  • #7 20905676
    Tuseras_09
    Level 12  
    My error was due to not downloading the entire directory. In the end I managed to upload the flash for one module, I managed to find that P5- button, P22- relay and diode. I didn't find the second diode, it doesn't matter - it looks like the issue with the relay and communication is solved.

    Now just the key question, how to control these converted sonoffs using the ESP8266?
    Simply speaking, I would like to connect 2 inputs to the ESP8266:
    if on the 1st input of the ESP there is a high state, then the ESP turns on sonoff number 1,
    if on the 2nd input of the ESP there is a high state, then the ESP turns on sonoff number 2.
    But, I will develop the logic of the inputs later ;) .
  • ADVERTISEMENT
  • Helpful post
    #8 20906127
    p.kaczmarek2
    Moderator Smart Home
    And what on ESP is

    You can send them commands over HTTP, the submission is Tasmota style. Just like Tasmota you can send a POWER ON or OFF or TOGGLE command via HTTP, the same here.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #9 20906152
    Tuseras_09
    Level 12  
    At the moment I have the 8266 as I took it "out of the box". I don't have anything uploaded there. I will need 3 conditions to handle the outputs, but I wanted to start with device control first, I will develop the code later.
    Could you give me a hint on what is easiest to put on the 8266 and how to send such a command frame?
  • #10 20906538
    p.kaczmarek2
    Moderator Smart Home
    If you can, please provide the solution you used and then close the topic.

    I would think either PlatformIO with ArduinoOTA, or about sending HTTP cm/cmnd GET from Tasmota.
    Helpful post? Buy me a coffee.
  • Helpful post
    #11 20906843
    Tuseras_09
    Level 12  
    Code: C / C++
    Log in, to see the code


    Recommendations after http.
  • #12 20907235
    p.kaczmarek2
    Moderator Smart Home
    Ok, now the topic can be closed. I would add that analogously you can execute commands on a device with Tasmota. By the way, here is a list of OBK commands:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commands.md
    Helpful post? Buy me a coffee.
  • #13 20908120
    Tuseras_09
    Level 12  
    Finally, I have a question about control from the android platform. I am also concerned with the simplest possible way, I was thinking of a single widget for one device- on/off.

    Have you any ideas on how to implement this for devices with OpenBeken?
  • #14 20908203
    p.kaczmarek2
    Moderator Smart Home
    OpenBeken and Tasmota are compatible with Tasmota Control and similar applications, these applications work via HTTP:



    In your own project you can also get compatibility with this application relatively easily, you just need to respond in a certain way to GET requests, just like Tasmota does.
    My relay controller on the PIC18F67J60 is compatible with it, the code is available on the forum:
    https://www.elektroda.pl/rtvforum/topic3789324.html
    Helpful post? Buy me a coffee.

Topic summary

✨ The discussion revolves around controlling two Sonoff MINI R3 modules using an ESP8266 via WiFi, particularly after discovering that the Sonoff devices contain a BL602 chip instead of the expected ESP chip. The user seeks guidance on how to upload the necessary firmware to the BL602 and establish communication between the ESP8266 and the Sonoff modules. Various responses provide insights into flashing the BL602, using HTTP commands for control, and suggest programming approaches, including the use of Tasmota firmware. The user successfully uploads the firmware and outlines a plan to implement input conditions for controlling the relays on the Sonoff devices. Additionally, there is a query about controlling the devices from an Android platform, with suggestions for compatibility with existing applications.
Generated by the language model.

FAQ

TL;DR: Use ESP8266 to switch OpenBeken‑flashed Sonoff MINI R3 over Wi‑Fi with 1 HTTP GET; "You can send them commands over HTTP, Tasmota style." [Elektroda, p.kaczmarek2, post #20906127]

Why it matters: This helps DIYers link ESP8266 input logic to BL602‑based Sonoff MINI R3 for fast, cloud‑free control.

Quick facts:

Quick Facts

What firmware should I flash on a BL602 Sonoff MINI R3 for local control?

Flash OpenBeken on the BL602 MINI R3. It exposes Tasmota‑style HTTP endpoints for relay control. You can then send POWER, TOGGLE, or channel commands locally. This mirrors how Tasmota devices behave. The thread links the OpenBeken commands list for reference. [Elektroda, p.kaczmarek2, post #20907235]

Do all devices need to be on the same network?

Yes. Keep the ESP8266 and the MINI R3 units on the same LAN for direct HTTP control. This avoids extra routing, NAT, or cloud services. It also reduces latency and complexity. [Elektroda, p.kaczmarek2, post #20903970]

Can you show a 3‑step setup to map two ESP8266 inputs to two relays?

  1. Wire two digital inputs (e.g., D1 and D3) and set them as INPUT.
  2. In loop(), detect input changes and manage intervals with millis().
  3. On change, send http://IP/cm?cmnd=toggleChannel%200 (or 1) to each MINI R3. The sample sketch uses 10 s ON and 50 s OFF timers. [Elektroda, Tuseras_09, post #20906843]

How do I fix "Failed to execute script BLDevCube"?

Download and use the full BLDevCube directory, not a single EXE. The error appeared when files were missing. After grabbing the complete folder, flashing proceeded correctly. Run with appropriate permissions if needed. [Elektroda, Tuseras_09, post #20904131]

Which pins map to the button, relay, and LED on MINI R3?

On the referenced board, P5 is the button input. P22 drives the relay and an LED. A second LED may be absent on some revisions. Confirm mappings in OpenBeken’s web UI and adjust the template if required. [Elektroda, Tuseras_09, post #20905676]

How can I control OpenBeken from Android with a widget?

'OpenBeken and Tasmota are compatible with Tasmota Control,' which uses HTTP. Install Tasmota Control, add your device, and create a widget for POWER TOGGLE or channel actions. It gives one‑tap control without cloud dependence. [Elektroda, p.kaczmarek2, post #20908203]

Do I need MQTT or a cloud, or is HTTP enough?

HTTP is enough for local control. Send Tasmota‑style commands directly to each device over LAN. As noted, "Just like Tasmota you can send a POWER ON or OFF or TOGGLE command via HTTP." Add MQTT only if you need brokers or dashboards. [Elektroda, p.kaczmarek2, post #20906127]

What’s the quickest way to build the ESP8266 side?

Use PlatformIO with ArduinoOTA for fast iteration. Alternatively, control devices from a Tasmota module by sending HTTP cm/cmnd GET requests. For small sketches, the Arduino ESP8266HTTPClient library is sufficient. Choose the path that matches your toolchain. [Elektroda, p.kaczmarek2, post #20906538]

Where do I find supported OpenBeken commands?

See the OpenBeken commands reference. It documents POWER, TOGGLE, toggleChannel, and related parameters. URLs follow Tasmota naming and structure. Use it to validate command syntax before automating. [OpenBeken commands]

Can I trigger OpenBeken devices from a Tasmota relay module?

Yes. From Tasmota, issue an HTTP GET to the OpenBeken device’s cm/cmnd endpoint. Use Rules or Backlog in Tasmota to fire the request on button or relay events. This keeps everything local. [Elektroda, p.kaczmarek2, post #20906538]

How do I confirm a command worked?

Check that the device returns HTTP 200 OK. Listen for the relay click and watch any mapped LED. In code, print the http.GET() result to Serial for diagnostics. You can also query status via a follow‑up command. [Elektroda, Tuseras_09, post #20906843]

How do I keep timing logic non‑blocking on ESP8266?

Use millis() tracking instead of delay(). Store previousMillis per channel and compare against intervals. Toggle outputs when intervals elapse. This keeps Wi‑Fi responsive and avoids blocking. The posted sketch demonstrates the pattern. [Elektroda, Tuseras_09, post #20906843]
Generated by the language model.
ADVERTISEMENT