Zero Cross

Zero crossing detection for AC mains voltage

Warning
CAUTION: this module was design to connect directly to the AC grid power, and its misuse might cause ELECTRIC SHOCK and FIRE. Only use this module if you already have prior experience with mains AC circuits, and carefully follow the safety recommendations at the bottom of this page.

The Zero Cross Nanoshield allows you to identify the moment when the AC voltage from the power grid crosses the zero-volt line. This can be used in the following applications:

  • Dimming of incandescent, halogen or other dimmable lamps.
  • Smooth control of high power loads, minimizing noise on the main power line (also check the Triac Nanoshield).
  • Detection of presence or lack of electric power.

Main features:

  • Centralized output pulse on zero crossing with constant 1 millisecond duration, either for 127V or 220V.
  • Optically coupled output to isolate AC voltages from other DC circuits and components.
  • Efficient detection circuit that generates a lot less heat than solutions based on optocouplers connected directly to power resistors.
  • Output selection between 5V or 3.3V output via solder jumper (default: 5V).
  • 17 options for the output pin, selectable via solder jumper (default: D2).
  • Output status indicator LED.

Diagrama Zero Cross diagram

Zero crossing with 127V input

Zero crossing with 220V input

!Sample code

The Arduino code below shows how to make a simple measurement of the AC grid frequency using the Zero Cross Nanoshield and show it on the serial monitor:

#define SECONDS 2.0

int count = 0;

void setup()
{
  Serial.begin(9600);
  Serial.println("Zero Cross Test");

  attachInterrupt(0, cross, RISING);
}

void loop()
{
  delay(SECONDS * 1000);

  noInterrupts();
  float hz = count / SECONDS / 2;
  count = 0;
  interrupts();

  Serial.print(hz);
  Serial.println("Hz");
}

void cross() {
  count++;
}

To learn how to use the Zero Cross Nanoshield along with the Triac Nanoshield to dim lights, for exemple, check out our Dimmer library.

Electrical specifications

  • Power supply: done through the VCC pin, with a range from 4.5V to 5.5V (5V typical). Alternatively, it can be done through the 3V3 pin – in this case the VLOGIC jumper configuration must be changed (see instructions in the schematics).

  • Current consumption: the maximum current consumption is 3mA.

  • Logic levels: the output signal is factory configured to work with a logic level of 5V. By changing the VLOGIC jumper, it's possible to configure it to operate with 3.3V (see instructions in the schematics).

Safety recommendations

Please follow the recommendations below before using this Nanoshield or any other device that is directly connected to the mains AC grid power supply.

  • Keep in mind that AC mains current can be very dangerous. Accidents can cause injuries and even death. Hence, only use this equipment if you have prior knowledge about mains electrical circuits and if you are absolutely certain of what you are doing. If you are a beginner who is starting to play with electronics, do not use this Nanoshield or any other equipment which has a direct connection with the mains AC grid.
  • Certify yourself that the electrical installation of the place you are working on follows the local safety rules and has a residual-current circuit breaker (RCCB) installed.
  • Never touch or handle the device when it's the mains AC power is on – always turn off the circuit breaker before connecting the wires or doing any manual configuration in the system.
  • This Nanoshield does not have safety devices like fuses or circuit breakers – you must install them externally according to the particular needs of your project.
  • If you want to include this module in a commercial product, check the requirements that are applicable to the safety certification processes in your area.

Downloads

Projects