1. 通过修改树莓派系统的配置 ,打开usb端口模拟网卡的功能.然后可以通过这个虚拟的网口,用ssh方式或者vnc方式控制树莓派.对树莓派0这种端口很少的设备非常管用.
Setting up a headless setup for Pi Zero W is simple. The limitation of Pi Zero and Zero W is that it doesn’t have an Ethernet port. All we have is a single USB port. We need to use it as an Ethernet via USB technique to access the Pi. There are many tutorials available for this. But if you are using Windows 10 you might be faced the problem with RNDIS driver. The RNDIS driver will install automatically on all operating systems but not in Windows 10. In Windows10 the Pi Zero W detects as a Serial USB Device instead of RNDIS Device. RNDIS is an Ethernet via USB driver which enables virtual Ethernet connection link between the Pi and your Laptop. I tried downloading the drivers and installed but most drivers didn’t work. Then finally I found a driver link in a forum and I tried installing it manually and it’s worked. So I’m going to explain the complete steps for this headless setup along with driver installation. If you are facing issue only at the driver installation part you can directly continue with step 9.
Software Required for Headless setup:
- SD Card Formatter Software
- Win32 Disk Imager Software
- VNC Viewer
- Putty Software
- Sublime Text or Notepad++
- Raspbian OS (Raspbian Stretch)
- RNDIS Driver from MOD (Musical Operating Devices). They are using this driver on their musical devices and it works with Raspberry Pi also. Click here to download the driver. Also, check this forum for more details.
The Pi Zero W has in-built Wi-Fi, so you can use the headless Wi-Fi Setup too. Check out the Headless Wi-Fi setup tutorial here.
Step 1: Format the SD card with SD card formatter.
Note: NOOBs will not work with this set up (NOOBs is Just an OS installer). So, we need Raspbian. The Current version is Raspbian Stretch. A Raspbian OS is an image file with the ‘.img’ extension (It also comes with ‘.zip’ file you have to extract it before flashing).
Step 3: Once flashing done. Navigate to the SD Card folder. You can able to see the files extracted from the image.
Step 4: Now open ‘cmdline.txt’ file and add this at the end of the file. (Make sure it is at the end of the file not in newline).
Step 5: Now we need to modify the ‘config.txt’ file. So open the ‘config.txt’ file in text editor. Then add the following line anywhere in the file (will be in a newline).
Now save this file and close it.
Step 6: SSH is disabled default in new Raspbian OS. You can enable it by simply create an empty file and name it as ssh without any extension. Make sure the file name extensions option is selected in windows view settings.
Step 7: Eject the microSD card from the computer and place it in the Raspberry Pi. Then connect the PC and Raspberry Pi via USB cable. You don’t need external power as the Pi zero W USB pin provides power as well as data transfer. Wait until the pi boots up completely. It might take up to 90 Seconds.
Step 8: If the RNDIS driver installs automatically then jump to Step 10 for SSH using Putty. If it installs as a USB Serial Device then continue the following steps. You can check this in Device Manager. In Windows 10 the RNDIS Driver installs as a USB Serial Device at COM Port. So we need to install drivers to manually enable Ethernet over USB.
Step 9: Open Device Manager and you can see the Pi is detected as USB Serial Device at COM port under the PORTS & LPT. Right click on it and select “Update Driver Software”.
Select ‘Browse my computer for driver software’.
Choose the location where you extracted the driver files on your PC.
Select the Extracted driver folder which is mod-duo-rndis. Click ok and click Next. This will install the driver.
Now you can able to see the Pi Zero W as RNDIS in Network adapters.
Step 10: Make sure you have installed Bonjour Service (Apple Inc.) on your PC. It is a service to discover the Shared resources on the network and web servers. If you have iTunes installed on your PC, then it had been already installed. If Bonjour is not installed then the Hostname will not be mapped with IP. So you are not able to use Hostname (eg: raspberripi.local) in Putty (You can use direct IP of Pi. But finding the IP will be complex for headless setup).
Open Putty and enter the Host Name as ‘raspberrypi.local’ and port as 22. Click open, this will open a terminal window asking for username and password.
Step 11: Enter the default username as ‘pi’ and default password as ‘raspberry’.
Step 12: Now type vncserver in the terminal window. This will run the virtual server on the raspberry pi.
Step 13: Now go to Google Chrome and open VNC Viewer App (You need to install from google apps store or visit website).
Step 14: Enter the Hostname as ‘raspberrypi.local:1’(Hostname or IP address of Pi with :1 at the end.)