Simple relay question


Can anyone tell me how I might go about wiring this relay directly to the photon?

Would it be something like D0 in and GND out? I’m thinking about using it for an alexa controlled extension cord, unless anyone has any better suggestions on the hardware (UK 240V 13A rated).

Also, should I use a transistor of some kind to control the IO rather than running it straight from the D pin? If so, how and what kind would be best?



I usually use a transistor for that. I have a setup with a couple of relays like yours and when I tried to wire directly from photon to relay, it didn’t work.

Thanks Suriken, which wires did you put to where? I’m not even sure where to begin (I don’t want to blow up my Photon).

I usually follow this scheme:

And abd137/139 as the transistor

1 Like

It is an SSR, so you do not need all that @Suriken suggests . They don’t behave like a coil relay (note his flyback diode). They are more like a transistor and typically have opto-isolation.

I guess it really depends on how much current the SSR sinks and if your Photon can sink/source enough. I’d check to see how much current the SSR needs at 3.3V.

1 Like

Will do. Assuming it can handle it, how would you go about wiring it up?

I tried that because I also thought it should work. But in my case, that relay with a photon didn’t work at all. I think it needs more current that photon can supply.

In case a transistor is needed, you say that the diode is not neccesary? I never tried that, but it could be good if I can remove it from my designs.

@BulldogLowell, the specs show a 15ma max draw on the opto input to the SSR. A small current limiting resistor from the GPIO to the control input would be good.

@Suriken, don’t confuse a Solid State Relay with a coil relay which is what you have. SSRs have low current opto-isolated inputs and don’t use electrical contacts.

@peekay123, I have exactly the same SSR ( I also have some normal relays). I tried to connect directly to a digital pin of my photon (also with a resistor). It didn’t work. That’s why I used the same schematic as I use with normal relays. I didn’t know about the diode, but I will remove it from my schematics for the next design.
But I do need the transistor to make it work.

@Suriken, odd as I have used one without. What size resistor did you use?

Nonetheless, a transistor never hurts! In your circuit, the flyback diode can be removed and the relay replaced with a resistor from Vin of the Photon to the SSR + input and the other to the collector of the transistor. A 220 ohm, 1/4 watt resistor would be fine.

Without a transistor, a 100 ohm resistor from a Photon GPIO pin to the + input of the SSR and the other to GND should work.

@peekay123, 1k is what I use in all my relays. Damm it, that’s very odd. I remember reading it had to work as you said but when I tried it didn’t. I tested with a couple of arduinos to see if it was my photon and same behaviour . So in the end I went back to that schematic. You say 220, maybe 1k is too much? I will test this weekend just for curiosity.

It could be the relay, but it has been working ok for the last 8 months.

@Suriken, the input of the SSR is a photodiode. These are current driven devices (as long as the voltage is high than their breakdown voltage and does not exceed their limit). Driving directly from a GPIO would use a 100 ohm resistor. At 1K ohms, the current would not be enough to light the LED and trigger the SSR.


@peekay123 and @Suriken, I tested this with my relay which is a SSR-40DA. As far as I can tell from the data sheet, this has the same input characteristics as the SSR-25DA that @timtiernan is using. The data sheet shows a resistor already in series with the input LED, though it doesn’t state what value it has. When I test with a 100 ohm resistor between the Photon pin and the relay, it does not turn on completely; testing with a 1500 watt hairdryer, it was clearly running at low speed. When I tested with a 43 watt halogen bulb, it blinked off and on. Testing with the relay connected directly to the Photon pin appears to work correctly; I couldn’t discern any difference in speed of the hairdryer powered that way or directly plugged into the wall socket. I tried to measure the current being sourced from the Photon pin with no resistor, and it was around 5 ma, on the 32-320 ma scale of my multimeter and 1500 ua on the 320-3200 ua scale, so I’m not sure what that means. The voltage across the input terminals of the relay was 3.25v with no resistor, and 2.97v with the 100 ohm resistor.


@Ric, thanks for some great testing! The datasheet I looked at had no resistor showing. Nicely done :+1:

On a slight tangent, be aware that many of those “SSR’s” on eBay are fakes, they work but crack one open and inside you will find an opto islolator and a Triac rated nowhere near the 25A claimed on the outside. Still worth £2 either way …