I hope this is the right place to ask this kind of question.

I'm quite new to this, so I expect there is a simple explanation.

Basically, I have a small electro magnet (the type from an old doorbell) and when I take the 3.3v pin from the Raspberry Pi and connect that to one of the wires of the electromagnet, and then touch the other wire with a connection to ground, the electromagnet operates as expected.

However, when I take the positive voltage from a GPIO Pin instead of the 3.3v pin (I tried both 23 and 24 in this case) it appears not to work when I set the voltage high. Connecting it to a breadboard with an LED lights the LED fine, but connecting it to the electromagnet does not work -- it's as if, for some reason, the GPIO connection doesn't like it and doesn't let the voltage flow? Measuring it on the magnet with a voltmeter shows a small (tiny, barely noticeable) voltage change.

Apologies for getting any terminology wrong etc., but hopefully that makes sense.

Any feedback hugely appreciated.


1 Answer 1


I believe the problem is the max amount of current (3 mA) that can be provided by the GPIO pins vs. the 3.3 volt pin (50 mA).

Second you should not directly power an inductive load (electromagnets, motors etc.) from the GPIO pins because when you remove the current it can back feed EMF through the GPIO pin, and fry the pin or Pi. Instead you should use a transistor or an IC like the ULN2803 to switch a separate power supply that will drive the coil in the electromagnet.

You mention:

Measuring it on the magnet with a voltmeter shows a small (tiny, barely noticeable) voltage change.

Are you using a digital meter? If not I would suggest getting a digital meter.

  • I believe the maximum current on a GPIO pin is 16mA, with a total maximum of 50mA across all used GPIO pins. The max current on the 3V3 pin is indeed 50mA.
    – Phil B.
    Oct 2, 2015 at 0:45
  • @PhilB.I saw some conflicting numbers so went with the lower of the two. I also saw 17 mA and I linked to the other question because it had more details than I wanted to type. Either way the root cause of the problem is the same. Oct 2, 2015 at 1:05
  • Excellent, thankyou. I knew it would be something like that, but just wasn't sure of the detail. I will certainly give that a go and stop trying to fry my pi. I only have my old analog meter from when I was a child, I've been meaning to get a digital one. I have another question about this same project but will post it separately. Many thanks again. D.
    – Darren
    Oct 2, 2015 at 6:18
  • So, you'll be pleased to know I finally got around to getting a digital meter ;). I've now introduced a transistor (2n222) between the 5v pin and the electromagnet, with pin 24 of the pi on the base of the transistor. However when I turn pin 24 high I still only seem to get 1.25 volts across the electromagnet? Thanks again.
    – Darren
    Oct 24, 2015 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.