Page 1 of 1

Serial on RPi B works; won't work on RPi Zero W

Posted: Sat Jan 18, 2020 4:40 am
by summersab
I have an old RPi B (yes, the 2012 board) that I used to prototype a serial device. I went to move everything to a RPi Zero W so it would fit in a smaller project case, but I couldn't get the serial connection to work. Things I tried:
  • Yes, I have disabled the terminal on the serial port, edited /boot/cmdline.txt and /boot/config.txt, etc.
  • I thought maybe I did a bad job soldering and damaged my Zero W, so I tested it on another Zero W. Same result.
  • I cloned the SD card from my RPi B to my micro SD for the Zero W using dd. Same result.
  • I downloaded the latest Raspbian and started fresh. Same result.
What on earth am I missing?

Re: Serial on RPi B works; won't work on RPi Zero W

Posted: Sat Jan 18, 2020 6:38 am
by klricks
What device name are you using?
I think you need to use /dev/serial0

Re: Serial on RPi B works; won't work on RPi Zero W

Posted: Sat Jan 18, 2020 5:57 pm
by summersab
I've tried accessing ttyAMA0, ttyS0, serial0, serial1, etc. None of them give me any output. To test, I'm hooking up an ESP8266 that is sending a continuous stream of "Hello" messages. When I do a simple `cat` of the block device on the RPi B, I get data. Nothing happens on the Zero.

Here's my cmdline.txt:

Code: Select all

dwc_otg.lpm_enable=0 console=tty1 root=PARTUUID=700539e0-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
Here are the only uncommented lines from my config.txt:

Code: Select all

dtparam=audio=on
enable_uart=1
I've read a few things about needing to disable Bluetooth with an overlay, and I tried a few things, there (I don't remember exactly - that was a few days ago). Still, it seems as if this should be working just fine ESPECIALLY with the SD card image that I `dd`'d from my RPi B.

Re: Serial on RPi B works; won't work on RPi Zero W

Posted: Sun Jan 19, 2020 3:09 am
by Earlton2
In raspi-config I set:

1. Interface > Serial > ... login .. accessible over serial > NO
2. ... serial port hardware to be enabled > YES

I'm using WiringPi to access serial:

if (wiringPiSetup() == -1) ....

if ((ftmp = serialOpen ("/dev/serial0", baud)) < 0) << part of set-up, int ftmp - file descriptor >>

rByte = serialGetchar (ftmp); << read char >>

serialPutchar (ftmp, cCAL); << transmit >>

serialFlush(ftmp)

The above just grabbed from some old code so might not stay on-the-rails!

Re: Serial on RPi B works; won't work on RPi Zero W

Posted: Sun Jan 19, 2020 3:47 am
by ejolson
summersab wrote:
Sat Jan 18, 2020 4:40 am
I have an old RPi B (yes, the 2012 board) that I used to prototype a serial device. I went to move everything to a RPi Zero W so it would fit in a smaller project case, but I couldn't get the serial connection to work. Things I tried:
  • Yes, I have disabled the terminal on the serial port, edited /boot/cmdline.txt and /boot/config.txt, etc.
  • I thought maybe I did a bad job soldering and damaged my Zero W, so I tested it on another Zero W. Same result.
  • I cloned the SD card from my RPi B to my micro SD for the Zero W using dd. Same result.
  • I downloaded the latest Raspbian and started fresh. Same result.
What on earth am I missing?
On the the Pi Zero W the serial port corresponding to the full UART that you are using on the original B is internally connected to the WiFi. From what I understand, the mini UART instead appears on the GPIO pins on the Zero. I think there are ways to disable WiFi and route the full UART back to GPIO on the Zero W, but I don't know the details.

At any rate, the short answer is that the hardware has changed and your software may need to change as well.