Serial communication only working when Serial Monitor is opened.

Hello,

I have a question regarding serial communication. I'm sending data serially from raspberry pi to arduino to turn on and off LEDs (using python). When I'm using my PC it works great; however, when I'm using raspberry pi, I need to open the serial monitor to make it work.
Any idea why this is happening?

Thanks in advance!

Why do you think so?

Do note that opening the Serial Monitor does reset (most) Arduino's. And you can't use Python and the Serial Monitor at the same time.

septillion:
Why do you think so?

Do note that opening the Serial Monitor does reset (most) Arduino's. And you can't use Python and the Serial Monitor at the same time.

But when I'm not opening the Serial monitor it's not working.

But if you do, it can't work either because if the Serial Monitor is open the Python script can't access the serial port...

septillion:
But if you do, it can't work either because if the Serial Monitor is open the Python script can't access the serial port...

What is weird is that once I connect it to my PC and run the same exact Python script, it works great. Do you think it might be due to power issues?

Might (no idea what else is connected) but does not explain anything with the Serial Monitor.

But can you explain what I say in reply #3? How is it possible for the Python script to work if you open the Serial monitor if Python isn't able to connect to the Serial port as long as the Serial monitor is open?

septillion:
Might (no idea what else is connected) but does not explain anything with the Serial Monitor.

But can you explain what I say in reply #3? How is it possible for the Python script to work if you open the Serial monitor if Python isn't able to connect to the Serial port as long as the Serial monitor is open?

So basically what I did is that I run the Python script, then I open the Serial monitor. At first is says that I can't open it since the PORT is not selected even-though I've already uploaded the program. so I go and select the port again and it works.

Now I start to doubt the behavior of serial ports in Linux...

But what it seems to bottle down to is that a reset seems to fix the problem. You can try a reset instead of opening Serial Monitor.

If that fixes it then it's a "bug" in your program. Aka, that it only works if the PC starts talking right away or something. But without code....

septillion:
Now I start to doubt the behavior of serial ports in Linux...

But what it seems to bottle down to is that a reset seems to fix the problem. You can try a reset instead of opening Serial Monitor.

If that fixes it then it's a "bug" in your program. Aka, that it only works if the PC starts talking right away or something. But without code....

Did not work :confused:

What Arduino are we talking about?

Mega2560, and it worked. Apparently it's a power issue. The raspberry pi isn't supplying enough current to the Arduino I guess. I connected a 5V battery to the Vin and GND of the arduino and that solved it.

maybe you should try changing the baud rate. :slight_smile: