Turn on/off USB Power on TL-MR3020 running OpenWrt to restart Arduino

In a later blog post I will describe how I am using a TL-MR3020 router as low-cost wifi shield for my Arduino to transmit sensor data over wifi. In this post I just want to show how you can script a restart of the arduino by powering off the USB port that the Arduino is connected to. In need this because sometimes the arduino does not send anymore data to the ttyUSB0 device. So as a workaround I’m restarting the Arduino from time to time by cron job.

#!/bin/sh
echo 0 > /sys/class/gpio/gpio8/value
echo 1 > /sys/class/gpio/gpio8/value
echo "$(date)" >> /tmp/restart.log

Now a beer! Did you like this post? It often takes me several hours of my free time to write one. If I was your neighbour would you offer me a beer for the hard work I did for you? The beauty is: beers can be teletransported with a painless donation using Paypal. A beer in a Swiss bar costs about USD $4.80. Or use this affiliate link if you order something on Banggood and I'll get a small kickback. Thank you!