OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Can't open serial monitor while pyserial script is working, using nodemcu

  • Thread starter Thread starter Çağan
  • Start date Start date
Ç

Çağan

Guest
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.

Code:
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

Code:
           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.

Code:
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.
<p>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.</p>
<p>Commented line is for mac, the line below is for windows.</p>
<pre><code>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ı")
</code></pre>
<p>Using python, I edit data and send it constantly to the NodeMCU, the code below is in a while loop</p>
<pre><code> if connected:
arduino.write(bytes(some_string, 'utf-8'))
print(msj, "sent")
time.sleep(0.1)
</code></pre>
<p>I've attached servo's to the NodeMCU and turn them according to the data I get from Python program.</p>
<pre><code>void loop() {
if (Serial.available()) {

int x = Serial.read();

</code></pre>
<p>Later I use this x value according to my needs.</p>
<p>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.</p>
<p>I've tried running the NodeMCU first but then I couldn't run the Python program.</p>
 
Top