A GUI program using PyQt5 to perform serial communication between the GUI and a microcontroller. Serial communication allows for writing to or reading from the microcontroller.
The establishment is exceptionally straightforward you fair ought to have PyQt5 and pyserial introduced which can be introduced with this command:
pip install pyserial
pip install PyQt5
pip install PyQt5-Qt5
pip install PyQt5Designer
After that fair duplicate the library to your venture and grant the record a title (e.g. IO.py
).
# Initialize the Port object from the IO module
import IO
Port = IO.Ports()
# to send a message through the serial port
if Port.serial.is_open:
Port.Write(message)
Port.ReadExisting.connect(main.DataReceived) # to handle data received from the serial port
Port.BaudRate # to update the list of baud rates
port.portName() # to update the list of available ports
For a more complete usage example, refer to main.py
.
To run the above source code, follow these steps:
- Upload the program located at
arduino/softwareserial/softwareserial.ino
to the microcontroller. - Next, run
program.py
. - Select the port and baud rate.
- Once selected, press the connect button.
- The application should now be operational.