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
-
Gnome 47.2 Now Available
Gnome 47.2 is now available for general use but don't expect much in the way of newness, as this is all about improvements and bug fixes.
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.
-
New Steam Client Ups the Ante for Linux
The latest release from Steam has some pretty cool tricks up its sleeve.