@@ -315,133 +315,9 @@ remotely.
315
315
Pi Zero USB OTG
316
316
===============
317
317
318
- The `Raspberry Pi Zero `_ and `Pi Zero W `_ feature a USB OTG port, allowing users
319
- to configure the device as (amongst other things) an Ethernet device. In this
320
- mode, it is possible to control the Pi Zero's GPIO pins over USB from another
321
- computer using remote pins.
318
+ Continue to:
322
319
323
- GPIO expander method - no SD card required
324
- ------------------------------------------
325
-
326
- The GPIO expander method allows you to boot the Pi Zero over USB from the PC,
327
- without an SD card. Your PC sends the required boot firmware to the Pi over the
328
- USB cable, launching a mini version of Raspbian and booting it in RAM. The OS
329
- then starts the pigpio daemon, allowing "remote" access over the USB cable.
330
-
331
- At the time of writing, this is only possible using either the Raspberry Pi
332
- Desktop x86 OS, or Ubuntu (or a derivative), or from another Raspberry Pi. Usage
333
- from Windows and Mac OS is not supported at present.
334
-
335
- Raspberry Pi Desktop x86 setup
336
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
337
-
338
- 1. Download an ISO of the Raspberry Pi Desktop OS from raspberrypi.org (this
339
- must be the Stretch release, not the older Jessie image).
340
-
341
- 2. Write the image to a USB stick or burn to a DVD.
342
-
343
- 3. Live boot your PC or Mac into the OS (select "Run with persistence" and your
344
- computer will be back to normal afterwards).
345
-
346
- Raspberry Pi (Raspbian) setup
347
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
348
-
349
- 1. Update your package list and install the ``usbbootgui `` package:
350
-
351
- .. code-block :: console
352
-
353
- $ sudo apt update
354
- $ sudo apt install usbbootgui
355
-
356
- Ubuntu setup
357
- ~~~~~~~~~~~~
358
-
359
- 1. Add the Raspberry Pi PPA to your system:
360
-
361
- .. code-block :: console
362
-
363
- $ sudo add-apt-repository ppa:rpi-distro/ppa
364
-
365
- 2. If you have previously installed ``gpiozero `` or ``pigpio `` with pip,
366
- uninstall these first:
367
-
368
- .. code-block :: console
369
-
370
- $ sudo pip3 uninstall gpiozero pigpio
371
-
372
- 3. Install the required packages from the PPA:
373
-
374
- .. code-block :: console
375
-
376
- $ sudo apt install usbbootgui pigpio python3-gpiozero python3-pigpio
377
-
378
- Access the GPIOs
379
- ~~~~~~~~~~~~~~~~
380
-
381
- Once your PC or Pi has the USB Boot GUI tool installed, connecting a Pi Zero
382
- will automatically launch a prompt to select a role for the device. Select
383
- "GPIO expansion board" and continue:
384
-
385
- .. image :: images/gpio-expansion-prompt.png
386
-
387
- It will take 30 seconds or so to flash it, then the dialogue will disappear.
388
-
389
- Raspberry Pi Desktop and Raspbian will name your Pi Zero connection ``usb0 ``. On
390
- Ubuntu, this will likely be something else. You can ping it (be sure to use
391
- ``ping6 `` as it's IPv6 only) using the address ``fe80::1% `` followed by the
392
- connection string. You can look this up using ``ifconfig ``.
393
-
394
- Set the ``GPIOZERO_PIN_FACTORY `` and ``PIGPIO_ADDR `` environment variables on
395
- your PC so GPIO Zero connects to the "remote" Pi Zero:
396
-
397
- .. code-block :: console
398
-
399
- $ export GPIOZERO_PIN_FACTORY=pigpio
400
- $ export PIGPIO_ADDR=fe80::1%usb0
401
-
402
- Now any GPIO Zero code you run on the PC will use the GPIOs of the attached Pi
403
- Zero:
404
-
405
- .. image :: images/gpio-expansion-example.png
406
-
407
- Alternatively, you can set the pin factory in-line, as explained above.
408
-
409
- Read more on the GPIO expander in blog posts on `raspberrypi.org `_ and
410
- `bennuttall.com `_.
411
-
412
- Legacy method - SD card required
413
- --------------------------------
414
-
415
- The legacy method requires the Pi Zero to have a Raspbian SD card inserted.
416
-
417
- Start by creating a Raspbian (desktop or lite) SD card, and then configure the
418
- boot partition like so:
419
-
420
- 1. Edit ``config.txt `` and add ``dtoverlay=dwc2 `` on a new line, then save the
421
- file.
422
-
423
- 2. Create an empty file called ``ssh `` (no file extension) and save it in the
424
- boot partition.
425
-
426
- 3. Edit ``cmdline.txt `` and insert ``modules-load=dwc2,g_ether `` after
427
- ``rootwait ``.
428
-
429
- (See guides on `blog.gbaman.info `_ and `learn.adafruit.com `_ for more detailed
430
- instructions)
431
-
432
- Then connect the Pi Zero to your computer using a micro USB cable (connecting it
433
- to the USB port, not the power port). You'll see the indicator LED flashing as
434
- the Pi Zero boots. When it's ready, you will be able to ping and SSH into it
435
- using the hostname ``raspberrypi.local ``. SSH into the Pi Zero, install pigpio
436
- and run the pigpio daemon.
437
-
438
- Then, drop out of the SSH session and you can run Python code on your computer
439
- to control devices attached to the Pi Zero, referencing it by its hostname (or
440
- IP address if you know it), for example:
441
-
442
- .. code-block :: console
443
-
444
- $ GPIOZERO_PIN_FACTORY=pigpio PIGPIO_ADDR=raspberrypi.local python3 led.py
320
+ * :doc: `pi_zero_otg `
445
321
446
322
447
323
.. _RPi.GPIO : https://pypi.python.org/pypi/RPi.GPIO
@@ -451,9 +327,3 @@ IP address if you know it), for example:
451
327
.. _get-pip : https://pip.pypa.io/en/stable/installing/
452
328
.. _following this guide : https://www.raspberrypi.org/learning/using-pip-on-windows/worksheet/
453
329
.. _Sense HAT : https://www.raspberrypi.org/products/sense-hat/
454
- .. _Raspberry Pi Zero : https://www.raspberrypi.org/products/raspberry-pi-zero/
455
- .. _Pi Zero W : https://www.raspberrypi.org/products/raspberry-pi-zero-w/
456
- .. _raspberrypi.org : https://www.raspberrypi.org/blog/gpio-expander/
457
- .. _bennuttall.com : http://bennuttall.com/raspberry-pi-zero-gpio-expander/
458
- .. _blog.gbaman.info : http://blog.gbaman.info/?p=791
459
- .. _learn.adafruit.com : https://learn.adafruit.com/turning-your-raspberry-pi-zero-into-a-usb-gadget/ethernet-gadget
0 commit comments