Turn around transistor. To swap outer pins.
The 2N7000 is not a PNP as shown in the schematic but is the Nch FET which also has a inward arrow like a PNP but polarity so the arrow is Gnd and you have it reversed.
The gate is active high impedance with 60pF input with inverting output Drain switched to gnd.
This voltage controlled switch which will drop < 0.5V with 7 ohm switch with Vgs>4.5V This is because Relay has a 70 Ohm coil, so 9% of the voltage is lost, but still sufficient to drive the coil.
All DC coils and open switched inductance needs a low resistance reversed diode across the drain-source switch to turn off the current slower and not raise the voltage rapidly trying to sustain the voltage.
V=LdI/dt where dt is very small >10ns with 25 pF Coss and “dI” is from 70mA to 0V turning off this coil, V=L 70mA/10ns or 7kV per uH.
- R3 =1k * 70mA limits the voltage to 70V, is no good
- always use a diode with low resistance or rated for more DC current than being used
such as a reverse 1N4001~...5 diode with a few Ohms when activated turning off the FET clamps the voltage to 0.6+ 70mA * 2~3ohms=0.8V max above Vcc=5V .
A 1N4148 might be 1.2V above Vcc and switch faster causing more EMI due to 10x higher resistance or lower current rating.
dt is increased with a lower resistance shunt diode. Thus it slows down from 10ns to about 100us Since decay time T=L/R which depends on coil inductance of several hundred uH or so or roughly 300uH/3 Ohms= 100us.
This current decay time or coil -ve rise time translates into a noise spectrum.
Where \$dt=0.35/f\$ for an impulse noise continuous spectrum up to 0.3 MHz.
This can inductively couple radiated noise into loose Rx channel wires or close tracks. It can also conduct noise share by the data ground = 0V line.
conducted noise needs a cap between coil Vcc and FET 0V as close as possible to switch.
- radiated noise lines should be paired or low impedance tracks or twisted pairs and same for data lines , preferably not bundled together and at right angles to coil current path.
a supply cap nearby will help attenuate this garbage also, along with diode and twisted pairs as long as not too big.
- C> Ic * dt/dV=70mA * 100us /5V = 35uF. But if close to supply it may not need to be so big.
You can also get conducted noise garbage on the ground lines if shared by the path of coil current rather than separate gnd and Vcc to supply.
- the Vcc loop to coil path area creates a B field as a loop antenna of this switched inductance, so keep the area between the paired power wires small.
Hopefully your LED still works after this as -5V =Vr max would be exceeded without the diode from the LED cathode rising 70V above the Vcc with Rs in series.