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.