I'm trying to get a TTY to USB converter hooked up with my Raspberry Pi. I'm using Pyserial to setup the connection and write data to the port in a script called pc_test.py. For some reason the script is able to run but it won't write anything to the port and will not throw any errors. PuTTy will hang there until I hit control C, so I know it's doing something, just not the correct thing. And my TTY to USB converter has a little blue LED that flashes when data is read/written and this LED does not flash when this script runs. Also, it only runs if I type either "Python3 pc_test.py", "Python pc_test.py", and "Sudo Python pc_test.py"; however, if I try to run it with "Sudo Python3 pc_test.py" It gives an error saying:
Traceback (most recent call last): File "pc_test.py", line 1, in import serial ModuleNotFoundError: No module named 'serial'
I feel like this has to be something to do with the issue as I had very similar code running on a different Pi that I ran with sudo Python3. I did have some extreme difficulties installing pyserial this time for some reason. Simply typing "python3 -m pip install pyserial" would not work so I eventually got it by using the command:
python3 -m pip install --trusted-host=pypi.org --trusted-host=files.pythonhosted.org --user pyserial
Maybe this is what messed things up?
Here is the pc_test.py:
import serial
import RPi.GPIO as GPIO
import time,csv
ser=serial.Serial("/dev/ttyAMA0",9600)
print(ser.name)
while True:
write_ser=ser.write("1".encode())
time.sleep(0.1)