2

I want to send/receive data between PC and Pi-Zero over USB port near PWR port.

I followed the instructions here https://www.tal.org/tutorials/raspberry-pi-zero-usb-serial-console But I don't enable

[email protected]

Pi appears as a serial device on Device Manager in Windows with port

COM13

. I wrote two scripts that will run on each side. On pc I have,

port = serial.Serial(port='COM13',  baudrate=115200,)
while True:
    num = port.write('hi\n')
    print num
    time.sleep(1)

This script successfully opens COM port and prints the number of bytes which is 3 bytes in this case.

On Pi zero,

/dev/ttyAMA0

appears as a serial device. And the code,

port = serial.Serial(port='/dev/ttyAMA0',  baudrate=115200,)
rec = port.read(3)
print rec

which opens the port successfully but outputs nothing, gets stuck in port.read instruction. What am I missing here?

2
  • try using a serial terminal program in windows, such as putty ... do same in linux .... that way you can change the settings easily, such as the baud rate
    – jsotola
    Dec 31, 2019 at 21:13
  • do you think that settings don't match?
    – eminakgn
    Dec 31, 2019 at 22:11

1 Answer 1

0

/dev/ttyAMA0 connects to either the GPIO serial port or Bluetooth (depending on Pi).

You need to find what device is the USB serial port and use that.

3
  • /dev/ttyAMA0 is the only device when I port = [str(port.device) for port in serial.tools.list_ports.comports()]
    – eminakgn
    Jan 1, 2020 at 12:20
  • @eminakgn /dev/ttyAMA0 maybe the only device you see, but there is absolutely no point in trying to use it. You will have to fix whatever you did wrong, but as you haven't explained no one can say.
    – Milliways
    Jan 2, 2020 at 1:07
  • I linked the tutorial that I followed. I should not be supposed that explaining all the steps to configure g_serial module which is often used to emulate pi console on PC's serial port. But not to achieve that, I disabled [email protected] as I have explained. So that I thought I could use that COM port. Nevertheless, Pi is using that port for some reason maybe.When I disconnect DATA cable from Pi Zero, device disappears. So It has to be that port, not GPIO or Bluetooth?
    – eminakgn
    Jan 2, 2020 at 6:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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