Raspberry Pi Zero Wi-Fi USB Adapter Installation: TP-Link Archer T2U

R. X. Seger
4 min readOct 4, 2016

--

Bought a TP-Link AC600 “Wireless Dual Band USB Adapter” Model No. Archer T2U, in order to add wireless network connectivity to a Raspberry Pi Zero. Why this particular Wi-Fi USB adapter? It supports 802.11ac/5GHz, and I was able to purchase it locally.

Also considered a device with out-of-the-box Linux support, including:

The TP-Link Archer T2U uses the mt7610u driver provided by the vendor. Even shows “Linux” as a supported operating system on the box. Note: not to be confused with the mt7601u driver, similarly named but not the same: 01 vs 10. The ’01u is included in Linux and Raspbian, but if you load it (modprobe mt7601u) the Archer T2U won’t use it, because it needs the ‘10u driver. At the time of this writing, you have to build it (mt7610u) yourself.

Connecting via Serial

Started connecting to the device using serial. Used the SparkFun FTDI Basic Breakout — 3.3V, wired to the GPIO header pins 6 (ground), 8 (TXD), and 10 (RXD):

then connected to the serial port on a PC. Press enter and login with pi/raspberry.

Building the mt7610u driver

Follow instructions from mt7610u_wifi_sta_v3002_dpo_20130916:

git clone https://github.com/lixz789/mt7610u_wifi_sta_v3002_dpo_20130916
make
sudo make install
sudo cp RT2870STA.dat /etc/Wireless/RT2870STA/RT2870STA.dat
sudo reboot

Fails on “make” with an error about a missing directory:

/lib/modules/4.4.17-v17/build

To get the “build” directory:

sudo apt-get install raspberrypi-kernel-headers

but this installed /lib/modules/4.4.21-v7+ headers. Updated the OS with:

sudo apt-get upgrade

and reboot. `uname -a` should now show 4.4.21-v7+.

Installing kernel headers without network connectivity

But the first step presents a problem on the Zero: how to install the kernel headers package without a network connection? One option is to use a virtual Ethernet interface through USB OTG to another computer, see RASPBERRY PI ZERO — PROGRAMMING OVER USB! (PART 2), but another is to download the .deb file, copy to a USB disk, and install manually:

dpkg -i raspberrypi-kernel-headers_1.20160921–1_armhf.deb

also copied the mt7610u git repository to the USB stick, then build:

make

Initially attempted to build on a Raspberry Pi 3, then copied over the built output to the Raspbery Pi Zero, but it failed to load with “symbols disagree” (differing kernel versions?). Compiled on the Zero instead, wait a while.

And keep waiting… until compilation completes. Long time, but it finishes. Finally, complete installation and reboot:

sudo make install
sudo cp RT2870STA.dat /etc/Wireless/RT2870STA/RT2870STA.dat
sudo reboot

Configuring the Wi-Fi client

Plug in the device and `ifconfig -a` should now show ra0.

Edit /etc/wpa_supplicant/wpa_supplicant.conf:

network={
ssid=your network name here
psk=your passphrase here
key_mgmt=WPA-PSK
}

To differentiate this Raspberry Pi Zero from the other Raspberry Pi 3 I had, edited /etc/hostname, changed to raspberrypizero from raspberrypi. Reboot and Wi-Fi should be working perfectly now.

These instructions are relatively short, but it took a few hours to do all this.

Application: Wi-Fi Controlled AC Power Outlet

Now that we have a wireless Pi Zero, what is it good for?

There are many possibilities, I went with a simple wireless home automation application: controlling an AC power outlet. Using a 5v/220V relay, driven by a transistor via GPIO, as follows:

similar to a transducer driver, built on the same 5x7cm PCB prototyping board as covered in Notes on prototyping circuit boards: breadboards, perfboards, and beyond. I actually only had a SPST relay, as salvaged in Building an H-Bridge from a salvaged Uninterruptible Power Supply, so I only switched “hot” not “neutral”, see discussion in Relay: do you switch the hot or neutral. While I was at it, wired neutral through a fuse as well. Insides:

The relay is wired up to switch 3 AC outlets, the other 3 remain fixed on. Threaded the Pi Zero’s USB AC adapter through the case and plugged it into one of the always-on outlets. Write a trivial script to control the GPIO port:

I’m using these AC outlets to power a desk lamp, with a light fixture that wasn’t compatible with the Philips Hue bulbs (for previous experiments with Hue, see: Enabling the hidden Wi-Fi radio on the Philips Hue Bridge 2.0: Adventures with 802.11n, ZigBee 802.15.4 and OpenWrt), hence this project.

Currently it isn’t very practical: SSH’ing into the Pi Zero to run a command to turn on/off the lights, versus flipping a physical switch, not to mention SSH’ing in and shutting down the Pi Zero before unplugging the box. Nonetheless, controlling power outlets via the Pi opens up a whole new world of possibilities for future home automation projects (such as: voice control).

--

--