Try using this following diagram to connect your relay:
That should work. Note I used a 2N3904 transistor but it could be the transistor you prefer. The diode is just for protection. If that doesn't work, try to blink a LED to make sure the control signal from the Breakout Board is working and the transistor is working too. The following post could be useful for the LED test: Your First Blink- Edison Breakout Board + Arduino IDE.
thank you very much,
it works very well mit a led but not with the relay, same issue if i plug the cabel directly to 1.8v pin the relay closes and if i connect it with gpio40 nothing appens.
i tried the relay parallel with the relay nothing happens, if remove the relay the led will shine. if i connect the base with 1.8v the led shines and the relay closes
1 of 1 people found this helpful
what is the relay coil resistance? you need to calculate how much collector current is needed, then apply 1/10th of that current to the base. 2N3904 has quite low gain and at the current level you have, the base-emitter voltage will be about 0.9V, so if you need 5mA and the pin voltage actually is 1.8V, you should use (1.8V-0.9V)/5mA = 180ohm base resistor. the problem is that you GPIO probably sags so you do not have 1.8V. so you have to check the actual pin voltage at 5mA and select the resistor value accordingly.
npn transistors are not well suited for use with 1.8V logic. darlington transistors are even worse. you need to get n-channel MOSFETs that have Rdson specified at 1.8V. these are readily available in SOT23 package and cost almost nothing. look for 20V n-channel MOSFETs in SOT23 package and check the datasheet for the Rdson value and make sure it is specified at 1.8V. ( forget the gate threshold value, it has no meaning.) Look for MOSFETs that has continuous drain current max rating of 1A or higher. There are many devices that can drive 4A or more. the higher current devices have more capacitance so they will cause a current spike in the GPIO pin when switching. this causes noise on the 1.8V rail, so you may want to add a 1k resistor between the GPIO pin and the gate if the MOSFET is large, to reduce the noise. A MOSFET is voltage driven, so it only draws a current briefly when GPIO pin changes.
Some part number examples below, from one vendor. use ECIA Authorized - The Search of Authorized Distribution and type in the partnumber to search availability and cost.
Package sizes get smaller and smaller, and SOT23 is today considered a huge size. you can find the same type of MOSFET in much smaller package sizes (1/10th the size of SOT23 in some cases) but for prototyping use SOT23 is nice as you can solder it without needing a microscope.