I am trying to make a 3kW triac based ESP8266 dimmer with zero detection for controlling boiler power, but the installation here in Belgium does not have neutral, so connection is to two live wires. I am using schematics from MOC3042 datasheet, without snubber circuit, applied to one live wire only. The problem is that for power values >0% and <100% test bulb just flickers randomly. Zero detection works ok as far as I can see on the scope, and even the whole circuit was behaving ok at 60VAC without load, but when testing it on 230VAC and with 40W light bulb goes bananas. Same flicker appears when testing with 2.5kW pool heater with led. Scope pics are with 33%, 50%, 70% power respectively, no load, 60VAC mains isolated.
// Check zero-crossing by polling the zero-cross detection pin
if (outputPower) {
if (digitalRead(ZERO_CROSS_PIN) == HIGH && !pulseHigh) {
pulseHigh = 1;
period = micros() - zeroCrossedMicros;
frequency = 500000.0 / period;
frequency = round(frequency * 100) / 100.0;
zeroCrossedMicros = micros();
} else if (digitalRead(ZERO_CROSS_PIN) == LOW && pulseHigh ) {
pulseHigh = 0;
}
if (micros() - zeroCrossedMicros > pulseDelay) {
digitalWrite(TRIAC_PIN, HIGH);
digitalWrite(TRIAC_PIN2, HIGH);
delayMicroseconds(20);
digitalWrite(TRIAC_PIN, LOW);
digitalWrite(TRIAC_PIN2, LOW);
}
}