enter image description hereMy previous questions have been anwsered, so thank you all for that!

I make a new question post because I have some other problems with my setup. I use a esp12s 8266 chip. It sends a PWM signal to a n-channel mosfet, so I can regulate the speed of the dc motor that is attached to the drain of the mosfet. The DC motor has extra power from a 9v battery and this battery negative is connected to the GND of the 8266. I can control it with bluetooth hc-05 module, it has 3 options, 40%, 0% (off) and 100% (full power).

Here's the problem: I can control everything and it seems like it works all fine, but when the motor starts spinning I see a yellow led flashing on my 8266 chip and I can't control it anymore. I read about backvoltage from the motor. So I think maybe the backvoltage is causing the chip not to function anymore. To make it work again I need to disconnect and reconnect the chip for it to work again.

So my question is: could this be the backvoltage or something else? And if it's the backvoltage how do I need to connect the diode (1n4001) in this circuit?

I read when a motor stops then the backvoltage happens, but in my case the led on the 8266 starts flashing when it spins. So maybe I hooked something the wrong way. here I have some pictures of the different setups I tried.

Of course I will solder everything nicely, but for now it's just to get a quick impression of the hookup.

Hopefully someone can help me out, thanks in advance!

Version 1

Version 2

  • More likely your weak 9v battery is unable to supply enough power.
    – Majenko
    Aug 20, 2019 at 10:15

3 Answers 3


I read when a motor stops then the backvoltage happens,

That is not true. With a brushed DC motor the back-EMF ("backvoltage") occurs at least twice (often more, depending on the number of commutator segments) per revolution of the motor. Brushed DC motors are very noisy.

While you can use a diode (connected as you would for a relay) it's not the best solution. Instead you really need a proper EMI-absorbing circuit.

This consists of three capacitors - all very small values, in the range 1-10nF, which connect all parts of the motor together and bleed off any induced voltages safely.

The first capacitor connects directly across the terminals. This will safely remove the back-EMF created in the windings as the voltages switch back and forth due to the rotation of the commutator.

The other two capacitors each connect from one terminal to the metal housing of the motor (one to each side of the housing). This will safely couple the housing to the rest of the circuit and cause it to act as a shield containing the magnetic fields better within the motor.

  • Thank you. I will try this out and let you know if it worked! I also added another picture that I found on the internet. On the picture you see between the negatief en positive of the motor there is a little capacitor 1uF ceramic capaciter. So you say I need to connect it like that right? and also one on the negative to the housing and the positive to the otherside of the housing, right? :)
    – Bart
    Aug 20, 2019 at 13:25
  • Yes, that's right. The housing-connected ones are less important than the one across the terminals, but still recommended if you can.
    – Majenko
    Aug 20, 2019 at 14:14
  • Thank you! I don't have the blinking Led on the 8266 and no data noise!
    – Bart
    Aug 22, 2019 at 19:25

You're looking for something called a "flyback diode."

What happens is, during "normal use" (when the DC motor is being powered by the system), you have a DC motor. But, when the system stops giving input, and the DC motor "spins down," it can become a power generator -- generators and motors are actually very much the same, it just depends on if they're generating the power, or using the power.

The idea with the flyback diode is that it doesn't let that generated current "back" into the system, and burn up your MCU. I've seen them in series with a small resistance, to help quickly bleed off any current/voltage the DC motor ends up generating. With it in series, the diode stops any power from being "wasted," as current will never flow "backwards" through the diode, and thus the resistor.

When you "cut the power" to the DC motor, current can then flow through the "mini-loop" and decay through the resistor (which is not pictured in this example).

  • Thank you, it gave me a better understanding of a dc motor!
    – Bart
    Aug 20, 2019 at 13:20

Okay, I'm not sure what you're trying to accomplish, electrically, but the diagram you added doesn't make sense. It also doesn't match any of the pictures you've posted. In the diagram, you have your emitter and collector tied together with a diode... but your pictures don't have ANYTHING attached to your emitter leg... you have things "wrapped" around your heatsink/ground, for some reason?

So we'll ignore the pictures that don't make actual circuits, and focus on your diagram. In the diagram, you've accomplished this:

enter image description here

If you look at this, the diode is doing nothing -- your BJT already has Miller resistance between the emitter and collector, so the diode does nothing for you, here. You also don't need any capacitors, as you are not looking to store any power, for any reason. Because of this, I've changed it to a resistor (R4).

What you're really looking for is something more along these lines:

enter image description here

With this, your 9V battery will only power the motor when the BJT is on (your Pin10 is HIGH). This completes the circuit, and current flows through your motor. The diode (D1) prevents any current from flowing through the resistor (R2), and no power is lost.

When you turn your motor "off" by setting Pin10 to LOW, kinetic energy will cause your motor to "continue spinning" a little bit -- it's not going to just stop dead, since that energy needs to go somewhere. This little bit of remaining spin turns your DC motor into a DC generator, and it provides its own power. This current/voltage needs to go somewhere, or you'll burn things up.

This is where the diode (D1) and resistor (R2) come in handy. That current can now flow through the mini-loop, and bleed-off this induced power -- or flyback voltage spike -- which is why it's called a "flyback diode." You're trying to bleed-off that power, not store them, so you need a resistor instead of a capacitor.

So lose the caps, substitute with a resistor, and move your flyback diode.

  • I am sorry I was not clear about the diagram, I don't use the diagram. I only wanted to point out that the guy from the diagram used a capacitor. So I am not using a BJT but a mosfet. I don't know if that makes a big differents. Also I can't read a circuit diagram, well only the very basic ones. So I didn't really understand what you mean only a small portion of it. I will first try the capacitor and if it not works I can always dive deeper in your story, so thanks!
    – Bart
    Aug 20, 2019 at 15:44
  • @Bart BJT's and MOSFETS are both transistors, one is a voltage-controlled voltage source, the other is a current-controlled current source -- Either way, you're connecting to the heatsink (the big plate) and not the collector. You're not making a complete circuit in either of your pictures. I would recommend you understand how basic transistors (BJT's and MOSFETS) work before you try to wire them up -- you have not made any complete circuits, and I'm surprised your motor is spinning at all. Aug 20, 2019 at 15:53
  • I followed a part of this video youtube.com/watch?v=T9Zpir5hidw&t=100s
    – Bart
    Aug 20, 2019 at 21:18

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.