Thursday, September 8, 2016

45: Some Obvious info about Opto-isolated Relays

For isolated wiring:
- external 5v to Relay JD-VCC pin (the usual label) and GND
- digital Arduino pins to Relay IN1, etc.
- Arduino 5v or 3.3v to the Relay VCC (next to IN pins)

Isolation comes from NOT connecting GND from the Arduino.

Most switches are "normally open". This would not be my first choice.


See the relay photo.

Wiring A: 
Switch is initially OFF.
digitalWrite(pin, LOW) turns it ON.

Wiring B:
Switch initially ON (even with no power input).
digitalWrite(pin, HIGH) turns it ON.

Wiring B is appealing because HIGH = ON but having even a momentary initial ON is irksome.

So what I do is use Wiring A with the following #define's:

#define SW_ON   LOW     // digitalWrite(pin, SW_ON) -- turn ON
#define SW_OFF  HIGH    // digitalWrite(pin, SW_OFF) -- turn OFF

Otherwise, chaos!

P.S.: Essentially the same goes for Particle Photon and Raspberry Pi.

No comments:

Post a Comment