3

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.

Steve Robillard
  • 34,988
  • 18
  • 106
  • 110
Darren
  • 143
  • 1
  • 4

1 Answers1

2

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.

Steve Robillard
  • 34,988
  • 18
  • 106
  • 110