I'm trying to write a simple program to read serial data from Arduino. In the Arduino serial monitor window, everything works fine. In the Python console, each number is on a separate line. In Pycharm, it just shows b' '. I don't know where the problem is.
Arduino Serial Monitor:
1234567890
1234567890
1234567890
1234567890
1234567890
1234567890
1234567890
1234567890
1234567890
1234567890
Python 3 console:
1
2
3
4
5
6
7
8
9
0
Pycharm IDE:
b' '
b' '
b' '
b' '
b' '
b' '
b' '
b' '
b' '
b' '
Here is the Python 3 code I am using:
import serial
from time import sleep
Ser = serial.Serial("COM3", 9600, timeout=0)
Counter = 1
while Counter <= 10:
data = Ser.readline()
print(data)
sleep(1)
Counter += 1
Ser.close()
Arduino code:
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println(1234567890);
delay(1000);
}