SusaNET

Kevin Sangeelee

Raspberry Pi – Driving a Relay using GPIO
Posted on June 26, 2012 by Kevin Sangeelee

There’s something exciting about crossing the boundary between the abstract world of software and the physical ‘real world’, and a relay driven from a GPIO pin seemed like a good example of this. Although a simple project, I still learned some new things about the Raspberry Pi while doing it. There are only four components required, and the cost for these is around 70p, so it would be a good candidate for a classroom exercise. Even a cheap relay like the Omron G5LA-1 5DC can switch loads of 10A at 240V. A word of caution: don’t tinker with mains voltages unless you’re really (really) sure about what you’re doing. A mechanical relay allows a safe learning environment, since you can switch any load with it (e.g. a 9V DC battery/bulb circuit for testing), and the concept of a mechanical switch is very easy to grasp. A more efficient alternative to switch an AC load would be to use a solid-state relay (e.g. opto-coupled Triac), but it’s quite easy to make a wrong assumption and blow everything up with a loud bang and a big spark. I recommend sticking with mechanical relays until you’re entirely sure about what you’re doing. Tip: you can buy plug-in low-voltage AC power-supplies if you want to play with triacs.

The Circuit
There are four components to this circuit. A relay (5V DC coil), a BC337 NPN transistor, a diode, and 1K resistor. Essentially, the transistor is used to energise the relay’s coil with the required voltage and current. A relay will often have 3 significant voltage/current ratings specified; coil, AC load, and DC load. The most important to our circuit is the coil rating, which is the current at a specified voltage required to energise the coil (activate the switch), sometimes expressed as milliwatts (mW). The AC and DC load ratings relate to the switch-contacts, and state the maximum load current (e.g. for your lamp, motor, etc.) that can be carried at the given AC and DC voltages. DC loads are rated lower because they arc (spark) more, which eventually wears the contacts to the point of failure. In general, large loads need heavier contacts, which in turn need bigger coils to switch them, and bigger coils need more power from your circuit. Relays sometimes don’t fit easily onto a breadboard, so you might want to build the circuit on veroboard instead, or just mount the relay on veroboard and add two pins for the coil contacts (allowing you to breadboard it). Don’t ever put AC mains into your breadboard!

or you’ll short 5V to ground via the transistor when the GPIO is high.Schematic for a relay via GPIO on the Raspberry Pi The GPIO pin used in the example code is GPIO_17. and therefore also through the relay’s coil. for example. Although the pin is marked 3. through a 1K resistor (you may choose to increase this to 1. Take care to orient the diode correctly.3V from the GPIO pin. c) the actual hFE of the transistor in your hand.g. Most general purpose NPN transistors with an minimum hFE of say 50 to 100 could be used in place of the BC337 – it will depend on a) how much current you’re willing to draw from the GPIO pin. avoiding a voltage spike. base. so check the datasheet. This current is enough to saturate the BC337 transistor. I’d recommend you double check these two components before . since they vary wildly and the current gain could easily be significantly more than the stated minimum.2K if you want to be strictly below 3mA).3V GPIO pin is driving a 5V load – it could also drive a 24V coil. The diode in the circuit is there to conduct the current generated by the de-energising coil back across the coil (e. The pin ordering varies by type. take care to correctly identify the collector. when switched off).3V on the schematic. and emitter pins on your transistor. Similarly. allowing the power to dissipate more gradually. don’t confuse this with the 3V3 pin – I labelled it with the voltage to highlight that a 3. which appears on pin 11 of the Raspberry Pi’s 26-pin expansion header (opposite GPIO_18 (PCM_CLK) and beside GPIO_21 (PCM_DOUT)). b) how much current is required to energise the relay’s coil. Essentially. causing current to flow on the 5V rail through the transistor. to activate the relay. The choice of GPIO 17 was simply because I considered it less likely to conflict with other peripherals likely to be in use. all the circuit does is send a few milliamps at 3. if an appropriate DC power supply is used rather than the Raspi’s 5V line.

and brown is Ground. then a resistor (10K would do) between the base and ground would ensure the transistor is fully off. Make sure you keep the resistor in the circuit (e. If it’s likely to also spend some time as an input. The green wire connects from GPIO 17 (pin 11 on the Raspi’s 26-pin header) to the transistor base via resistor R1. The breadboard photo shows it wired up.powering up. You should hear a click as you connect/disconnect 3V3. Blue is 5V. You can test that the relay is working by disconnecting the wire from GPIO 17 (pin 11 of the 26-pin header) and touching it to 3V3 (pin 1). The pin numbering on my IDC plug should be though of from above the connector. to make it correspond with the 26-pin header numbering.g. rather than having a floating voltage applied. Using the relay via the ‘/sys’ filesystem Enable GPIO 17 access via the Kernel on path ‘/sys/class/gpio/’. Note that the circuit assumes the GPIO pin will be configured as an output. don’t just take a wire from 3V3 to the transistor’s base pin). and configure it as an output pin: - echo "17" > /sys/class/gpio/export echo "out" > /sys/class/gpio/gpio17/direction View the current state of GPIO 17: - cat /sys/class/gpio/gpio17/value Set the state of GPIO 17 by writing “1″ for high (relay on) and “0″ for low (relay off): - echo "1" > /sys/class/gpio/gpio17/value echo "0" > /sys/class/gpio/gpio17/value .

The usleep(1) call has been used to create a short delay before reading the LEVn register to feed back the pin status.c . */ #include <stdio. /* * gpio_relay.addr + 11) // Reserved @ word offset 12 #define GPLEV0 *(gpio. This is because the rise time for a GPIO pin (the time for the voltage on the pin to rise to a level that’s considered ‘high’) is around 100ns to 3V. The ‘high’ threshold is probably less than half that.org/licenses/> * * This is intended as an example of using Raspberry Pi hardware registers to drive a relay using GPIO. Use a * risk or not at all.addr + 3) #define GPFSEL4 *(gpio.addr + 4) #define GPFSEL5 *(gpio.addr + 14) #define BIT_17 (1 << 17) #define PAGESIZE 4096 #define BLOCK_SIZE 4096 . see <http://www.addr + 7) #define GPSET1 *(gpio.h> #define IOBASE 0x20000000 #define GPIO_BASE (IOBASE + 0x200000) #define GPFSEL0 *(gpio.addr + 1) #define GPFSEL2 *(gpio.addr + 0) #define GPFSEL1 *(gpio.addr + 8) // Reserved @ word offset 9 #define GPCLR0 *(gpio. * conventional ways of doing this using kernel drivers. but even if it’s 30ns. that’s 21 ARM clock cycles at 700MHz.addr + 13) #define GPLEV1 *(gpio. and is enough time to read the LEVn register before it has transitioned.addr + 10) #define GPCLR1 *(gpio.gnu.h> #include <fcntl. As far as possible. to use the C code instead.addr + 2) #define GPFSEL3 *(gpio. It’s all in one file for simplicity and for clarity.example of driving a relay using the GPIO peripheral on a BCM2835 (Raspberry Pi) * * Copyright 2012 Kevin Sangeelee. * Released as GPLv2. I've omitted anything that doesn't relate to the Raspi registers.Finally. remove the pin from the control of the Kernel driver: - echo "17" > /sys/class/gpio/unexport The C Code Alternative The C source code below shows how to drive the relay using the GPIO peripheral’s hardware registers.addr + 5) // Reserved @ word offset 6 #define GPSET0 *(gpio.h> #include <sys/mman. though there’s not much to it.

"on")) gpio_state = 1. usleep(1). (GPLEV0 & BIT_17) ? "high" : "low"). } p->map = mmap( . printf("GPIO 17 is %s\n". // Delay to allow any change in state to be reflected in the LEVn. void *map.e. if(!strcmp(argv[1]. else if(gpio_state == 1) GPSET0 = BIT_17. try checking permissions. return -1. return -1. // Some forward declarations. //////////////// // main() //////////////// int main(int argc. void unmap_peripheral(struct bcm2835_peripheral *p).. }. register bit. } /* Set GPIO 17 as an output pin */ GPFSEL1 &= ~(7 << 21). // Mask out bits 23-21 of GPFSEL1 (i. int map_peripheral(struct bcm2835_peripheral *p).struct bcm2835_peripheral { unsigned long addr_p. force to zero) GPFSEL1 |= (1 << 21). int mem_fd.\n"). // Done! } // Exposes the physical address defined in the passed structure using mmap on /dev/mem int map_peripheral(struct bcm2835_peripheral *p) { // Open /dev/mem if ((p->mem_fd = open("/dev/mem". "off")) gpio_state = 0. char *argv[]) { if(argc == 2) { if(!strcmp(argv[1]. O_RDWR|O_SYNC) ) < 0) { printf("Failed to open /dev/mem.\n"). int gpio_state = -1. } if(map_peripheral(&gpio) == -1) { printf("Failed to map the physical GPIO registers into the virtual memory space. unmap_peripheral(&gpio). volatile unsigned int *addr. struct bcm2835_peripheral gpio = {GPIO_BASE}. // Set bits 23-21 of GPFSEL1 to binary '001' if(gpio_state == 0) GPCLR0 = BIT_17..

This entry was posted in Technical Stuff and tagged Electronics. raspberry pi./gpio_relay off low Note: there was an error in the original example code. } The code can be compiled and run with root@pi:~# root@pi:~# GPIO 17 is root@pi:~# GPIO 17 is gcc -o gpio_relay gpio_relay. close(p->mem_fd). return 0. BLOCK_SIZE. BLOCK_SIZE). NULL. raspi. Tutorial on Relays – a good beginners tutorial on relays by The Electronics Club. 38 Responses to Raspberry Pi – Driving a Relay using GPIO . // File descriptor to physical memory virtual file '/dev/mem' p->addr_p // Address in physical map that we want this memory block to expose if (p->map == MAP_FAILED) { perror("mmap"). Tutorial on Transistors – a guide to transistors by The Electronics Club. } void unmap_peripheral(struct bcm2835_peripheral *p) { munmap(p->map.wiki page that gives more details on GPIO (and more). BCM2835 Datasheet PADS Addendum – additional registers to configure the GPIO peripheral.c . Bookmark the permalink. maybe you’ve got the original code. My I2C RTC Example – Gives some info on using mmap() to access IO Peripherals./gpio_relay on high . If the pin fails to go high. among others. hardware. References BCM2835 Datasheet – abbreviated datasheet for Broadcom SoC.). and has other references to Gert Van Loo’s work. PROT_READ|PROT_WRITE. return -1. where it was initialising GPFSEL0 rather than GPFSEL1. p->mem_fd. RPi Low Level Peripherals . MAP_SHARED. } p->addr = (volatile unsigned int *)p->map.

2012 at 10:56 pm Loved this post. 2012 at 10:46 am Great post. I was impatient and only had Maplin to hand so I used N18AW relay. I got from Maplin: QR40T – 2N3904 transistor RP68Y – 6V 10A PCB Relay QL76H – 1N4004S diode M1K2 – 1K2 Metal Film 0. a cheap 1. 2012 at 6:58 pm Ah yes. I am making a build notification tool (lava lamp & buzzer alertion system .Phil Lavin says: June 29. a cheap diode. All mounted on some stripboard. 2012 at 8:03 am Great post. Knocked one of these up last night – works a treat. the noble aims of the Raspberry Pi Foundation celebrated with such enthusiasm :) Reply mike says: July 9. 2012 at 11:57 am The diode happened to be a 1N4004. Was just over £3 in total.2Kohm resistor and a 2N3904 transistor. . Reply Simon C says: July 28.6W Resistor Hope this helps anyone else :) Reply Steve White says: August 19. Plan to make a Raspi controlled beer o’clock alarm for the office :D Reply Kevin Sangeelee says: July 3. thanks Reply Kevin Sangeelee says: July 9. 2012 at 1:52 am What’s the diode you used? Great post. Thanks to Simon C for the exact parts details.) The parts I used to build this. I just used what was handy at the time. but most diodes would do (voltage and current conducted aren’t high when a 5V coil’s field collapses).

Reply Mike Kelly says: September 8. you just need to read the LEVn registers (see datasheet) to get the actual level on the pin. Reply Adrian says: September 28. See another post I wrote here (http://www. any board that accepts 3. but a darlington array should be ok. and a separate power source provided if they exceed. then there are numerous cheap options available – in fact.susa. and would reduce the current requirement from the .net/wordpress/2012/07/raspberry-pi-gpfsel-gpio-and-pads-status-viewer/) for an example – you can either compile and run from the shell. 2012 at 6:05 pm I’ve not used that chip. such as uln2803 (which is basically the same thing. they look like they will do the job. Reply Michele says: September 12. The power requirement of the relay coils would need to be known.3V though. it’s worth pointing out that if you just need relay control and aren’t interested in learning how to do the electronics stuff yourself.3V as a ‘high’ signal will work directly with the Raspberry Pi’s GPIO outputs. 2012 at 5:52 pm I’m wondering if all this will work with a darlington array. 2012 at 8:39 pm Yes. the power available from the Pi. or use it as an example to incorporate into your own code. we’ll see :P Reply Kevin Sangeelee says: September 28. You can get from 1 to 16 relays. in total.. 2012 at 8:36 pm Hi! Nice word… Just a quick question… Is there a way to check the status of the gpio line using C language? I’m a total noob in C (but a great programmer in Delphi/Lazarus :P) Reply Kevin Sangeelee says: September 12. 2012 at 11:59 pm Thanks Mike – yes. Google for “Relay Module Switch Board For Arduino” Mike Reply Kevin Sangeelee says: September 23. in an IC) it’s a bit of a risk to see if the uln2803 will work at 3. 2012 at 10:19 pm Relay modules for Arduino coat about $1 per relay on eBay.

or mA – convert between them using Ohm’s Law). If you have a 40V DC supply to energise a 30V DC coil. the ULN2308 IC arrived. Reply Adrian says: October 22. Richard. Regardless. DC stuff (LEDs. 2012 at 12:44 pm yes. you can drive motors and coils directly from the IC. Reply Kevin Sangeelee says: September 30. 2012 at 3:46 am Hi Kevin I am attempting to use my Pi and this circuit to switch a garage door opener (GDO) with a 30V DC coil relay. .GPIO pins. Also. but in terms of energising a DC coil as per the post. I have been using a SY-4080 SS Relay as a test relay (before connecting to the GDO) as it accepts 3V-32VDC – but will only trigger when I supply 5V. mW. it works perfectly :D 8 relays with one IC. When I connect this/your circuit but provide 30V from the Relay (instead of 5V from the Pi) it does not want to work. you need to ensure that your transistor can switch the load required of the coil (given either as ohms. your DC power-supply grounds must be connected. not bad. Your advise please. I don’t want to give advice on switching mains level voltages. As you’ll be aware. The GDO provides a Common (ground) and Relay (30V) connectors which when connected trigger the AC motor to open the door. without even the need of a relay. motors. then the ground of this supply would need to be connected to the ground of the Raspberry Pi’s supply. 2012 at 6:14 pm Just to let you guys know. 2012 at 10:22 am Hi Richard. Also. they can provide enough current to drive most general purpose transistors for switching relay coils. I have also tried a test of a 12V and no luck. 2012 at 6:50 pm Good news. Reply Adrian says: October 29. so they are necessary. but bear in mind that a line-driver will only switch DC loads. Reply Kevin Sangeelee says: October 22. obviously). and at whatever voltage i choose to input to the IC Reply Richard Stent says: September 30. the C-E voltage rating must be greater than the requirement of your coil. etc) already work nicely. I’m planning to use the relays on home appliances and lighting (AC.

I am learning lots … but feel free to comment if I still don’t seem to get it. 2012 at 9:41 am Hi Kevin Thanks for your reply. :-) Your site is very enlightening. 2012 at 4:07 am Hi Kevin Yes. it is working now using the Pi and the (R) and (C) connections as you advised. then connecting R to the transistor’s collector. Thanks for your help. You’re essentially doing what the GPIO pin does when it goes high and low. The voltage across R->C is 30V. I’d try it first without the Raspberry Pi – just find a 3V3 or 5V supply. All that is contained inside the GDO. when using mains AC voltage. Yes. Reply Richard Stent says: October 1. Reply Richard Stent says: October 15. I measured the voltage and current across the contacts (using a multimeter) and is it reads 30VDC and draws 76mA. Reply Kevin Sangeelee says: October 1. connecting ‘relay’ (R) and ‘common’ (C) results in an internal relay energising. Thanks for your help. whereas 30V DC contact rating would be very common. . Don’t forget to join your ‘common’ and ground too. and make that audibly click before moving on to anything else (and certainly before trying to control any domestic mains circuits). I would think that I am trying to connect to (switch on) a 30V DC ‘contact’ as it is currently activating the relay/switch (inside the GDO) when the common and relay are briefly touched. Rest assured I am going no where near any AC mains level voltages. C to the emitter and to the Raspberry Pi’s Ground should be enough to drive the internal relay coil. Regards Richard. If so. buy a relay with a 12V coil. so if it works. I’d recommend you find a 12V DC power-supply. 2012 at 12:45 pm If I understand correctly. Richard. I now believe I need a mechanical relay that has a 5V coil (powered from the Pi and energized with the BC337 NPN transistor) that will allow me to switch this 30V DC contact load briefly (via GPIO on/off commands from my Pi program). connect a resistor to the transistor’s base and then connect the other leg of the resistor alternately between +ve and ground of your supply. then it should work fine with the Pi. and the current through R->C is 76mA. A mistake or misunderstanding on this. I suspect that you’ve confused the contact rating (the switch) with the coil rating (the bit that flicks the switch) – a 30V DC coil would be very unusual. could easily kill your Raspberry Pi (and quite possibly even yourself).However.

Away on a ski holiday at present so apologies for the delayed reply. 2012 at 3:05 pm More of the same really. which is why the transistor is required. I’m a total noob.Reply richard says: October 9. and using GPSETn and GPCLRn bits to set and clear the bits that relate to the pins you want to control. Can you explain or (give some overview?) how one would customize this for each GPIOx. As best I can tell there can be 17 to 21+ GPIO’s available in the new 2. but: why is the transistor required? Can’t you just switch a (3V) relay with the 3. 2012 at 7:20 pm Hi. then you’ll understand what’s required. sorry if this is a stupid question. The transistor conducts a relatively large current when a relatively small current is applied to the base pin – small enough to be driven by a GPIO pin on the Raspberry Pi. 2012 at 10:19 am Hi Kevin Yes. Most small relays require between 50mA to 150mA to energise. thank you. Reply Kevin Sangeelee says: November 3. Will let you know how I get on in a week or so. a lot less than 25mA). Reply . For the C code. Reply David says: November 3. it’s just a matter of setting the appropriate GPFSELn bits to ’001′ (so the corresponding pin functions as an output). 2012 at 6:21 am Great outline. that is my way forward. Richard Reply Bos says: October 18. then you should be able to control it. You might try connecting the transistor to a different pin.0 512M boards. As long as you know which physical pin on the Pi is connected to the GPIO you’re using. The Bash approach makes it even more obvious – just replace 17 with the GPIO that you want to control. 2012 at 8:29 pm It’s a perfectly reasonable question – the answer is that you can drive directly from a GPIO pin if you can find a relay that will energise with the current that the GPIO pins can supply (e.3V output from the GPIO pin? Reply Kevin Sangeelee says: October 18.g.

and if so you might need to prevent them loading (e. Wrote about it at http://saranga2000. others are I2C. we configure the required pin as a GPIO Output. Reply David says: November 4. all the information you need is there to extend this. Reply Vinod says: December 7. is GPIO Input. of course. etc. and at a specified frequency – commonly used to generate a variable average voltage or to drive servos. Can all the pins on the RPi be used – 17-21 like David says above? Most forums seem to indicate that only 5 odd are GPIO pins. need to be capable of energising 16 relays simultaneously.g. An enhancement might be a darlington array chip to provide multiple high-gain transistors in a single package – neater than 16 x 3-pin transistors. through a web interface – in about 30 minutes flat. PWM and other types ( I have yet to understand what these are)./gpio_relay 17 on ie . and thanks to webiopi.Vinod says: December 7. Reply Kevin Sangeelee says: December 7. I believe that the default state for any pin.com/watch?v=8X6PgYaegz0 . The I2C and SPI peripherals are just for serial communications. In short. Certain kernel drivers will reconfigure pins if loaded. I plan to try out switching a simple led with a 5v relay before moving on to switching on AC circuits at home. 2012 at 9:38 am Thanks for this post Kevin ( most detailed one I saw on this topic anywhere online). it would be awesome if you can post a detailed tutorial like this one on driving a 16 channel 5V 10A relays using the RPi – something like http://www. PWM (Pulse Width Modulation) peripherals generate high/low pulses of a specified width. 2012 at 5:28 pm Thanks for the detailed reply Kevin – was most useful. other than the UART. so it’s more of an ‘exercise for the reader’ . read the datasheet to understand how the function-select bits work for each pin.) are is connected to (is active on) a pin. for example so that is might work like . The GPIO function select registers determine what peripherals (I2C.-) Between the datasheet.youtube. most of the pins on the P1 header can be used for GPIO (some on other headers can be used too). over the next couple of weeks. A 16 channel driver is really just more of the same as what’s here (and written elsewhere). As a starting point. For our application. the schematic and the code.com/2012/12/07/raspberry-pi-hello-gpio/ . SPI. 2012 at 11:17 am Hi Vinod. 2012 at 10:33 am With respect to the C code above would it be possible to alter the code to take a variable input into the command line. unless you take steps in software to stagger them. PWM.only as a thankyou to all the Giants (including you) on whose shoulders I stood today. I got the led on/off via GPIO working today.wordpress. blacklist them)./gpio_relay x on where x is the particular pin being controlled? Reply . The power supply would. and helped me be a little more confident as I wired up a led today ( without worrying about using/messing up a wrong pin).

to make sure that the transistor is reaching saturation – you could use your 470R instead.Kevin Sangeelee says: November 4. 2012 at 2:51 pm Hi Kevin. removing the diode. Thanks :-) Reply Vinod says: December 12. You might also try a another transistor. You can use the printf() function to display the parameters if you want to experiment a bit. Is this it? Or am I doing something else wrong? If former. 2012 at 10:49 am Great post for beginners like me. 2012 at 11:17 am Hi David. I did some debugging and saw that: 1. yes it’s easy to get at parameters from the command line – define main with ‘int argc’ and ‘char *argv[]‘ parameters (for reference. BC547B transistor 2.freeshell. Reply . Circuit and Relay spec pics are here: http://kannvin. what should I do different to drive the relay. What am I doing wrong – the only thing I can think of is the BC547B is not able to power up sufficiently to turn on the 6V relay. Please help. which contain the ‘count’ and ‘values’ of parameters respectively. and passing the 5v through a 470ohm resistor through led 2. I used 1.3V pin.net/wiki/doku. Reply Kevin Sangeelee says: December 12. 1N4007 diode 3. even among transistors of the same type.php?id=personal:journal:2012-12-12-144621 I don’t get the clicking sound with the base connected through a 1K ohm resistor to the 3. 2012 at 3:00 pm You can try using a lower value resistor to the base. Reply Pingback: Getting Started w ith My Raspberry Pi – Part 1 : Blog Post Survey | Lasse Christiansen Development Michael Horne says: December 7. the relay itself is working – i get a clicking sound if I connect the 5v pin and ground directly to the leads of the relay. Ive been trying to get a circuit like above ( controlling a relay with the GPIO) to work. I wired up the exact same circuit but with different parts ( using what I had with me). Note your link returns ‘permission denied’. I am able to light up a LED through the same circuit. a local relay I got in a kit – that seems to indicate its a 6v relay ( pic attached). the RTC post has source-code that uses these). since the actual gain varies wildly.

enough to drive an LED but not enough to drive a relay). 2012 at 11:59 pm Thanks for posting this! Great place to start for a noob like me. 2012 at 12:06 am This is nicely explained in the “Tutorial on Relays” (linked in the References) – “Current flowing through a relay coil creates a magnetic field which collapses suddenly when the current is switched off.php?id=projects:rpi . The protection diode allows the induced voltage to drive a brief current through the coil (and diode) so the magnetic field dies away quickly rather than instantly. and consider that a bipolar transistor is made from two diodes – there are plenty of sources on the net that will explain the details better than I could. It works now.freeshell.net/wiki/doku. Reply scott says: December 19. Thanks for your prompt help Kevin. just not so well (hence a small current flows.” It’s still required for a darlington pair. So it will work similarly when connected in reverse like you did.Vinod says: December 12. To understand more you need to read about doping of diodes. The sudden collapse of the magnetic field induces a brief high voltage across the relay coil which is very likely to damage transistors and ICs. Can you please explain the purpose of the diode in this configuration? Would the diode still be required if a darlington array were used? Cheers! Reply Kevin Sangeelee says: December 20. but not a perfect symmetry. . Glad you figured it out. The relay spec and circuit should now be accessible at http://kannvin. 2012 at 5:18 pm There’s a symmetry in an NPN transistor. Although interestingly I was able to light up an LED even with the E & C swapped. Reply SusaNET Proudly powered by WordPress. This prevents the induced voltage becoming high enough to cause damage to transistors and ICs. because there’s still a transistor driving the relay’s coil. Reply Kevin Sangeelee says: December 12. 2012 at 4:09 pm I just figured out what the problem was – I had the Emitter and Collector swapped. A higher current through the base may actually drive it to saturation.

Sign up to vote on this title
UsefulNot useful