PySerial issues (Or just Arduino Serial issue)

I'm trying to write something to Serial with Python and read it in Arduino so Arduino will know my Python program is still alive. But the Pyserial serial.write() function doesn't seem to work properly? I saw some discussions about this, and possible solution being letting some time pass after starting the serial connection and doing the write().

I tried it.. but doesnt work very well still.

import serial
import time

arduinoSerialData = serial.Serial('com6', 9600)

while True:

And in Arduino I have this code:

void loop() {

    if (Serial.readString().startsWith("AAA")) {
        digitalWrite(7, LOW);
    } else {
        digitalWrite(7, HIGH);

I'm hoping I'm doing something wrong in the Arduino code and its not an PySerial oddity again.

But seeing how it works fine in the console and not when executing a file I dont know....

Also sorry about the previosu topic, I have a terrible fever and my brain was malfunctioning.

Cross-posted to



Also on this forum:

Do the words “cross-posting” mean anything to you?

Please do not cross-post. This wastes time and resources as people attempt to answer your question on multiple threads.

Thread locked.

  • Moderator