- Raspberry Pi Zero Cookbook
- Edward Snajder
- 424字
- 2021-07-09 19:12:12
Programming over a virtual Ethernet modem on USB OTG
This is my favorite way to connect to the Raspberry Pi Zero. Not only can you operate it with a single USB cable, but you can get it attached to the network and be able to communicate with other machines and the Internet.
Getting ready
The same as the last recipe, if you have the USB OTG functions installed and a regular-to-micro USB cable, you are ready to go.
How to do it...
Just like the last recipe, be careful with the edits to cmdline.txt
. You can make this change from the serial connection you made before, reboot, and go!
- The unedited version of the file should look something like this:
pi@rpz14101:~$ sudo cat /boot/cmdline.txt dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
If you're coming from the previous recipe, it will look like this:
pi@rpz14101:~$ sudo cat /boot/cmdline.txt dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait modules-load=dwc2,g_serial
- We want our new configuration to look like this:
pi@rpz14101:~$ sudo cat /boot/cmdline.txt dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait modules-load=dwc2,g_ether
- After you make the change, you can use
sudo reboot
. You'll see the COM device disappear from the device manager and should see a new device come up in the Network Adapters tree: - Now, you can connect your Raspberry Pi through your USB cable using SSH:
If the Bonjour service is running on Windows (or avanti-daemon
on Linux), you should be able to SSH to raspberrypi.local
.
Note
The default hostname for the Raspberry Pi is raspberrypi
. If you changed the name of your Zero in raspi-config
or using the hostname
command, the connection will be hostname.local
. For instance, if I change my Raspberry Pi Zero's name to rpz14101
, then I will SSH to rpz14101.local
.
Another great thing about using SSH to connect the Raspberry Pi Zero is if you configure your host machine's network adapter to allow Internet sharing, your Zero can communicate with the Internet! On Windows, go to Network connections in Control Panel, select the adapter that's connected to your home network, and enable Internet Connection Sharing. Here's where you can find the option in Windows:

On OS X go to System Preferences -> Sharing -> Internet Sharing and Choose the "RNDIS/Ethernet Gadget." Check the box to start sharing. On Linux machines, it varies by distro and version, check the docs or community forums for Internet Connection Sharing.
With this setting, your Pi Zero can use your host computer's adapter to talk to other devices on the home network or over the Internet.
- Hands-On Intelligent Agents with OpenAI Gym
- 數(shù)據(jù)展現(xiàn)的藝術(shù)
- Google Cloud Platform Cookbook
- 平面設(shè)計(jì)初步
- 數(shù)據(jù)庫(kù)原理與應(yīng)用技術(shù)
- 21天學(xué)通Visual C++
- 完全掌握AutoCAD 2008中文版:機(jī)械篇
- 網(wǎng)站前臺(tái)設(shè)計(jì)綜合實(shí)訓(xùn)
- Practical Big Data Analytics
- Godot Engine Game Development Projects
- 簡(jiǎn)明學(xué)中文版Photoshop
- Building Google Cloud Platform Solutions
- 案例解說(shuō)Delphi典型控制應(yīng)用
- Practical AWS Networking
- RealFlow流體制作經(jīng)典實(shí)例解析