Python: Using an Arduino alongside uArm Problem

Hi, I am trying to use the uArm Swift Pro in Python with another arduino which is to perform external tasks un-related to the arm (reading sensors in a gardenbed). It seems the uArm Swift python library “from uarm.wrapper import SwiftAPI” is interfereing with the “import serial” library. What should/can i do to get around this as it is preventing me from collecting my sensor data via serial?

The serial data collected is then used to determine where to move the uArm.
Thanks, any help appreciated :slight_smile:

uArm Serial No.: (the No. at the bottom of each uArm reading “UARM-XXXXXXXXXX”) ask me

Firmware Version: ask me

Operation System: Win10

uArm Controlling Method: python


UFACTORY Website
Official Store
uArm User Facebook Group

Feedback:
English
中文通道

I use uArm with external 2 Arduino boards controlling 2 other motors (yes using import serial), all with python. There are no fundamental issues with this. Having said that, I will not look at your code and debug it for you. :slight_smile:

Interesting. Is there any chance I could see your code so I can analyse the problem? I was told I might have to look into Multi-threading to solve the problem. Could also possibly be a problem with my computer so when I get the chance I will attempt on another computer. Thanks for your help :slight_smile:

I don’t know if look at my code is going to help as it will have lots of irrelevant stuff.

If you have the error at ‘import serial’, then this is likely a python library conflict. If you running your python code without an virtual environment, this is bad practice as the more python libraries your install the more likely conflicts will occur (it is inevitable actually) because not all versions of libraries are compatible each other.

I recommend you use an virtual environment manager like Anaconda. Research it if you don’t already know about it. With Anaconda, you can create virtual environment in whatever python version and install only the libraries necessary. You create virtual environment for each particular python thing you need.

1 Like

I found the solution. You need to open Swift_API.py file and change line “def init(self, port=port, baudrate=115200, timeout=None, **kwargs):” change port to the COM port the uArm is connected to (can be found in Device Manager). e.g “def init(self, port=‘COM5’, baudrate=115200, timeout=None, **kwargs):”. Otherwise, on my system anyways, the uArm reserves all COM ports and hence will reject another Arduino with serial communication.

If that solves it, you could just leave the original API and initialize with the port. That way, you don’t mess with their code. :slight_smile:

u = SwiftAPI(port=‘COM5’)

1 Like