Please find the details of the project on STM8 board as discussed on the call.
We want to build a working prototype which has the following components,
1. STM8 Microcontroller
2. 4 * HLW8012
3. 4 * Dimmer (Triac based)
Dimmer Module: The module should be able to control the 4 channel Dimmer via UART Commands from the ESP32. The commands will be like "D : 1,52" (* D : <channel_to-be_dimmed> *). The appliance connected to the specified channel should be dim up to the specified level.
Dimmer Specifications: The dimmer should be able to control all the devices (Inductive or Resistive loads) in 101 (0-100) steps without any flickering/humming noise. You can find the reference design for the dimmer:
https://robotdyn.com/pub/media/0G-00005678==Mod-Dimmer-5A-2L/DOCS/Schematic==0G-00005678==[login to view URL]
Power Monitoring System: You need to measure the power consumed by the devices connected at the dimmer end. The range and accuracy are of prime importance for us. Range - 5watt to 1.5KW and Accuracy greater than 99%. We have finalized the power metering IC (i.e. HLW8012) and have tested it as per our requirement with Arduino board.
HLW8012 Specification: HLW8012 is a power metering chip which gives output on CF and CF1 pins. The CF pin outputs a signal with a constant 50% duty cycle and frequency proportional to the Power consumed by the device and CF1 pin can output both the voltage and current reading in a similar fashion. The output of both the pins are independent and hence we require the power of the appliances per module (1 HLW8012) since the voltage will be same across all the 4 channels. So in total, we'll be using 4 CF pins from different HLW8012 modules. We also need to read what constant voltage is being supplied to the appliance and hence 1 CF1 pin will be used which will be giving us the voltage value. For details about HLW8012 Module find the link below.
[login to view URL]
Synopsis of Interrupt Pins: So in total, we require 6 interrupt pins, 5 of HLW8012 and 1 Interrupt pin for Zero crossing.
STM8 and ESP32 board communicate through UART so there will be a basic protocol where we can set the value of the dimmer and ESP32 can request the Power reading of certain channel ("P : 2" - A request command from ESP32 for power consumption of Channel 2) from STM8.