DC12V motor with arduino+esp8266 with one power
Large inductive loads are create power problems because of source resistance/impedance. Sources cannot supply an infinite amount of current and if you have a cable the inductance of the cable also 'blocks' current. 

When the relay switches on, it sinks a large amount of current from the source and stores it in a magnetic field (plus the load of whatever the relay switched into the circuit like the motor which is an additional inductive load). This creates a voltage drop because the cable and the inductor act like a voltage divider (on a small time scale). This causes a voltage drop and your processor to drop out. 

When the inductor is switched off the opposite effect happens. The inductor would create a near infinite voltage across its terminals when switched off from the magnetic field (less than infinite in real world because of parasitic effects). This causes an overvoltage condition which is why you have the diode to clamp voltages across the inductor. 

So to make your processor happy you need to make sure your operating within its voltage range at all times, which is 3.3V. You can't have a drop out even for a few ns below a threshold (probably less than 3 would be a problem, but I'd have to look that up and I'm lazy and that spec probably doesn't exsit for a cheap chinese part like the ESP8266. 

If you have an oscilloscope or know someone who has one, turn it to it's highest time resolution, set the threshold for 3.1V then turn the motor and relay on. You'll see a dip in voltage. The dip needs to go away. So what can you do about it?

1) Put a large capacitor on the 3.3V line near the regulator for the ESP8266 or the input of the ESP8266. Proabably on the same order of inductance of the relay or more. 

2) Use a large inductor in series with your power supply to source energy, not as good idea as the capacitor but would still work, this also needs to be near your load

3) Do both, if you do make sure the capacitor is on the load side.







simulate this circuit &ndash; Schematic created using CircuitLab