book collections email follower instructable user
Picture of Add sensors to your router! Use GPIO and sensors on OpenWrt

If your network router supports OpenWrt Linux, you can unlock many useful features for your projects!

Check for suported routers on

then check your router's toh page for details on finding the gpio pins.

Example for TPlink 703n:

Here are a few examples of using GPIO as input and output on a Tplink TL-WR 703n. This router has three easily accessible GPIO pins you can use.
Most of the time you can find maped GPIO pins on the OpenWrt table of hardware, for 703n look here!

To conect 5V sensors that are intended for use with Arduino you need 5V, GND and a voltage divider to get a signal in 3.3V range instead of 5V, Just to be on the safe side I connected a 1K resistor between the voltage devider and the sensor to limit the current passing trough the GPIO.

Next connect the 5V to the VCC on the sensor, ground to sensor GND and voltage devider GND, Signal output from the sensor to the voltage devider input and the voltage devider output to the current limiting ressistor and then to GPIO.

To be safe you can use a multimeter to mesure voltage before connecting the 3,3V signal to the GPIO pin.

Step 1: OpenWrt setup

OpenWrt setup
I use GPIO 29 so for input the setup looks like this:


# Put your custom commands here that should be executed once

# the system init finished. By default this file does nothing.

echo “29” > /sys/class/gpio/export;

echo “in” > /sys/class/gpio/gpio29/direction

exit 0

And you can get the state of the pin with:

cat /sys/class/gpio/gpio29/value

And this is what you get:

(some sensors send inverted values, its up to you to use what you need)

root@OpenWrt:~# cat /sys/class/gpio/gpio29/value


root@OpenWrt:~# cat /sys/class/gpio/gpio29/value


root@OpenWrt:~# cat /sys/class/gpio/gpio29/value


robthebrew4 years ago

nice introduction. There is lots more you can do with the 703 but it requires serious soldering skills. I say serious, but I wear glasses to even see it, but I managed to change the rom and reflow the RAM.

Tkdwn (author)  robthebrew4 years ago
Yep, Tplink's are greate. 703, 3020, and the clone Gl-inet is the best of the bunch, and yeah you aquire some greate soldering skills with these kind of projects.

Wow man... the things I learn from Instructables are amazing. I should have skipped university. Great job! Will definitely try to follow these steps.

Tkdwn (author)  LucasGilbert4 years ago
Tnx, if something is missing just ask and, i will edit it in. Have fun!