4

I'm looking for an ESP8266 board with a dual relay for one of my projects. Yes a Sonoff Dual - quite answers all my needs, beside the part of messing around with soldering and the for need more GPIO's and I want them reachable.

While looking around, this product caught my eye. All seemed good, but I suddenly noticed that there is a STM microprocessor additional to an ESP8266 chip.

  1. I'll be happy to hear pros and cons for such system (dual MCUs).

  2. Since I write my own code using Arduino IDE, how is the access is done when ESP8266 serves only the wifi connectivity .

3 Answers 3

3

I successfully used this exact board tctech.cc's relay boards on my project. It's very easy to program.

Here's how to control the relay from the ESP01 module:

Send this to the TX pin using the UART 115200 bps (some boards could be 9600):

  • Relay 1 ON: 0xA0, 0x01, 0x01, 0xA2
  • Relay 1 OFF: 0xA0, 0x01, 0x00, 0xA1
  • Relay 2 ON: 0xA0, 0x02, 0x01, 0xA3
  • Relay 2 OFF: 0xA0, 0x02, 0x00, 0xA2

(if you get the 4 relay version...)

  • Relay 3 ON: 0xA0, 0x03, 0x01, 0xA4
  • Relay 3 OFF: 0xA0, 0x03, 0x00, 0xA3
  • Relay 4 ON: 0xA0, 0x04, 0x01, 0xA5
  • Relay 4 OFF: 0xA0, 0x04, 0x00, 0xA4

The format is the following:

  1. first byte: 0xA0
  2. second byte: relay number (first is 0x01)
  3. third byte: command (0x00-off, 0x01-on)
  4. fourth byte: sum of previous bytes
1
2

The product link which you have provided contains the ESP-01 module. The ESP or wifi module is only used for communication through wifi or server and it will send the data through the UART to the STM8 controller and the further controlling will be done through the STM8 you will need to check whether the Rx and Tx lines of ESP-01 are connected to the Rx and Tx of the STM8. If yes then the STM8 will only compare the string received and will turn On or Off the relay.

For using your own code on Arduino the access will be done through the UART as said before

I cannot comment on the pros and cons of the module or of using different MCUs

2
  • Thank you for your answer. I can’t see how can I affect ESP chip in code ( for example sending a MQTT message) or define a certain behavior of the STM chip
    – guyd
    Dec 24, 2020 at 14:28
  • If you want to define a certain behaviour then you will need to change the firmware of the STM32 and what do you really want to affect of the ESP
    – Maaz Sk
    Dec 26, 2020 at 15:48
0

I'll be happy to hear pros and cons for such system (dual MCUs).

I have used two STM32 MCUS in a robotic application before, where one MCU was responsible for processing 32 analogue signals, which means 32 ADC channels to be read and processed in real-time. The higher sampling rate was the better. The other MCU was responsible for multiple PID controllers, battery management, Bluetooth connection, controlling servos and a DC motor. So the pros were:

  • Load balanced, decoupled system parts with clear responsibilities. The large amount of analogue signal processing did not conflict with the PID controllers, motor drive, etc. It could run on highest priority on another MCU without compromising other parts of the system.
  • The increased hardware complexity resulted a decreased software complexity. (To be honest this could be a con as well, depending on the application.)

Regarding the relay board in question, I do not see any requirement that would justify the two MCUs. It could have been realized just with the ESP only.

Now as for the cons:

  • Number one con is cost. An additional MCU and its supplementary circuity (programming interface, power, etc.) will cost more. Same goes for the increased PCB size.
  • With the different MCU selection on the relay board, more complexity was introduced in development as the MCU are from different manufacturers. They require different toolchains, programming tools, SDKs, etc. (In my example we went with two STM32 MCU, so it was not an issue.)

Since I write my own code using Arduino IDE, how is the access is done when ESP8266 serves only the wifi connectivity .

The other answers have summed it up pretty well that the STM8 expects commands via UART, so you could change the program on the ESP while interfacing the STM8 with the same UART commands. The STM8 will act as an external peripheral like a GPS or GSM module would. So you can create an MQTT client on the ESP that will subscribe to some topic instead of using the demo app to control the relays.

Luckily the ESP-01 can be removed from the board, which makes it much simpler to flash it, How to Program ESP8266 (ESP-01) Module with Arduino UNO. You do not have to bother with the STM8 and with the fact that it sits on the same UART lines.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.