summersab
Posts: 21
Joined: Thu Aug 27, 2015 6:15 pm

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

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?

klricks
Posts: 6793
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

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

Sat Jan 18, 2020 6:38 am

What device name are you using?
I think you need to use /dev/serial0
Unless specified otherwise my response is based on the latest and fully updated Raspbian Buster w/ Desktop OS.

summersab
Posts: 21
Joined: Thu Aug 27, 2015 6:15 pm

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

Sat Jan 18, 2020 5:57 pm

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.

Earlton2
Posts: 65
Joined: Mon May 27, 2013 1:13 am
Location: Tonight it's -28C
Contact: Website

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

Sun Jan 19, 2020 3:09 am

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!

ejolson
Posts: 4287
Joined: Tue Mar 18, 2014 11:47 am

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

Sun Jan 19, 2020 3:47 am

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.

Return to “Interfacing (DSI, CSI, I2C, etc.)”