Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Programming Arduino Directly from PYDAQ #15

Open
samirmartins opened this issue Aug 7, 2024 · 2 comments
Open

Programming Arduino Directly from PYDAQ #15

samirmartins opened this issue Aug 7, 2024 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@samirmartins
Copy link
Owner

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

@samirmartins samirmartins added enhancement New feature or request good first issue Good for newcomers labels Aug 7, 2024
@Nikhildave4478
Copy link

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

  1. Install Arduino CLI:
  2. Set Up Your Environment:
  3. Write a Python Function (Ensure you have Python installed and also install the subprocess module)
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)

@samirmartins
Copy link
Owner Author

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,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants