I have two microcontrollers in two different boards, and each board has its own power source. I have linked the ground of the two boards and the two microcontrollers are also linked on two general I/O pins to transmi/receive each other.
The system works perfectly, but when only one board is powered the other one turns on too! :o
Why? How can I avoid this?
Perhaps, the voltage on one I/O pin of a microcontroller, due to internal pull-up, injects current trough the internal pull-up of the other microcontroller?
Serial ports are held high when idle; thus, when the powered device is not transmitting, you're applying 5v (or 3.3 if it's running at that) to an IO pin! Per datasheet, there are protection diodes on each pin, so you're powering the chip from the Tx line through the protection diodes...
DrAzzy:
so you're powering the chip from the Tx line through the protection diodes...
Thank you, DrAzzy, now I understand. Then, is there a simple solution to avoid this, or is it necessary to introduce something like a photocoupler or an operational amplifier configured as a voltage follower?
If it's just a digital pin connected to the other you can use pinMode(pin, INPUT_PULLUP) on the receiver and instead of digitalWrite(pin, LOW) and digitalWrite(pin, HIGH) you use:
//to turn on
pinMode(pin, OUTPUT);
digitalWrite(pin, LOW);
//to turn off
pinMode(pin, INPUT);
Now the transmitter never sources power.
If it's indeed serial you can indeed use a opto or just a transistor. It's the same circuit as a level shifter.
Only you connect the 3,3V line to the power rail (this can be 5V as well) of the transmitting Arduino and the 5V line to the receiving Arduino. This way, just like the code above, the sending Arduino can only pull the line low. On the receiving end it's pulled high with R2 from the power rail of the receiving Arduino.
For two way serial you need to make it twice. Data is transmitted from left to right. You can also use an off the shelve level converter as well.
septillion:
If it's just a digital pin connected to the other you can use pinMode(pin, INPUT_PULLUP) on the receiver and instead of digitalWrite(pin, LOW) and digitalWrite(pin, HIGH) you use:
//to turn on
pinMode(pin, OUTPUT);
digitalWrite(pin, LOW);
//to turn off
pinMode(pin, INPUT);
Now the transmitter never sources power.
If it's indeed serial you can indeed use a opto or just a transistor. It's the same circuit as a level shifter.

Only you connect the 3,3V line to the power rail (this can be 5V as well) of the transmitting Arduino and the 5V line to the receiving Arduino. This way, just like the code above, the sending Arduino can only pull the line low. On the receiving end it's pulled high with R2 from the power rail of the receiving Arduino.
For two way serial you need to make it twice. Data is transmitted from left to right. You can also use an off the shelve level converter as well.