Monday, 4 April 2016

Raspberry Pi Gadget

The latest issue of MagPi magazine contains instructions on how to create a Raspberry Pi Gadget. That's a Pi Zero that you plug into a host machine's USB port. The host machine sees the USB gadget as a network interface and can therefore communicate with the Pi. The Pi Zero draws its power from the host machine across the USB connection and can use any connected networks on the host machine.

To much fun to pass up really. As the MagPi article refers to, there are also instruction on the adafruit site. Both sources state the need for a USB to serial TTL console cable that allows you to communicate with the Pi Zero over the serial port. I found that because I already had my Pi Zero set up and available on my network through an ethernet connection, I could perform all the setup on the Pi Zero just by ssh-ing to it before shutting down and using it as a gadget with my laptop.

Other than that, everything worked as described in the articles apart from DNS settings.

I couldn't get the Windows Internet Connection to share DNS service with the Pi. It allocated an IP fine and delivered itself as the DNS server (it got written to /etc/resolv.conf on the Pi) but the laptop didn't respond to any requests. Probably a problem with my laptop settings, but my quick fix was to add a couple of lines to /etc/resolv.conf.head that pointed at my home network and nameserver.

domain myhome.net
nameserver 192.168.19.62

and all works fine.

I have to figure out a proper solution for when I'm out and about and want to share a wireless connection - but I can always fall back on editing /etc/resolv.conf.head and reloading everything with

sudo ifdown usb0
sudo ifup usb0

I needed a case for the gadget. The MagPi article shows a naked Pi Zero attached to a laptop with a simple cableless USB Micro B to A converter. It does look cool - but years of experience of destroying USB things and connectors with dongles that stick out of the side of laptops made me think "case and cable needed".

I've recently discovered the wonders of hot glue guns and have a case bought with my first Raspberry Pi Model B. The case has always been fairly pointless as you can't get at the GPIO pins with it closed. It isn't pointless anymore.







Still necessary to open the case to get at GPIO pins but at least now they won't be encrusted with discarded food chunks from my laptop bag.

No comments:

Post a Comment