I made simple custom arduino board using an atmega328p and the PL2303 serial to USB chip.

In my arduino program, I am in a loop that sends out a string continuously. I can read this in the Arduino serial monitor with a baudrate of 9600. However, in my python program using the pySerial library, the readline function doesn't return anything. I checked using PuTTY but it still doesn't do anything.

Now I tried messing with the serial settings and found out that these lines of code work (the readline returns the string) if I call it in the exact same order.

ser = serial.Serial(comm_port)
ser.xonxoff = True
ser.rtscts = True
ser.dsrdtr = True

However, the code below doesn't work

ser = serial.Serial(comm_port, xonxoff=True, rtscts=True, dsrdtr=True)

What could be causing this? My guess is somehow I've switched the datalines in my USB cable and that the arduino serial monitor handles this somehow.

Another thing to note is that I couldn't program the Arduino the normal way via USB. I always have to program it using the ICSP port and a USBasp programmer.

1 Answer 1


I wrote a python application which communicated with an arduino and for some reason I had to insert a delay after opening the serial for it to work correctly, if I didn't the first data I sent would always get dropped. Perhaps that's what's occuring here? Setting the attributes of the serial connection like that is probably slower than doing it in initialisation.

For myself I found that a delay of 3 seconds was what I needed for it to work 100% correctly on all computers (on some a second was enough). You only had to wait after opening it once open it worked fine.

To do a delay import the time module and use the sleep function which takes an argument of seconds.

import time


Also worth noting depending on your application it's worth setting a timeout value for the serial that's appropriate or just keeping it open with the timeout paramter.

 ser = serial.Serial(com, 115200, timeout=0) 

If you do this make sure to close it when you finished with it though (I personally used a try finally block which makes sure its always closed).

  ser = serial.Serial(com, 115200, timeout=0)
  #go nuts with whatever communicating your doing

I'm afraid I can't really tell you what caused the issue though. I also realise that this question is quite old so I hope my answer is still helpful, if not to you then to someone else who stumbles across it. To note for future the people on the official Arduino forum may be of more help for arduino related questions in general.

  • 2
    The delay before it is ready is almost certainly caused by the auto reset on serial open behavior and the subsequent bootloader timeout. Oct 18, 2016 at 12:56
  • Yes, try connecting to the RX/TX pins instead.
    – user2497
    Aug 15, 2017 at 20:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.