Activate 12 V Relay with a 5 V GPIO
The base current, if the GPIO input is actually at +5V, will be approximately (5-0.7V)/R.
You should pick the R to provide 1/10 to 1/20 of the DC current that the relay draws, according to the relay datasheet. That's a rule-of-thumb with a typical jellybean NPN transistor. If you study the transistor datasheet you can usually find Vce(sat) values at Ic/Ib = 10.
For example, a 360mW 12V relay will draw approximately 30mA at room temperature. That means you should have 1.5 to 3mA of base current. So the resistor should be between about 1.5K and 3K.
If the GPIO does not give you quite 5V under that loading you might have to go a bit lower. In this case, assuming the GPIO gets within (say) 0.5V of Vdd, 2K could be a good value.
There is no need to supply excessive current to the base, it will result in needless power dissipation (much of it in the MCU at higher current levels) and the GPIO &quot;5V&quot; output will drop as a result of the excessive loading. Excessive current will negatively affect the reliability of the MCU chip.