I used circuit like this: enter image description here

On led I get: 3.3 mA and 1.3V

What is the best way to test if zero crossing works with arduino or multimetar?

  • 3
    \$\begingroup\$ An oscilloscope. \$\endgroup\$ – Andy aka Feb 3 '16 at 13:59
  • \$\begingroup\$ I don't have... \$\endgroup\$ – Vladimir Djukic Feb 3 '16 at 14:07
  • 1
    \$\begingroup\$ There are some cheap ones on ebay for less than 25$ USD ebay.com/itm/PC-Computer-Digital-USB-Oscilloscope-1MS-Sampling-/… you may be able to find them cheaper coming directly from china. They even have some based off of PIC's for 13$ USD You really need something to look at time. \$\endgroup\$ – Voltage Spike Feb 3 '16 at 17:38
  • \$\begingroup\$ just don't start probing high voltage circuit ( like the mains side of the circuit above ) until you have learned about the ground paths from your scope lead through the building wiring and back to the circuit your testing. The issue is shorting the supply through the scope / pc / earth to live...the result is a burned mess. \$\endgroup\$ – Spoon Feb 3 '16 at 20:46

A simple test is to use a multimeter to measure the voltage on the output. Since it should be PWM you should see something between 5V and 0V. If you see 5V or 0V, then it's not working, but if you see something between the two, it's probably working.

Another option is to connect an LED with an appropriate resistor between 5V and the output, then sweep your eyes across the LED. 100Hz is very low frequency, and it should appear that instead of a solid light streak in your vision there should be a dotted line of light pulses if the zero crossing is working correctly.

Another option is to connect a small, low power speaker and series resistor between 5V and the output. You can then hear the 100Hz zero crossings if it's working correctly.

If you have an arduino, though, it's easy enough to count the number of pulses per second and verify correct operation.


Does your multimeter have any sort of frequency counter function? Some do, and that would be simplest — verify that the output of the detector matches your line frequency.

Otherwise, program the Arduino to be a frequency counter and look at the results there. It isn't hard to do. Just count the rising edges for one second and print out the value.

  • \$\begingroup\$ Could you provide me some simple code for arduino? \$\endgroup\$ – Vladimir Djukic Feb 3 '16 at 14:12
  • \$\begingroup\$ I'm not an Arduino programmer, but see the link I added above. \$\endgroup\$ – Dave Tweed Feb 3 '16 at 14:15
  • \$\begingroup\$ But the output of that detector would output pulses at 100Hz on 50Hz 230V mains (two zero crossings for each period). \$\endgroup\$ – jms Feb 3 '16 at 15:07
  • \$\begingroup\$ The H11AA1 uses two LEDs in inverse parallel to excite the phototransistor, so the output frequency will be twice the line frequency. \$\endgroup\$ – EM Fields Feb 3 '16 at 15:13
  • \$\begingroup\$ OK, fair enough. I didn't look up the part; I just assumed that one of the diodes was not an LED. In that case, you don't get any phase information (rising vs. falling edge), and the Arduino needs to be fast enough to catch the relatively narrow output pulses. \$\endgroup\$ – Dave Tweed Feb 3 '16 at 15:22

Here's a simple Arduino program for measuring the AC crossing interrupt:

#define ZERO_DETECT   2     // Your arduino interrupt pin
#define BOARD_LED     13    // on board LED

// volatile required if you are going to reference this variable
// outside of the interrupt procedure
volatile  byte zeroCrossCounter = 0;

void setup() {
  // You don't need a pullup since you can use the Arduino pullup

void loop() {
  // put your main code here, to run repeatedly:
  // Nothing to do here

void AcZeroCrossingInterrupt () {

  if ( ++zeroCrossCounter == 60 ) {     // blink LED approx every 1/2 second
    zeroCrossCounter = 0;
  • \$\begingroup\$ Perhaps OP will be more thankful if you can also help OP in verifying that zero cross detector is indeed working correctly. \$\endgroup\$ – Umar Jan 19 '17 at 0:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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