I am trying to read data from the SFM10, using the simple hello world example,
It works in powershell but not using python
The following code works for an arduino
import serial
# Set a 5 second timeout
port = serial.Serial('COM6', 115200, bytesize=8, parity='N', stopbits=1, timeout=5)
try:
line = port.readline().decode('utf-8')
print(line)
except serial.SerialTimeoutException:
print("No data received within timeout period")
finally:
port.close()
Solved! Go to Solution.
Hi again, today I got a really good help from synchronicIT, see condensed solution below
import time
import serial
running = 0
ser = serial.serial_for_url('COM6', do_not_open=True)
ser.baudrate = 115200
ser.bytesize = 8
ser.parity = 'N'
ser.stopbits = 1
ser.rtscts = False
ser.xonxoff = False
ser.open()
# START
ser.rts = False
ser.dtr = True
time.sleep(0.02)
ser.rts = True
ser.dtr = False
time.sleep(0.01)
test=ser.readline()
time.sleep(0.02)
ser.write(b'the text\n')
test2=ser.readline()
print(test2)
ser.close()
Hi again, today I got a really good help from synchronicIT, see condensed solution below
import time
import serial
running = 0
ser = serial.serial_for_url('COM6', do_not_open=True)
ser.baudrate = 115200
ser.bytesize = 8
ser.parity = 'N'
ser.stopbits = 1
ser.rtscts = False
ser.xonxoff = False
ser.open()
# START
ser.rts = False
ser.dtr = True
time.sleep(0.02)
ser.rts = True
ser.dtr = False
time.sleep(0.01)
test=ser.readline()
time.sleep(0.02)
ser.write(b'the text\n')
test2=ser.readline()
print(test2)
ser.close()