I have a circuit which uses an ATtiny85 output to a transistor (S9013), which will trigger a relay that controls a motor.
The reason for the transistor to relay is because I do not have a transistor that can take the current of the motor, so I am isolating it with a relay.
While I can purchase all these, it will take time to ship.
Here is the circuit:
SCHEMATIC NOT UPDATED, I HAVE A DIODE GOING ACROSS THE MOTOR, AND A 100uF CAPACITOR GOING ACROSS THE VCC AND GND TO SMOOTH OUT THE VOLTAGE (have also tried 100nF).
Everything works if I don't connect the motor OR if I isolate the motor with its own power source.
The issue now is that when the motor is switched on, there is a massive voltage drop and the ATtiny85 will reset. Here is a waveform of the motor trying to turn on three times:
Is there a way to prevent this drop or at least reduce it to a point where the ATtiny85 won't reset? I'm thinking wire up a simple voltage regulator but not sure if the added complexity will introduce other issues. I also know I can go out and buy a motor or voltage regulators but let's avoid that option.
EDIT: so as per the answer, a diode (cathode at +ve, anode at VCC) was added between +ve and VCC, assuming that there is a capacitor connected in parallel with the ATtiny85 (+ve end at VCC, -ve end at GND). Theory is that the cap gets charged while the motor is off to VCC. When the motor turns on, it's going to drop that voltage down to below VCC and the diode is going to be reverse-biased and prevent any conflict from the supply to going into the ATtiny85. The capacitor can now freely discharge into the ATtiny85 without the supply affecting it (without the diode, supply will average capacitor down faster than if it would just discharge alone). For reference, the bulk capacitance value I used was 100uF.