Relay works backwards (on when it should be off)

  • Relay module

Why it happens

  • The module is active low.
  • The wire is in NC instead of NO.

How to fix it

  1. Swap HIGH and LOW for the relay in the code.
  2. Or move the wire from NC to NO.
  3. Set the pin HIGH in setup() before pinMode(pin, OUTPUT) so it doesn't click at start.

It worked if: The relay's LED is on only when it should be.

From how the part works. Explained from how the part works; not tried on a real circuit for this page.

Didn't help? Search another error or ask us.