It turns out that the string needed to be turned into a bytearray and to do this I editted the code to

ser.write("%01#RDD0010000107**\r".encode())

This solved the problem

Answer from Garvin on Stack Overflow
🌐
pySerial
pyserial.readthedocs.io › en › latest › shortintro.html
Short introduction — pySerial 3.5 documentation
>>> import serial >>> ser = serial.Serial('/dev/ttyUSB0') # open serial port >>> print(ser.name) # check which port was really used >>> ser.write(b'hello') # write a string >>> ser.close() # close port
Discussions

serial - How to use pyserial to write two separate message? - Arduino Stack Exchange
You can store your characters in a String or char array until you detect your delimiter and then execute your command. Hope that helps! ... Find the answer to your question by asking. Ask question ... See similar questions with these tags. ... 1 Initially my Arduino executes a series of PWM signals simultaneously, but after some iterations it adds around a second between PWM executions · 0 Can't display the two float values correctly from pyserial ... More on arduino.stackexchange.com
🌐 arduino.stackexchange.com
March 19, 2021
PySerial not sending string to serial port of Arduino
Hello. I’m kind of new to Python and Arduino but I started to work recently with these two, so I need some help. This is the scenario: At work: We are working with an Arduino Uno and a Rpi 4. They are conencted via USB cable and we connect to the Rpi 4 via work Wireless network. More on discuss.python.org
🌐 discuss.python.org
19
0
October 4, 2022
python - Ser.write() function input - Raspberry Pi Stack Exchange
I am trying to to send a number from serial ports on my Pi 3 to a motor driver, (RoboLCaw) by using Python. I have read lots of articles on the internet about how to to do very simple number sending More on raspberrypi.stackexchange.com
🌐 raspberrypi.stackexchange.com
March 5, 2017
help with sending string using pyserial
You're not supposed to send '' literally. It means "carriage return". Some devices need sending '\r', some require \n' and some need '\r\n'. Check your device documentation how is interpreted. Try this: ser.write('#0P500S750\r') More on reddit.com
🌐 r/learnpython
4
3
April 17, 2017
🌐
pySerial
pyserial.readthedocs.io › en › latest › pyserial_api.html
pySerial API — pySerial 3.5 documentation
class PrintLines(LineReader): def connection_made(self, transport): super(PrintLines, self).connection_made(transport) sys.stdout.write('port opened\n') self.write_line('hello world') def handle_line(self, data): sys.stdout.write('line received: {}\n'.format(repr(data))) def connection_lost(self, exc): if exc: traceback.print_exc(exc) sys.stdout.write('port closed\n') ser = serial.serial_for_url('loop://', baudrate=115200, timeout=1) with ReaderThread(ser, PrintLines) as protocol: protocol.write_line('hello') time.sleep(2) asyncio was introduced with Python 3.4. Experimental support for pySerial is provided via a separate distribution pyserial-asyncio.
🌐
Python.org
discuss.python.org › python help
PySerial not sending string to serial port of Arduino - Python Help - Discussions on Python.org
October 4, 2022 - Hello. I’m kind of new to Python and Arduino but I started to work recently with these two, so I need some help. This is the scenario: At work: We are working with an Arduino Uno and a Rpi 4. They are conencted via US…
🌐
GitHub
gist.github.com › yptheangel › fcd62ad59a569ace75eb07025b8e9c4f
pyserial read write example · GitHub
pyserial read write example · Raw · pyserial_example.py · This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters · Show hidden characters · Copy link · Copy Markdown · Hi, this just print empty strings, b' ' Copy link ·
🌐
Python
python-list.python.narkive.com › KIdrRlpL › psserial-how-to-write-a-single-byte-value-to-the-serial-port
psSerial: how to write a single byte value to the serial port?
A string consists only of the characters you can "see" - if python usues C convention for 0-termination or othear means is an implementation detail none of your concern. Post by SoftwareTester byte = chr(0x40) ser.write(byte) ... http://pyserial.sourceforge.net/ example shows how to write string to serial port.
Find elsewhere
🌐
Pyserial
pyserial.com › docs › writing-data
Writing Data | PySerial Docs
Every write() call requires a bytes ...+GMR\r\n') # Send a single control character ser.write(b'\x1A') # Ctrl+Z · Strings must be encoded before writing....
🌐
Reddit
reddit.com › r/learnpython › help with sending string using pyserial
r/learnpython on Reddit: help with sending string using pyserial
April 17, 2017 -

I'm trying to (learn and) use python to send a serial command to a servo controller. My current code is as follows:

import serial
import time

ser=serial.Serial('COM7',9600)
i=0
print 'START'

while(i<5):
    ser.write('#0P500S750<cr>')
    time.sleep(2)
    ser.write('#0P2500S750<cr>')
    time.sleep(2)
    print 'sweep'
    i=i+1

print 'STOP'

The device moves the servo based on the received serial command. #0P500S750<cr> translates to port 0, position 2500, speed 750. The command is terminated for the device with <cr>.

I'm not sure what I'm doing wrong. I am currently using python 2.7.13

thanks in advance

🌐
Python.org
discuss.python.org › python help
How to send and receive serial in python - Python Help - Discussions on Python.org
August 30, 2021 - Hi, I am running the following code in python. The Microcontroller is connected to the USB UART COM 7. I am sending the character “S” from python to Microcontroller and I expect a line from Microcontroller but there is nothing on the python shell. I am not sure if I am sending it properly or not and whether I am reading the line from Microcontroller the right way or not. import serial ser = serial.Serial("COM7", 9600) # Send character 'S' to start the program ser.write(bytearray('S','ascii...
🌐
Raspberry Pi Forums
forums.raspberrypi.com › board index › programming › python
Trouble sending a string over serial - Raspberry Pi Forums
April 5, 2022 - import serial ser = serial.Serial('/dev/ttyS0', 115200, timeout=4) print("We are using", ser.name ) print ("closing serial") # in case it was already open ser.close() print ("opening serial") ser.open() mystr ="PQR" mynum = 1.234 mytext = mystr+str(mynum) print ("My text is:", mytext) print ("convert mytext to bytes") mydata = bytes(mytext,'utf-8') print ("write mydata as bytes to serial") ser.write(mydata) print ("serial ser.write done") ... Tue Apr 05, 2022 6:17 pm encode is a function. use "string".encode('ascii') instead, which calls the function, converting the string to ascii which is sufficient here.
🌐
Pyserial
pyserial.org › docs › writing-data
Writing Serial Data with PySerial
Master all PySerial write methods and data transmission techniques. ... The core method for sending data. ... import serial ser = serial.Serial('/dev/ttyUSB0', 9600, timeout=1) # Send bytes bytes_written = ser.write(b'Hello World') print(f"Sent {bytes_written} bytes") # Send with line ending ser.write(b'Command\r\n') # Send single byte ser.write(b'\x1A') # Ctrl+Z · # Convert string to bytes (required!) message = "Hello Serial World" # Method 1: encode() ser.write(message.encode('utf-8')) # Method 2: bytes literal ser.write(b'Hello Serial World') # Method 3: format and encode temperature = 25.6 data = f"TEMP:{temperature:.1f}\n" ser.write(data.encode('utf-8')) # Common encodings ser.write(message.encode('ascii')) # ASCII only ser.write(message.encode('latin-1')) # Extended ASCII ser.write(message.encode('cp1252')) # Windows encoding
🌐
Medium
rahulsreedharan.medium.com › python-serial-port-programming-tutorial-for-beginners-using-pyserial-module-6df0666f0db6
Python Serial Port Programming Tutorial for Beginners using PySerial Module | by RSDevX | Medium
June 24, 2022 - SerialObj.write(b’A’) #transmit ‘A’ (8bit) to micro/Arduino · SerialObj.close() # Close the port · Full Source code can be found here · Detailed Explanation can be found here · The first line import serial imports the pySerial module so that your programcan use it. ComPort = serial.Serial(‘COM24’) opens the serial port named COM24. Serial communication occurs in bytes (8 bits) while Python3+ handles strings in unicode format which may consume upto 4 bytes.
🌐
Reddit
reddit.com › r/learnpython › [pyserial] sending list through serial port.
r/learnpython on Reddit: [pySerial] Sending list through serial port.
May 4, 2018 -

Good day. I'm trying to send a 'list' through a serial port. The list has three items. [string, string, tuple]

I can send individual strings without an issue, but when I try to send a list items it doesn't work. It says must be a 'string'.

Perhaps there is a way to easily convert a list into a 'string' or 'byte' object. I've tried that, but I have issues converting the 'list' from 'string' back to the original 'list' on the other side.

Any suggestions or guidance would be appreciated.

import serial

lst_data = []

ser = serial.Serial(
    port='/dev/ttyAMA0',
    baudrate = 9600,
    parity=serial.PARITY_NONE,
    stopbits=serial.STOPBITS_ONE,
    bytesize=serial.EIGHTBITS,
    timeout=1)

if ser.isOpen == True:
    ser.close()
    
def write(string):
    if ser.isOpen() == False:
        ser.open()
    ser.write(string)
    ser.close()

I want to be able to pass 'write(['hello', 'world', ('hello','world')])'

Someone suggested using ",".join(list), but it doesn't work. I can't because list[2] is a tuple.

>>string_data = ",".join(data)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: sequence item 2: expected string, tuple found
🌐
Quora
quora.com › How-do-I-use-pyserial-to-send-strings-to-Arduino
How to use pyserial to send strings to Arduino - Quora
Send command-response: Python writes a command ending in '\n', Arduino processes and replies with a line. Logging: Arduino periodically prints sensor values; Python reads lines in a loop and parses them. Binary frames: use a start byte, length, payload, checksum; implement framing on both ends. This approach provides reliable text communication between Python and Arduino using pyserial. ... Originally Answered: How do I send a data string ...
🌐
Arduino Forum
forum.arduino.cc › projects › programming
String Write from Python - Programming - Arduino Forum
August 18, 2023 - Hello, I am working on a project that uses a Python UX to transmit a String to the arduino in order to write to an RFID tag. I am having issues with the python code writing to the arduino. Below is the arduino code that is receiving the string from python. For some reason I can input this string ...
🌐
Python.org
discuss.python.org › python help
PySerial not sending string to serial port of Arduino - Page 2 - Python Help - Discussions on Python.org
October 4, 2022 - Hello. I’m kind of new to Python and Arduino but I started to work recently with these two, so I need some help. This is the scenario: At work: We are working with an Arduino Uno and a Rpi 4. They are conencted via US…
🌐
I-systems
i-systems.github.io › teaching › mechatronics › iNotes › 07_Arduino_with_Python.html
07_Arduino_with_Python
String LEDcmd = ""; const int pin = 9; void setup() { pinMode(pin, OUTPUT); Serial.begin(9600); } void loop() { if (Serial.available() > 0) { LEDcmd = Serial.readStringUntil('\n'); if (LEDcmd == "ON") digitalWrite(pin, HIGH); else if (LEDcmd == "OFF") digitalWrite(pin, LOW); } } ... ser = serial.Serial('COM14', 9600, timeout=1) for i in range(10): ser.write(str('ON').encode('UTF-8')) time.sleep(0.5) ser.write(str('OFF').encode('UTF-8')) time.sleep(0.5) ser.close()
🌐
GitHub
github.com › pyserial › pyserial › issues › 78
String being cut when using write() method · Issue #78 · pyserial/pyserial
My string is being cut in the middle of the sentence. Is there any workaround? import serial port = "COM1" ser = serial.Serial(port, 115200, timeout=3) ser.write('setenv -p F1 "flash -noheader 127.0.0.1:lalala.kernel flash0.kernel"\r\n') ser.write('setenv -p F2 "flash -revend1 127.0.0.1:lelele.ubi nandflash0.rootfs"\r\n')
Author   pyserial