How to run Raspberry Pi Zero by a micro-USB cable and a Mac

Yiqiang Zhao
3 min readNov 21, 2019

--

We love Raspberry Pi Zero, but sometimes we hate the way we connect to it.

Micro-USB and Mini-HDMI all come with such a cool but scary prefix that increase simplicity while decreasing its connectivity. So here comes the problem: If I have no keyboard, no monitor, no power adapter, with just a Pi Zero, a Mac and a micro USB cable, how can I use my Raspberry Pi Zero?

No worry. I’ve used the following method for the sensors used in my research field studies for many many times. Here is the solution:

First part: pre-configuration
1. Install the OS, not matter Raspbian or NOOB. Go to the official website, download the OS file and burn it onto your microSD card. If you don’t know how to do it, follow the official tutorial here: https://www.raspberrypi.org/documentation/installation/installing-images/README.md
2. take out your SD card reader from your Mac and then re-insert it. Go to the SD card drive folder and you’ll see lots of files.
3. Open the file config.txt, go to the last row and insert a new row:

dtoverlay=dwc2

, then save it and quit.
4. Open the file cmdline.txt, insert after the word rootwait with

modules-load=dwc2,g_ether

, then save it and quit.

5. At the root path of your sd card, add a new empty file called ssh. (In Terminal, you can type

touch ssh

, then in finder click and drag it from desktop to the SD card drive)

Second part: Connection
1. Connect your Raspberry Pi Zero to your Mac by micro-USB cable. Wait for probably about 1 min for the OS initialisation.
2. Go to terminal and type:

ssh pi@raspberrypi.local

, then type the default login detail:

password: raspberry

After that, depending on your OS version, if the system asks yes/no to continue the connection, type y to continue and congratulation, you have connected the Raspberry Pi Zero!

If not, (which I think 80% of you will come to this direction), it might show lines of strange errors talking about something such as WARNING: POSSIBLE DNS SPOOFING DETECTED! . NO WORRY! Open the Terminal, type

open .ssh 

and the system will pop up a file named known_hosts.

Open it, and delete all the stuff there, save and quit. Go back to the terminal and retype `ssh pi@raspberrypi.local`. It’s working, isn’t it.

Cheers! 🤟

ps: First, this method is only ok for Raspberry Pi Zero. I haven’t tested the other devices. Second, I didn’t mention the directory of the Terminal. Here I just use the default ~. if you are familiar with UNIX, do whatever you want about changing the directory, copy etc.

If you have questions, please leave it at the comments. Thank you!

--

--

Yiqiang Zhao

PhD candidate at the University of Edinburgh. Architect🏛, iOS developer🖥, environment science tutor👨🏻‍🏫.