Accessing Arduino GPIOs from Python over IoT

If you're having trouble with your LattePanda Alpha & Delta, here's the place to get help.
Forum rules
If you have not found a solution, post a new issue. To speed up the process please let us know:
- Have you tried the solutions listed above?
- What board are you using? Standard (2GB RAM/32GB eMMC) or Enhanced (4GB RAM/64GB eMMC)?
- Have you tried any other solutions?
- How long have you had your board for?
- When did you first boot your board?
- Did it work ok before the issue occurred or has the issue always been there?
- Use images and videos to help us understand the issue where possible

If you are seeking RMA:
- Please open a new topic rather than hijacking someone else's thread
- Mark RMA posts with [DEFECTIVE] + <helpful description of issue>. We can then approve/disapprove each request
- Completed RMA cases will be marked with [CLOSED]
You can find the RMA guide [here]

Resolved Issues
- If you manage to fix an issue, please share your solution for the good of the community. It could help someone else in future.
- If an issue is resolved the thread should be marked as [RESOLVED]. We can then sticky the thread to help people in future.
Post Reply
User avatar
cj1711
Posts: 2
Joined: Tue Jun 07, 2022 7:24 pm

Wed Jun 08, 2022 2:23 pm

Hello, my company has purchased a Delta, and are looking to utilize the on-board Arduino Leonardo. I have had to flash a custom Linux image onto the Panda to meet the company’s security policies, so I looked into using the Python Library PyFirmata (https://github.com/tino/pyFirmata). I had read in another forum that people had successfully used this library with the LattePandas. The library seemed to be simple, but I soon ran into numerous problems and questions.



One of the first lines of code needed is defining your board and its port. Most of the information online tells you how to find this address by either using a process controlled by Windows (Device Manager) or requires you to unplug the Arduino at some point(which is not feasible since it is onboard). When using " ls /dev/tty* " with the Linux on the LattePanda there are numerous options that come up. I have tried many of them (especially the ones that have been referenced online as being common ports for the Arduino to be connected to), but all of them seem to give me the same error message "could not open port /dev/ttyACM0: [Errno 2] No such file or directory: '/dev/ttyACM0'" (code below)



board = pyfirmata.Arduino('/dev/ttyACM0')



I have also tried using the Python library PySerial. The function serial.tools.list_ports is meant to return all ports. When I created code for this it returned ZERO ports (code below).



import serial
ports = serial.tools.list_ports.comports()
for p in ports:
print(p.device)
print(len(ports), 'ports found')



I have looked into seeing if there is some way that the serial ports need to be "opened", but do not have much experience with manipulating this either through Python or Linux. Not being able to access the port at all has completely stalled my project. Would someone be able to help me successfully access the Arduino's port so that I can control its GPIOs through Python?

User avatar
calpin
Site Admin
Posts: 49
Joined: Fri Apr 15, 2016 9:21 am

Fri Jun 17, 2022 11:05 am

https://www.lattepanda.com/topic-f16t16 ... ux+arduino
Hope this can help. BTW, because the chip is 32u4, the serial port you used with hardware might be serial1 not serial0.

Post Reply