Questions tagged [pyserial]

pySerial is a Python module that encapsulates the access for the serial port. It provides backends for different platforms and Python implementations.

pySerial encapsulates the access for the serial port. It provides backends for Python running on Windows, Linux, BSD (possibly any POSIX compliant system), Jython and IronPython (.NET and Mono). The module named serial automatically selects the appropriate backend.

This is an example extracted from the introduction of the documentation:

>>> import serial
>>> ser = serial.Serial(0)  # open first serial port
>>> print(ser.portstr)      # check which port was really used
>>> ser.write("hello")      # write a string
>>> ser.close()             # close port

References:

2268 questions
0
votes
1 answer

How to fix " serial is not defined " in python

I'm currently using serial package for python and I have followed every tutorial on the internet but I have always got this error. NameError: name 'serial' is not defined I have already tried from serial import Serial and from serial import * . I…
Zion Miguel
  • 83
  • 1
  • 3
  • 9
0
votes
2 answers

Python pyserial one write delay

I'm having a weird issue with pyserial, using Python 3.6.9, running under WSL Ubuntu 18.4.2 LTS I've set up a simple function to send GCODE commands to a serial port: def gcode_send(data): print("Sending: " + data.strip()) data =…
XDGFX
  • 41
  • 2
  • 9
0
votes
1 answer

PySerial Attribute Error with 'read_until'

I need some help troubleshooting an Attribute Error in my Python code. I am working with a serial device connected by a /dev/ttyUSB0 to a Raspberry Pi 2B. My goal for this code is to read live serial data continuously from the serial device and…
0
votes
1 answer

Combining pyserial and pyside2/pyqt5

I'm writing a code to have a GUI which controls a peristaltic pump via a serial connection. First I developed a Class "Pump", which works fine in a jupyter book. Second I developed a GUI using PySide2/PyQt5. By merging both, I get some issues. This…
Andreas
  • 11
  • 2
0
votes
0 answers

Is it possible to find out the current baud rate while sending data serially to a microcontroller using PySerial?

I'm trying to find a way to calculate the current baud rate while transmitting data serially to a microcontroller. I don't want to source this from the baud rate setting used by Python Serial module rather I want to find the start and end time of…
0
votes
1 answer

how to insert data from one function into multiple widgets in PyQt5

I have a device connected with my interface and want to insert the data into QlineEdit widgets This function def getdevice_data(self): receaves the data from the device and returns it as string with…
Sator
  • 636
  • 4
  • 13
  • 34
0
votes
0 answers

loosing data from device connected to serial port

I have a scale connected via USB (virtual serial port) There is a print button to send the data, when I press the button fast enough I do not receive all the data. The items stored in the list are ether not complete or, or empty Looks like I do…
Sator
  • 636
  • 4
  • 13
  • 34
0
votes
1 answer

Python to Arduino through Serial, can’t move servos

I'm currently trying to have a camera mounted on a pan tilt made of two micro servos track a face. My python code has been working and has been successfully identifying a face, but non of my servos have been moving while the Arduino is constantly…
0
votes
1 answer

Trouble Using Command Prompt to Install Pyserial

I need to process serial data using python for a project I am working on. However, the download of python 3 I have installed does not have the serial module already, so I have been working on trying to install the module. To install the module, I…
Smurphinator
  • 1
  • 1
  • 2
0
votes
1 answer

check if specific device is connected to COM Port

I want to check if one specific device is connected to one of my serial ports. with list_ports.comports() I get all the COM Ports with x = list_ports.grep("0403:6001") I can search for a specific device. This gives me
Sator
  • 636
  • 4
  • 13
  • 34
0
votes
1 answer

Using pyserial to read Scale shows b''

I am fairly new to using pyserial and I am currently having difficulty with reading a scale. I believe that it has to do with some initialization that I am not doing correctly on python. I have been running the scale with LabVIEW but am trying to…
Z.Tyler
  • 11
  • 3
0
votes
1 answer

Serial AT commands not working in python script but working in Minicom

I am trying to program a GPRS/GNSS/... Raspberry PI HAT. Sending commands with Minicom works fine. Sending commands with a Python script works for most of the commands but not for all. Using the Python script commands are received but gives me back…
Milos
  • 21
  • 3
0
votes
1 answer

Serial port overload in Psychopy

I am using a button box connected via a serial port for running an experiment in Psychopy. from binascii import hexlify import serial import serial.tools.list_ports as port_list ports = list(port_list.comports()) # search for the devices #for p in…
0
votes
2 answers

How to parse a string stream from pyserial and compare with a pre-specified value

I'm finding it really hard to phrase this question, mainly because I've found the problem confusing myself. So I have an IMU stream running from my Arduino and I'm streaming it through pySerial. Basically it gives me an output like this: ** #1, #2,…
Shayan Riyaz
  • 82
  • 11
0
votes
2 answers

Python unable to convert utf-8 decoded serial data in string to floats

I am trying to get Serial data from my Arduino to my python console Here is my Arduino code: void setup() { Serial.begin(115200); Serial.setTimeout(10); randomSeed(analogRead(0)); } void loop() { float x = float(random(0,200))/100; …
SKrish
  • 43
  • 6