Whale Oracle with OpenWRT
Project Description
The Whale Oracle is a physical object that users can interact with through a website. The setup involves 2 wireless routers, a Raspberry Pi controlling an LED array, and a website hosted on a remote VPS. The travel router, Whaley, connects over wifi to the larger router, WhaleyHub, which is connected over ethernet to the home network. A webcam is connected to WhaleyHub through USB, and the Raspberry Pi is connected to Whaley by ethernet.
In the future, other objects beside Whaley can be added to the WhaleyHub wireless network.
Hardware
Routers / Servers:
VPS |
n/a |
n/a |
Ubuntu 18.04.5 LTS (Bionic Beaver) |
n/a |
WhaleyHub |
TP-Link TL-WDR3600 ver 1.4 |
Atheros |
OpenWrt 18.06.2, r7676-cddd7b4c77 |
Webcam |
Whaley |
TP-Link TL-WR703N |
Atheros |
OpenWrt 14.07, r42625 (Barrier Breaker) |
|
RaspPi |
Raspberry Pi Model B+ V1.2 |
ARM |
Raspbian 10 Lite (Debian Buster) |
|
Webcams:
Bought a bunch of webcams and found that the UVC-compatible cams were easy to get working; non-UVC cams weren’t.
Logitech QuickCam Deluxe for Notebooks |
UVC (generic) |
Yes |
Creative Live! VF0520 |
UVC (generic) |
Yes |
Logitech C200 |
UVC (generic) |
Yes, but video is glitchy |
Logitech QuickCam Messenger |
gspca_zc3xx (generic) |
No - couldn’t find streaming software |
D-Link DSB-C300 |
ov511 (specific) |
No - didn’t bother trying to install driver |
Addresses
VPS |
n/a |
http://hwsrv-640154.hostwindsdns.com |
n/a |
Home |
192.168.2.1 |
Dynamic |
n/a |
WhaleyHub |
192.168.1.1 |
192.168.2.45 |
192.168.2.1 (Home) |
WhaleyHub - LuCI |
192.168.1.1:80 |
192.168.2.45:50080 |
|
WhaleyHub - SSH |
192.168.1.1:22 |
192.168.2.45:50022 |
|
Whaley |
192.168.1.2 |
n/a |
192.168.1.1 (WhaleyHub) |
Whaley - LuCI |
192.168.1.2:80 |
192.168.2.45:60080 |
|
Whaley - SSH |
192.168.1.2:22 |
192.168.2.45:60022 |
|
RaspPi |
192.168.1.3 |
n/a |
192.168.1.1 (WhaleyHub) |
OpenWRT Setup
OpenWRT 1st access:
- Reset WhaleyHub’s OpenWrt to default settings by holding in reset button until lights flash
- Connect WhaleyHub to home router through WAN ethernet port
- Connect WhaleyHub to PC through LAN ethernet port
- Set PC to static IP:
- In Windows 10: Control Panel -> View Network Connections, right-click on Ethernet -> Properties, click on IPv4 -> Properties.
- Set the PC’s IP to something in the correct subnet, set the subnet mask & set the gateway to the router’s IP.
IP |
192.168.1.10 |
Default Gateway |
192.168.1.1 |
Subnet Mask |
255.255.255.0 |
- Connect to WhaleyHub through LuCI web interface at 192.168.1.1
- Set root password, etc.
Starting with a fresh OpenWrt installation:
- Reset the 2 routers thru LuCI. Originally connected to each router in turn through ethernet (had to set PC IP to 192.168.1.x).
- Whaley:
- Connected to Whaley’s LuCI at 192.168.1.1
- Prompted to set password, enabled remote SSH access
- WhaleyHub:
- Connected to WhaleyHub’s LuCI at 192.168.1.1
- Set password, enabled remote SSH access
- Logged in to SSH, can
ping 8.8.8.8
= DNS working, internet accessible
- Made sure physical wireless switch is set to on
- Enabled 802.11an wireless (radio0) – OpenWrt wireless network appears
- Note: chose radio0 (2.4 GHz) because Whaley couldn’t see radio1 (5 GHz)
- Disconnected laptop from ethernet, joined OpenWrt wireless network
- Can
ping 8.8.8.8
= DNS working, internet is accessible
- Renamed OpenWrt wireless network to WhaleyHub
Connecting WhaleyHub & Whaley
Determining what setup to use to connect WhaleyHub and Whaley:
Setting up a WDS wireless network bridge (aka repeater):
- Following openwrt.org/docs/guide-user/network/wifi/atheroswds:
- WhaleyHub: the Access Point:
- Under the section “LuCI”:
- Network → wireless → edit (Interface Configuration): change Mode from Access Point to Access Point (WDS)
- Remember to hit “Save & Apply”
- Whaley:
- Follow the initial instructions for the terminal, under “The remote wireless station”:
vi etc/config/dhcd
to disable dhcp on lan
vi etc/config/network
to change the static IP
- Reboot
- Follow the remaining LuCI instructions under “The remote wireless station”:
- Scan to join WhaleyHub’s wireless, set firewall to lan
- Set wireless mode to Client (WDS), change Network from wwan to lan
- Network → DHCP & DNS: set DNS forwardings to 192.168.1.1
- Network → Interfaces → LAN → Edit: set IPV4 gateway to 192.168.1.1
- Physical Settings: Enable STP
- Note: can add another wifi network in order to connect to Whaley thru wifi
- In Whaley’s terminal
ping 192.168.1.1
to make sure you’re connected to WhaleyHub wirelessly
ping 8.8.8.8
to make sure Whaley can reach the outside internet.
Accessing Luci & SSH over WAN
- Allow ping + SSH + LuCI access over WAN (WAN with respect to WhaleyHub = home LAN). Add port forwards in WhaleyHub’s LuCI (Network → Firewall → Port Forwards)
- ping WhaleyHub: IPv4-tcp, udp From any host in wan Via any router IP -> IP 192.168.1.1, port 7 in lan
- SSH WhaleyHub: IPv4-tcp udp From any host in wan Via any router IP at port 50022 -> IP 192.168.1.1, port 22 in lan
- SSH whaley: IPv4-tcp, udp From any host in wan Via any router IP at port 60022 -> IP 192.168.1.2, port 22 in lan
- LuCI WhaleyHub: IPv4-tcp, udp From any host in wan Via any router IP at port 50080 -> IP 192.168.1.1, port 80 in lan
- LuCI whaley: IPv4-tcp, udp From any host in wan Via any router IP at port 60080 -> IP 192.168.1.2, port 80 in lan
Debugging Connection Problems
- WhaleyHub LuCI:
- System → Startup: toggle firewall to Disabled
- reboot the router
Setting up WPA encryption on WhaleyHub
Setting up a webcam on WhaleyHub
Connect to WhaleyHub though PuTTY
Installing usb driver packages: openwrt.org/docs/guide-user/storage/usb-installing
Useful commands:
opkg update
opkg list-installed | grep
opkg install
- Plug in usb device +
dmesg
Installing webcam drivers: openwrt.org/docs/guide-user/hardware/video/webcam
Installing streaming software:
opkg install mjpg-streamer
vi etc/config/mjpg-streamer
-> set enabled to 1
Setting up a basic streaming website:
- Setting up local streaming on the router’s LAN:
/etc/init.d/mjpg-streamer start
- Visit video at 192.168.1.1:8080 (username: openwrt, password: openwrt)
- Start webcam stream at boot
- System → Startup → Local Startup: Add
/etc/init.d/mjpg-streamer start
- Allow video feed access from a device in our home LAN:
- In LuCI → Network → Firewall → Port Forwards: Open up port 8080
- Now can visit the video at WhaleyHub’s external IP, which I set to 192.168.2.45 in the home router.
- Allow video feed access from the outside internet via our home’s external IP:
- In home router, opened port 8080 and forwarded it to WhaleyHub
- Now can visit the video at our home’s external (dynamic) IP
- Hosting a temporary website on my VPS, embedding video from our home IP:
- SSH into WhaleyHub, disable mjpg-streamer authentication:
vim /etc/config/mjpg-streamer
- Remove the username and password lines with
dd
/etc/init.d/mjpg-streamer restart
- In VPS, create a webpage with the video embedded in an iframe
- Note: can’t be tested from own internet (eg: need to use cell phone w data)
Debugging the video feed:
- Test feed as a client of WhaleyHub: 192.168.1.1:8080
- Test feed as a client of Home Router: 192.168.2.45:8080
- port 8080 needs to be open on WhaleyHub
- Test feed @ Home External IP: [dynamic IP]:8080
- port 8080 need to be open on Home router & forwards to WhaleyHub
- Test feed @ VPS (embedded from Home IP): http://hwsrv-640154.hostwindsdns.com/whaley/whaley.html
- Need to have a webserver running on VPS
- Remember to update our home IP (since it’s dynamic) in whaley.html