Open samirmartins opened 2 months ago
Currently, to use an Arduino with PYDAQ, you need to upload a code (sketch) onto the Arduino beforehand. This can be cumbersome, especially if you frequently change the sketch. The goal here is to automate the process of uploading the Arduino code directly from Python, making it more efficient and user-friendly.
Steps to Achieve This
import subprocess
def upload_sketch(sketch_path, board_fqbn, port):
compile_command = f"arduino-cli compile --fqbn {board_fqbn} {sketch_path}"
print("compiling sketch")
subprocess.run(compile_command, shell=True, check=True)
upload_command = f"arduino-cli upload -p {port} --fqbn {board_fqbn} {sketch_path}"
print("uploading sketch")
subprocess.run(upload_command, shell=True, check=True)
print("upload successful!")
if __name__ == "__main__":
sketch_path = "path/to/your_sketch.ino"
board_fqbn = "arduino:avr:uno" # Change as per your board
port = "/dev/ttyUSB0" # Change according to your connection
upload_sketch(sketch_path, board_fqbn, port)
Dear @Nikhildave4478 ,
thanks for your comment and suggestion for improvement into PYDAQ.
At this moment I'm working on solving a different issue. In this sense, you are more than invited to implement the suggestion into PYDAQ, make tests and submit a PR.
Tell me if you want to proceed with this contribution. If so, we could be in contact by Telegram/Discord to discuss the implementation of it.
Best regards,
As is known, in the current version of PYDAQ, to use the Arduino it is necessary to load a code onto it prior to executing PYDAQ. With this improvement, it is expected that the code loading will be done directly via Python/PYDAQ