A DIY $12.06 + Tax WiFi USB Adapter/Bridge for SmartThings hub

hubv2
wifi

(Enis Hoca) #1

I recently had to repair a couple of Z-Wave devices a lock and switch on the other side of the house, and didn’t really feel like taking out my long ethernet cable to do the whole z-wave thing. I had a few of these parts left over from other projects. So I thought why not make a little wireless adapter that can connect the ST hub to wifi, and get rid of the hassle forever. It took about 45 minutes to do this, after googling and locating all the info.

IMG_2241%20copy

Parts list
$3.99 1x 4 GB MicroSD card - Microcenter

$5.00 Raspberry pi Zero W from Microcenter

$3.07 ENC28J60 LAN Ethernet Network Board Module Ebay

A few notes -

  1. This is not really a bridge in the networking sense - this is a NAT proxy much like your home network. Your hub will not be on your home network but in a network all by itself. Doesn’t really matter if you want to only talk to zigbee or z-wave devices, and you can also talk from your hub to other devices on your network, but you won’t be able talk from your network to the hub. Again this is not really for day to day use.

  2. The speed is around 3 Mb/s but in this case speed doesn’t really matter

  3. Smartthings setup instructions say “Don’t stack your SmartThings Hub directly on top of your wireless router.” So this is ok for going around and setting up things but not a permanent solution

  4. ST Hub USB doesn’t have enough power for the Raspberry Pi and the network adapter. I used a portable USB battery pack

  5. I am not a networking or electronics expert, these instructions are a result of googling and a bit of trial and error. I don’t think I can offer much assistance if things don’t go as expected. I have documented what worked for me, hopefully someone may find it useful.

Wiring:
Connection-scheme for the ENC28J60 on the Raspberry Pi Zero:

clk = not connected
wol = not connected
si  = GPIO10
cs  = GPIO8
vcc = +3.3v
gnd = 0v / gnd
rst = not connected
sck = GPIO11
so  = GPIO9
nt / int = GPIO25


Check out this Youtube video for more details

Setting up Rasberry PI
Download jessie lite from here http://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2017-07-05/2017-07-05-raspbian-jessie-lite.zip
Don’t use Stretch (current version as of Feb 2018) - it doesn’t work
Google how to setup a Jessie lite headless Pi or follow the instructions here
http://desertbot.io/setup-pi-zero-w-headless-wifi/

Enabling ethernet
To configure the Raspberry Pi Zero W, do the following on the command line:

$ sudo raspi-config

Go to “9 Advanced Options”, select “SPI” and Enable it.

edit /boot/config.txt
Add this line:

dtoverlay=enc28j60

reboot - the ethernet adapter should work - you can connect to your router and test

Setting up the Wireless Bridge
run the following commands on the Raspberry pi

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install dnsmasq

Assign a static IP address to eth0 the Pi side of ethernet which will be used as gateway. Edit the /etc/networ interfaces file

sudo nano /etc/network/interfaces

Make the eth0 section look like this

allow-hotplug eth0  
iface eth0 inet static  
address 192.168.2.1
netmask 255.255.255.0
network 192.168.2.0
broadcast 192.168.2.255

save away the original and create a new dnsmasq config file

sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig  
sudo nano /etc/dnsmasq.conf

Add the following to the file

interface=eth0      # Use interface eth0  
listen-address=192.168.2.1   
bind-interfaces
server=8.8.8.8        
domain-needed         
bogus-priv
dhcp-range=192.168.2.2,192.168.2.100,12h

Edit the /etc/sysctl.conf file to enable packet forwarding

sudo nano /etc/sysctl.conf

Remove the # from the beginning of the line containing net.ipv4.ip_forward=1

Now setup the NAT between wlan0 and eth0

sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE  
sudo iptables -A FORWARD -i wlan0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT  
sudo iptables -A FORWARD -i eth0 -o wlan0 -j ACCEPT
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"

now edit rc.local

sudo nano /etc/rc.local

and add this before exit 0

iptables-restore < /etc/iptables.ipv4.nat

reboot and enjoy

sudo reboot

Note - the instructions for setting up the networking are from here - https://raspberrypi.stackexchange.com/questions/48307/sharing-the-pis-wifi-connection-through-the-ethernet-port?answertab=active#tab-top

I have just followed the instructions and am not a networking expert, so if things don’t work tinker around, google, etc. I would do the same, and I am afraid I won’t be able to offer much help on this


(Eric) #2

45 minutes! I call shenanigans but you may be an actual McGyver. Excellent documents.

I will keep my 100ft ethernet handy.


(Geko) #3

Good idea, but to make it even less hassle, why not get a dirt-cheap used Wi-Fi router (you may event have one gathering dust in your closet), flash it with DD-WRT firmware and setup a Wi-Fi bridge? No need to mess with circuit boards and wires :stuck_out_tongue_winking_eye:


(Dana ) #4

C’mon, this is a great McGyver moment, gotta respect that! Excellent stuff, @enis.


(Enis Hoca) #5

I have old 54g linksys router running ddwrt but carrying everything around is a hassle, plus got to use the soldering iron once in a while :slight_smile: