I have a program which constantly sends data from Pyton to NodeMCU esp8266 (connected to the computer with a micro usb cable) using PySerial library. The program works without a problem on a mac computer but gives error on Windows computer.
Commented line is for mac, the line below is for windows.
if connect:
#arduino = serial.Serial(port='/dev/cu.usbserial-10', baudrate=9600, timeout=.1)
arduino = serial.Serial('COM5', 9600, timeout=.1)
print("arduino bağlandı")
Using python, I edit data and send it constantly to the NodeMCU, the code below is in a while loop
if connected:
arduino.write(bytes(some_string, 'utf-8'))
print(msj, "sent")
time.sleep(0.1)
I've attached servo's to the NodeMCU and turn them according to the data I get from Python program.
void loop() {
if (Serial.available()) {
int x = Serial.read();
Later I use this x value according to my needs.
As I mentioned, the program works fine on a mac computer. However on a windows computer, I can't run both programs at the same time. If I start the python program, I get "Port monitor error: command 'open' failed: Serial port busy. Could not connect to COM5 serial port." error when I try to open the serial monitor on arduino IDE.
I've tried running the NodeMCU first but then I couldn't run the Python program.