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

Posted by Daniel Eichhorn

Daniel Eichhorn is a software engineer and an enthusiastic maker. He loves working on projects related to the Internet of Things, electronics, and embedded software. He owns two 3D printers: a Creality Ender 3 V2 and an Elegoo Mars 3. In 2018, he co-founded ThingPulse along with Marcel Stör. Together, they develop IoT hardware and distribute it to various locations around the world.

Leave a Reply