Spark with relay 3 vdc

I got a 3 vdc relay which has 5 pins. 2 pins to switch relay. 1 common. No and NC pins. I can switch relay if I connect to gnd and 3.3v but if I connect to gnd and digital pin it will not switch. I am software guy and not to good with hardware

The relay coil used to activate the switch requires more current than what the microcontroller pins can provide. (Usually 20mA)

So you will need 2 things:

  1. transistor
  2. free wheeling diode


1 Like

I thought that may be the problem. Could you give me a simple circuit diagram and if possible some part numbers for the parts. Sorry to be a pain as I mentioned I am a newbie to hardware

No worries! we are all here to learn. I’m also noob in many areas but just keep learning :smiley:

You can see the schematics for the shield shield as reference:

In general, use find a NPN resistor which you can easily get hold of and just make sure it can handle sufficient current the relay might draw.

If you have the datasheet of the relay, we will be able to advice :wink:


Your help is much appreciated. Attached is the datasheet for the relay I am using. Don’t know how to attach pdf doc so I just added a link

Ah nice.

I took a quick look so 2 things:

1.) We should go for the model with lower power consumption.

HRS4H-(S) 5V

The current will be around 72mA based on the 360mW power mentioned.

2.) A typical transistor like 2N2222A will be suitable to do the switching.

As for the free-wheeling diode and gate resistor, I can also check up a suitable one if needed :slight_smile:

@fletch, @kennethlimcp, I have to ask as to why you would not go with a relay breakout like this one on ebay? Using the 3.3v rail for powering your relay is not a good idea since Spark’s onboard regulator is not able to provide a lot of current for peripherals. With a 5v relay driven by 3.3v logic, you can use the USB 5v supply via the Vin pin and have plenty of current to switch one or more relays. You could even power the relays (coils) with a separate 5v supply. :smile:

1 Like

Yeah that’s why i suggested the 5V version of the relay :wink:

Thanks. I thought being a 3 v relay I could just connect it straight to a digital pin but unfortunately, I was wrong and i purchased 5 of the darn things, but will try and exchange for 5v. I see now that the current is more important than the voltage.

1 Like

Thanks peekay123 those relays on eBay look good will order but delivery 12-24days. For now I am really keen to play, so I want to try and make something up

@fletch, the existing relays will work but you will need a seperate 3.3v supply for them since the Core’s regulator can’t supply enough current. The same goes with the 5 relays, if you get them.

In either case, you will need some transistors to do the switching, some diodes to protect against inductive kickback and some resistors. Let me know how you want to proceed :smile:


Great thread-saved me from buying the wrong parts!

So it sounds like there’s some internal transformer that regulates the input voltage to output 3.3v with a small amount of amps max, so the digital pins don’t have enough juice to enable a relay even if it’s a 3.3v input relay.

Does this “not enough juice” problem also apply to the 3V3 pin?

I’m wondering if I can hook up D0 to a transistor which drives current from 3V3 to a 3.3v relay, or if it will be lacking the power to enable the relay.

I’m trying to avoid buying the spark shield as it’s too big to put behind my wall. I want to buy a single relay to power a light switch for my first project here, and I’d love to eliminate the need for a 2nd power supply just to get enough current to the relay.

3.3V is obtained from a 5v to 3.3v voltage regulator. As long as your USB power supply has sufficient power, there’s no issue.

The relay shield works fine and you can consider it!

Thx - so I think you’re saying that D0 doesn’t have enough amps output for a relay, but 3V3 does, so using D0 to a transistor can control on/off for 3V3 to power a relay.


I like the relay shield for my 2nd set of lights where there’s 4 switches all together, but for the first, I only need one relay so it’s overkill.

I had to look up what “inductive kickback” means despite my EE undergrad, but looks like the relays use an inductor to do the voltage transform, and turning them off quickly can throw a lot of juice back into the on/off switch, which in this case is connected to the 3V3, and could damage the spark core. So sounds like a diode between the transistor output from the 3V3 and the input from the relay would stop that.

Yes. a GPIO for micro-controller is 20mA in general. The relays requires like 70-100mA! This is a good point to note for micro-controllers. You will be required to use an external circuitry and the GPIO will only be involved to do the controlling portion.

You basically need to add a free-wheeling diode.


As the inductor stores some energy during the “on” phase, turning the circuit OPEN would momentarily disrupt the current flowing through. As such, the inductor will attempt to reverse it’s emf to continue supplying current.

The diode is there to serve as a path for discharging the spike current instead of allowing it to flow elsewhere, causing damage!

I learnt this at age 19 so there might be some wrong descriptions here :smiley:

1 Like

@jkucera, @kennethlimcp, I just need to clarify the 3.3V power stuff. Though the 3.3V is derived from the USB power (5V), the onboard regulator that supplies the 3.3V is limited to 500ma. Given that the CC3000 wifi module can take up to 350ma, that leaves about 150ma to play with.

Personally, I prefer using a relays that have 5V coils but are controlled with 3.3V logic. This usually means an opto-isolator and a transistor or a transistor alone to drive the relay. The reason for this is that the relays can be powered independently from the Spark or using the Vin pin which is supplied from the USB power.

Nonetheless, you should be able to drive a 3.3V relay with a transistor using the 3.3V line on the Spark.


@peekay123, just to confirm, you mean one should be able to drive a 5V relay with a transistor using the 3.3V line right?

Well, I’ve been struggling with this the last four hours. Google took me to raspberry Pi and Arduino forums, and took me a while to figure out if I had the right components.
As you can see in the image below I´m trying to drive a relay module, wich should already have those kickback protections, right? So would be merely a case of passing on the 5V?
So in the image’s wiring if I set D2 HIGH only the led of the relay will turn on. With the relay powered on the VIN and GND from the spark and the logic wire on a HIGH pin of the Arduino it clicked as expected, so the relay is ok.

Well, I have some 2N3904 transistors, 1k and 10k resistors; in my ressearch these were the most used components. Could someone help me with this? I really want to understand what is going on, so in the meantime I´ll study more about transistors.

@rodrigdjodi, when @peekay123 talked about 3.3V controlled relay, I guess he meant that there will be some control electronics between the Core and the relay.
Since I don’t know your pictured relay board (can you provide a type or datasheet?) I can only guess again, but your symptoms do suggest that there is no actual 3.3V control electronics there.
But this briliant post of @harrisonhjones should help you to use your components shown on the photo to achieve what you are looking for.
Since you are using a relay instead of a light source - as in the above link - there is need for a free-wheeling diode (if it’s not on the board already).

@ScruffR, that is exactly what I meant. A lot of eBay type relay module have opto-isolated front ends that work well with 3.3v logic while using 5v relays. Just a note, the diode may already be on the board. @rodrigdjodi, which relay breakout are you using?

1 Like

This one:
But I really don´t need more than 5A, it´s just what I had at hand for study.

Thank for the link @ScruffR, that simulator is really helpful. One of my difficulties with electronics is visualize the current path.

By the way, thanks both for taking your time and not reply “get a 3.3V module”. I feel encouraged.

1 Like