Breathe new life into your old home router
USB Drives
To add USB drives, remotely SSH into the router and enter the code from Listing 1. After the USB packages are loaded, reboot the router.
Listing 1
Adding USB Drives Remotely
## update okpg is required to get info on new packages opkg update ## get packages for USB2/3 and ext4 type devices opkg install block-mount e2fsprogs kmod-fs-ext4 kmod-usb-storage kmod-usb2 kmod-usb3
Under the System menu, you will now see the Mount Points item has been added to the LuCI web interface. This option allows for easy addition and removal of portable USB drives (Figure 4).
Adding USB drives to a router opens up the possibility of a number of interesting projects, such as a SAMBA file/printer server, an FTP server, or a Network File System (NFS).
USB Webcam Project
For a fun router project, you can connect a USB webcam and start a video-streaming service. A number of excellent USB video solutions are available, but you need to ensure that the router's small memory size can accommodate the video package and all its dependencies. A good lightweight USB video option is mjpg-streamer
, which can be installed with the code in Listing 2.
Listing 2
Installing mjpg-streamer
## install video streaming software and nano editor opkg install kmod-video-uvc mjpg-streamer nano ## enable video service ## edit config file, and set "option enable '1' nano /etc/config/mjpg-streamer
Once you've installed mjpg-streamer
, you need to start the video service:
## to start the service: /etc/init.d/mjpg-streamer start ## to enable the service to start on boot /etc/init.d/mjpg-streamer enable
You can access the USB webcam as a web page from the router's IP with the default port of 8080 (Figure 5).
USB-Serial Connections
A router doesn't have external General Purpose Input/Output (GPIO) pins like a Raspberry Pi or an Arduino, but USB ports can be used to pass data.
Because there aren't a lot of USB sensors available, a good workaround to this problem is to use an older microcontroller. Low-end modules such as the Arduino Nano, littleBits Arduino Bit, or a BBC micro:bit can be directly connected to sensors, and the data can be passed with the USB-to-Serial interface.
To start the video service, you need to enable USB-to-Serial communications in OpenWRT:
## add USB-Serial packages opkg install kmod-usb-serial kmod-usb-acm ## add terminal config package opkg install coreutils-stty
For our project, we used a BBC micro:bit [4], which is very user-friendly for coding: It only took five blocks to send the on-board temperature reading and to show the value on the front panel (Figure 6).
The OpenWRT firmware runs a light version of the Bash shell called Ash. The Ash script in Listing 3 connects to the micro:bit USB port and prints out the temperature data.
Listing 3
Reading USB-Serial Data
#!/bin/ash # # microbit.sh - reads microbit temperature # # set terminal speed stty -F /dev/ttyACM0 115200 # read USB-Serial device (/dev/ttyACM0) while read -r line < /dev/ttyACM0; do echo " Temp: $line DegC" done
« Previous 1 2 3 4 Next »
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Thousands of Linux Servers Infected with Stealth Malware Since 2021
Perfctl is capable of remaining undetected, which makes it dangerous and hard to mitigate.
-
Halcyon Creates Anti-Ransomware Protection for Linux
As more Linux systems are targeted by ransomware, Halcyon is stepping up its protection.
-
Valve and Arch Linux Announce Collaboration
Valve and Arch have come together for two projects that will have a serious impact on the Linux distribution.
-
Hacker Successfully Runs Linux on a CPU from the Early ‘70s
From the office of "Look what I can do," Dmitry Grinberg was able to get Linux running on a processor that was created in 1971.
-
OSI and LPI Form Strategic Alliance
With a goal of strengthening Linux and open source communities, this new alliance aims to nurture the growth of more highly skilled professionals.
-
Fedora 41 Beta Available with Some Interesting Additions
If you're a Fedora fan, you'll be excited to hear the beta version of the latest release is now available for testing and includes plenty of updates.
-
AlmaLinux Unveils New Hardware Certification Process
The AlmaLinux Hardware Certification Program run by the Certification Special Interest Group (SIG) aims to ensure seamless compatibility between AlmaLinux and a wide range of hardware configurations.
-
Wind River Introduces eLxr Pro Linux Solution
eLxr Pro offers an end-to-end Linux solution backed by expert commercial support.
-
Juno Tab 3 Launches with Ubuntu 24.04
Anyone looking for a full-blown Linux tablet need look no further. Juno has released the Tab 3.
-
New KDE Slimbook Plasma Available for Preorder
Powered by an AMD Ryzen CPU, the latest KDE Slimbook laptop is powerful enough for local AI tasks.