Rescued WiFi Router Turned 3D Print Server!

On January 27, 2015, in Projects, Tutorial, by Matt Defenthaler

I’ve been using the heck out of my Makerfarm i3v 10″ ever since it arrived back in November. It’s a solid kit and Colin at Makerfarm quickly responds to emails (that’s worth a lot to me even though I only had to bug him once.) Out of the box it comes with two ways to drive it: 1) a computer connected via USB and 2) the provided SD card and LCD interface. I use my laptop for modeling in addition to non-3D printing stuff, so having it tethered to the printer got old fast. Enter OctoPrint. OctoPrint is a Python project that communicates with the printer via USB, but also provides a web interface for controlling the printer, viewing its status, and uploading files. A lot of people run it on a Raspberry Pi. It’s a perfect use-case for such a device. Why not go with that? It’s well-supported and cheap enough, right? That’s just not how I roll.

The way I roll: Hey, all of OctoPrint is in Python and I know I can get the orphan Netgear running Python and the router has a USB port… New project!!

 

router3DPrintServer

The following is what’s involved in general and is not a step-by-step guide.

Device: WNDR3700v1 (originally found wet, cold, and bricked in a dumpster)
Hardware: 4GB USB stick + USB hub (passive is just fine)
OS: OpenWrt Chaos Calmer (from here https://forum.openwrt.org/viewtopic.php?id=50914) (default password: changeme)
Software: OctoPrint + dependencies (Download from here)

First, figure out how to get OpenWrt on your router. There’s a tutorial on the web somewhere. (side note: I tried DD-Wrt, but had trouble getting the USB drivers installed, so I switched to OpenWrt.)

You’ll have to start with a connection to one of the LAN interfaces on the router, but we of course want to make things wireless and it makes it a lot easier to download packages and change settings when the router is configured as a client of our home WiFi network. Go ahead and configure that in LuCI before continuing. NOTE: The wwan interface must be on the same subnet as your WiFi network, but you’ll want to change the LAN interface to be on a different subnet! It took me a while to realize why I couldn’t hit the wwan IP from my WiFi network. In the end I set the LAN interface to a static 192.168.2.1 and the wwan to a static 192.168.1.200 (my WiFi network is on the 192.168.1.1/24 subnet).

Next, since the router doesn’t have enough internal storage for our needs, we need to get USB storage working. Most routers will only have one USB port and we need two (one for the flash drive we’ll connect and one for the printer), but through the modern wonder that is USB, a hub gives us more ports. The USB drive needs to be formatted. It’s probably a good idea to give it at least two partitions (one big one for storage and the other for SWAP), but I went with just one for storage. I used ext4 (ext2 should work too, but don’t use ext3 because it will wear out your drive). Plug the hub into the USB port on the router and the flash drive into one of the hub’s ports. Next, add it as a mount point through the OpenWrt luci web interface by going to System > Mount Points and click the “Add” button under the Mount Points section. Check “Enable this mount” and choose the device, then select the Filesystem. When you select the Filesystem, a “

Now that we’ve extended the device’s storage with the flash drive, we have room for the necessary software. Let’s SSH into the router (root@yourroutersip) and get package management (opkg) set up. There might be extra steps or it might work out of the box. Try running opkg update and see what you get. Resolving opkg issues is beyond the scope of this post. We need three packages from opkg – python, python-setuptools and kmod-usb-acm. kmod-usb-acm is the driver for the printer (aka Arduino Mega 2560).

opkg install python python-setuptools

kmod-usb-acm failed for me with the normal install command (something about a kernel version mismatch even though the kernel version matched). I used the force-depends argument and everything worked fine. I suggest trying it without first, though.

opkg install kmod-usb-acm --force-depends

Connect the end of the printer’s USB cable to the USB hub and reboot the device either through the web interface or by typing reboot in the terminal. Once the device is back up, SSH back in and run ls /dev . If the ACM USB driver is working, you should see ttyACM0. If you don’t see it, do the usual dmesg | tail to troubleshoot.

The next step is to install OctoPrint on the router. I could not get python-setuptools to connect to HTTPS sites (I’m sure it’s something simple, but it was distracting from proving the concept of getting OctoPrint running on a router.) Instead, I downloaded the packages to my laptop and scp’d them to the router and found the order of operations by trial and error. Don’t worry, you won’t have to because I documented the process and have provided a file containing everything you need 🙂

The last step is to tell the router to start OctoPrint on boot. To do that,
we’ll add a command to the /etc/rc.local startup script.

octoprint --iknowwhatimdoing &

That argument is there since you normally don’t want something to run as root, but sometimes (like when that’s the only account there is) you have to. The command will start OctoPrint on port 5000 (add a –port=PORT_NUMBER argument if you want it on a different port) when the router boots.

Reboot the router and try accessing http://yourrouterswwanip:5000. You should see the OctoPrint page. Configure your connection. The /dev/ttyACM0 device should be in the dropdown.

Enjoy your (now wireless) 3D printing!

 

 

8 Responses to Rescued WiFi Router Turned 3D Print Server!

  1. […] 3D Printers are super convenient when you need a part quickly. However, they can be seriously inconvenient if the 3D printer has to be tethered to your computer for the duration of the entire print. [Matt] purchased a Makerfarm i3v printer and has been using it a bunch. The only thing he wasn’t crazy about was having it occupy his computer while printing objects. Then one day [Matt] was dumpster diving (don’t roll your eyes, we all do it) and found a Netgear WNDR3700v1 WiFi router. This particular router has a USB port and it made [Matt] think, “can I use this to run my printer?” […]

  2. […] your 3D printer remotely and reusing e-waste. For details about Defenthaler’s process, see the Projects and Thoughts section on Defenthaler’s website. For a fantastic discussion of the ins and outs of dumpster […]

  3. GrandpaDrift aka Bob says:

    Matt, great article. I was a DOD contractor. An IT SPECIALIST. Now I work at Disney IT as a server break fix technician. I still have my 1991 240sx. Runs badly and has some minor brake booster issues. FORMULA DRIFT @ OSW JUNE 5 & 6 .. Be there !

  4. Sancho says:

    Hi. Great how-to. Anyhow, I was not able to install the SW using your package as it was missing 3 additional installs.
    So I had to fix the certificates.
    To do that, I followed the guide here: https://wiki.openwrt.org/doc/howto/wget-ssl-certs
    I created the directory for it, set the variable and installed the ca-certificates package.
    I had to update the python setuptools as the version with OpenWRT was too old – so I downloaded the ez_setup.py and run python ez_setup.py install.
    Also, the Sphynx-1.3.3 did make some problems, so I downloaded the package manually and tried to install it using ez_setup again, but it failed with no error or warning – just stating “something went wrong, check the log above”.
    The problem was I was optimistically trying to run it with no swap to avoid the storage wear out. Fool…
    Then I run out of /tmp during the setup, so I had do manually download and setup Babel-2.1.1. Same for Pygments-2.0.2.
    Also, I was able to install mjpg-streamer and configure the webcam – it shows the stream 🙂
    Not sure how I can make timelapses as the small router will definitely not be able to encode them and the storage space is limited…

  5. Peter says:

    Hello!

    I successfully managed to install this OctoPrint version on a LinkIt Smart 7688 (with some additional package required), but what about the more recent versions and CuraEngine? Did You make more recent package since then?

    Best regards,
    Peter

  6. Sing says:

    Installed /usr/lib/python2.7/site-packages/OctoPrint-868dc6d7a9b4b45c4a6d77fa2226ca40d9a098a4-py2.7.egg
    Processing dependencies for OctoPrint===868dc6d7a9b4b45c4a6d77fa2226ca40d9a098a4
    Searching for babel!=2.0,>=1.3
    Reading https://pypi.python.org/simple/babel/
    Downloading https://pypi.python.org/packages/92/22/643f3b75f75e0220c5ef9f5b72b619ccffe9266170143a4821d4885198de/Babel-2.4.0.tar.gz#md5=90e7a0add19b2036a9b415630a0d9388
    Best match: Babel 2.4.0
    Processing Babel-2.4.0.tar.gz
    Writing /tmp/easy_install-hI6mjw/Babel-2.4.0/setup.cfg
    Running Babel-2.4.0/setup.py -q bdist_egg –dist-dir /tmp/easy_install-hI6mjw/Babel-2.4.0/egg-dist-tmp-hO3Y4k
    warning: no previously-included files matching ‘*’ found under directory ‘docs/_build’
    warning: no previously-included files matching ‘*.pyc’ found under directory ‘tests’
    warning: no previously-included files matching ‘*.pyo’ found under directory ‘tests’
    warning: build_py: byte-compiling is disabled, skipping.

    error: Setup script exited with error: [Errno 28] No space left on device
    root@mylinkit:/tmp/run/mountd/sda1#

    Install on LinkIt Smart 7688 broad status. Can you tell me how to do ? Thanks.

    • That’s a really cool board! I didn’t know about it until I saw your post. It looks like it has USB host so you should be able to connect external storage to it and install to a partition on a thumb drive. That will solve your space issue. If that’s what sda1 already is, maybe the partition is too small?

Leave a Reply

Your email address will not be published. Required fields are marked *