I have been trying to control the I/O pins on Yun through Ethernet/Wifi, and have two identical circuits connected on 2 different pins ( Say pin 13 and 11). The circuits that are connected are basic relay circuits to further turn an electrical appliance on or off based on pin 13 and 11 going high or low respectively.
The problem is when I try to turn both the appliances on/off, pins 13 and 11 dont go to ~5V simultaneously. Either 11 or 13 goes up to ~0.6V when turned on, when the relay circuits (load) is connected to these pins, and the other one goes up to ~5V. When I disconnect these external circuits from 11 and 13, these pins work fine and can go up to ~5V when turned on.
The external relay circuits seem to be working fine independently. And they dont require more current than pins 11 or 13 can provide, which is 40mA according to the specs, and as I understand all I/O pins can go up to 5V.
Can somebody suggest how to get ~5V on all I/O pins, so that they can drive an external circuit (in my case an electrical appliance connected via a relay switch).
Do not drive relay coils directly from pins, you will kill the pin circuitry in the micro. You must connect the pin to the base of a small transistor (eg BC548) via about 2k and use that to power the relay. And put a reverse-biased diode across the relay coil to catch the coil current when the transistor switches off.
Then you probably have something miswired, or your base resistor is too small. A typical small-signal transistor has a current gain of between 100-500, which means that you need only 1mA from your output pin to reliably supply 100mA to a relay coil. Your R1 should therefore be around 1k-3k, and the output pin should not struggle to pull up to nearly 5V.
Note that if you measure the voltage at the transistor's base instead of the actual output pin, you will measure about 0.6V though the pin is at 5V.
Both the circuits work fine independently, the problem seems to arise when I connect both the external relay circuits to arduino port..
And I am using 1K ohm resistor, and I measured 0.6V at the output port of arduino, not the base of the transistor.
Sorry, I figured it out. Seems like in the Arduino sketch I was using, I didnt declare the specific pin mode to "Output" for these I/O pins. After changing the pin mode, I can turn on/off 2 appliances at the same time, and I assume I can even control more than 2 appliances too. I am not sure, I still need to experiment more, but maybe the relay current consumption wasnt the issue here? Should have been more careful with the software part.