[Python] How to regulate two way serial communication between python and arduino?

Discussão em 'Python' iniciado por Stack, Março 23, 2025.

  1. Stack

    Stack Membro Participativo

    My question is kind of general, so I haven't included any code here. I am working on a project to control hardware and read sensors with an arduino board via a Python/tkinter interface on a PC. The idea is for the PC to be able to send serial commands to the arduino to manipulate hardware and to simultaneously transmit sensor data back from the arduino to the python script.

    I have a working code that allows for the hardware communication as well as sends back updates every second from the sensor to the PC. It works fine until... an outbound command overlaps with an inbound sensor bit in which case it freaks out and freezes.

    What is the general school of thought on how to regulate two way communications to deconflict incoming and outgoing serial communications?

    I'm like brand new to python so I'd appreciate the most basic or simple (easy for a human to understand) version.

    Thanks!

    Continue reading...

Compartilhe esta Página