Python Serial Port Programming

Mar 08, 2012  Since the spectrometer has a serial port, we can write a program that automates this process. In order for python to be able to talk to the spectrometer, we need to get pySerial, which extends Python's capabilities to include interacting with a serial port. In this python tutorial, I will explain how to: How to configure Python and pySerial. For more details check out pyserial documentation. Check what serial ports are available on your machine. To get a list of available serial ports use. Python -m serial.tools.listports.

Active18 days ago

Can someone please show me a full python sample code that uses pyserial, i have the package and am wondering how to send the AT commands and read them back!

Willi Mentzel
12.7k11 gold badges60 silver badges79 bronze badges
GathGath

Python Serial Port Programming List

5873 gold badges11 silver badges14 bronze badges
Python Serial Port Programming

closed as off-topic by Drew, miken32, Machavity, doelleri, CerebralFartOct 24 '16 at 17:51

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • 'Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.' – Drew, miken32, Machavity, doelleri, CerebralFart
If this question can be reworded to fit the rules in the help center, please edit the question.

4 Answers

FramesterFramester
12.2k36 gold badges109 silver badges176 bronze badges

use https://pythonhosted.org/pyserial/ for more examples

Vatev
6,4101 gold badge25 silver badges35 bronze badges
baydabayda
10.7k6 gold badges33 silver badges48 bronze badges
animuson
44.6k22 gold badges121 silver badges134 bronze badges
engasoengaso

I have not used pyserial but based on the API documentation at https://pyserial.readthedocs.io/en/latest/shortintro.html it seems like a very nice interface. It might be worth double-checking the specification for AT commands of the device/radio/whatever you are dealing with.

Specifically, some require some period of silence before and/or after the AT command for it to enter into command mode. I have encountered some which do not like reads of the response without some delay first.

Paul OsbornePaul Osborne
3,2585 gold badges20 silver badges18 bronze badges

Not the answer you're looking for? Browse other questions tagged pythonmodempyserial or ask your own question.

Latest version

Last released:

Python Serial Port Extension

Project description

Python Serial Port Extension for Win32, OSX, Linux, BSD, Jython, IronPython

Stable:

  • Documentation: http://pythonhosted.org/pyserial/
  • Download Page: https://pypi.python.org/pypi/pyserial

Latest:

  • Documentation: http://pyserial.readthedocs.io/en/latest/
  • Project Homepage: https://github.com/pyserial/pyserial

Release historyRelease notifications

3.4

3.3

3.2.1

3.2

3.1.1

3.1

3.0.1

3.0

2.7

2.6

2.5

Programming

2.4

2.3

2.0

1.20

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pyserial, version 3.4
Filename, sizeFile typePython versionUpload dateHashes
Filename, size pyserial-3.4-py2.py3-none-any.whl (193.7 kB) File type Wheel Python version py2.py3 Upload dateHashes
Filename, size pyserial-3.4.tar.gz (151.7 kB) File type Source Python version None Upload dateHashes

Python Serial Port Programming Guide

Close

Hashes for pyserial-3.4-py2.py3-none-any.whl

Hashes for pyserial-3.4-py2.py3-none-any.whl
AlgorithmHash digest
SHA256e0770fadba80c31013896c7e6ef703f72e7834965954a78e71a3049488d4d7d8
MD50e555d61700e0b95a15d8162092c5299
BLAKE2-2560de42a744dd9e3be04a0c0907414e2a01a7c88bb3915cbe3c8cc06e209f59c30
Close

Hashes for pyserial-3.4.tar.gz

Hashes for pyserial-3.4.tar.gz
AlgorithmHash digest
SHA2566e2d401fdee0eab996cf734e67773a0143b932772ca8b42451440cfed942c627
MD5ed6183b15519a0ae96675e9c3330c69b
BLAKE2-256cc7411b04703ec416717b247d789103277269d567db575d2fd88f25d9767fe3d