Issue
I have a Raspberry Pi Zero W running a variation of Debian. I am trying to communicate with it from a Linux PC via a micro-USB cable. I have been unable to activate gadget mode and use that, I suspect it is due to the heavily-modified OS.
I have been looking into serial communication with the devices in the /dev directory. To my understanding, they act similarly to how file descriptors work in C?
I have been trying to echo
text to the device, and am doing that like so:
echo test > /dev/ttyS4
I have echo'd to my own terminal using this strategy to see if I had any sense of direction, and it did work.
Is it possible to monitor some output on the device and watch for this output?
Or am I completely off track here?
Thanks.
Solution
The Pi serial ports are on GPIO pins 14 and 15 (see e.g. https://www.raspberrypi.com/documentation/computers/raspberry-pi.html); you need a ttl-to-serial adapter (like this) to connect them to your computer. These pins should correspond to device /dev/serial0
(which is itself a symbolic link to the actual device name, which may be different on different models or different os versions).
If you want to do serial over the microusb port, you must enable gadget mode (and specifically enable a serial gadget). There are several articles online that walk you through the process; this one on adafruit is probably a reasonable place to start.
If you try following those instructions and run into problems, consider opening a new question on https://raspberrypi.stackexchange.com/ and include specific details about what you tried, what happened, etc.
Answered By - larsks Answer Checked By - David Goodson (WPSolving Volunteer)