Upload .ino sketch from python GUI

Hi All,

I'm using a serial monitor GUI to read serial data off a dongle I have integrated into a python script. The data relies on arduino powered linear-actuators. I'm wondering if there's somehow a way I can incorporate a button in my GUI that browses for the .ino file necessary to drive the actuators, and upload it from within the serial monitor program.

I don't need to interactively code from python or gather any serial data from the arduino. All I'd like to do is upload and compile the sketches that are already located on my computer from within the python script.

Any suggestions on how to approach this??

Thanks in advance!

Your configuration isn't entirely clear to me from the description, but if the Arduino USB serial is connected to the host computer, you can execute an OS command from within Python to flash the Arduino.

"Avrdude" is the command line utility that the Arduino IDE uses to flash the Arduino, so you'd simply use Python's os.system() to call avrdude with the proper options to flash your file to the device.

Note that avrdude actually flashes from a hex file generated when the .ino is compiled, so it is that file that needs to be accessible. Also there are complications in finding the proper port for the Arduino that would need to be worked out.

If you want to compile as well as upload, I'd recommend using the Arduino IDE CLI instead of avrdude:

I use this Python program to compile and upload programs using the Arduino IDE command line.

...R