Control your Anet A8 3D Printer using Octoprint on Raspberry Pi Zero with SDIO WiFi Addon, direct UART connection and still have one free USB!



A lot of people are using OctoPring + Raspberry Pi 3 (RPi 3) to remote control their 3D printers via internet or local network.
However, RPi 3 costs $40, which is hardly the cheapest solution. Also, most of the features you pay for in a RPi 3, don’t have anything to do with the task of controlling the 3D printer remotely. And you end up paying for something you don’t really need or use (like audio output, lan port, bluetooth or display interface…).

So, I decided to come up with a cheaper solution, although requiring a little more effort to set up (isn’t that always the case) at roughly 1/4 the price.
The Pi Zero seemed like the ideal candidate – it’s bare bones, and it has the required processing power. However, there is one issue. Or more like 3 issues: if you do it “the usual” way, you will need 3 usb ports – one for the WiFi module, one for connecting to the printer itself, and one for a webcam (using the onboard camera interface is not an option – these cameras are far too expensive). The Pi Zero has only one USB, so you would need a hub, which adds to the price and to the power requirements (not to mention it adds even more cables hanging around).
Even if you use the newly released Pi Zero W which has built-in wifi, you would still need 2 usb ports. And the Pi Zero W itself costs $10.

My solution: use the Pi Zero’s UART pins to connect to the printer directly (bypassing the printer’s own USB to UART converter), and use cheap ESP-12F wifi module, connected to the Pi Zero’s SDIO pins.
Connect USB webcam to the now free USB port of the Pi Zero.

Before you start

This project IS NOT for people that have a lack of patience or some soldering skills. It also requires a bit of Linux tinkering. Not all steps are explained in the most detailed manner, so use your brain & google if you have doubts 😉

Let’s get started!

What you need:

  • a Raspberry Pi Zero mini PC (~$6) – Buy
  • ESP-12F WiFi Module ($2.35) – Buy
  • A piece of universal PCB (costs cents, if you don’t have it already) – Buy
  • 6x 33 (or 39) ohm resistors
  • Some male & female headers – Buy
  • Any micro sd memory card. 8GB is enough.
  • A separate 5V2A PSU (any micro usb phone charger) to power the Pi Zero independently from your main PSU

Schematics – ESP-12F to Raspberry Pi Zero Connection

Source: https://oshlab.com/esp8266-raspberry-pi-gpio-wifi/

Raspberry Pi Zero Pinout

Anet V1.0 Mainboard J3 Pinout

Putting it together

First, get six 33 Ohm resistors (or in my case – 39, because I didn’t had 33), and following the first schematic, solder the ESP module to the Pi Zero. Try to cut the resistor pins as short as possible. Initially I used some cables, but they are too long, and the ESP module was painfully slow. After I re-soldered it as shown on the picture, it achieves stable ~3MB/s transfer speed, which is more than enough for streaming video.

Next, prepare the Pi Zero / mainboard “attachment” – essentially, you want the TX pin of the Pi Zero to connect to the RX pin on J3, the RX pin of the Pi Zero to connect to the TX on J3, and GND to GND. I used a piece of universal PCB and a couple of female headers. See some sample photos below.

 

In the end, you will have a nice little addon module, that can be attached to your Anet 1.0 board and left in place.
Before you attach it though, the Anet board needs a slight modification. By default, the TX/RX pins of J3 are bypassed. You can find how to enable them here. Read on, and continue from here when you are ready 🙂

The Software

Download the disk image from here, and prepare a Raspbian Jessie Lite SD card for your Pi Zero.
In order to prepare the software, you WILL have to connect the Pi Zero to HDMI display, keyboard, and usb wifi card (once ready, you won’t need them).

Once you boot your Pi Zero, log-in with user pi and password raspberry.

Run this command to set your wifi connection credentials:

wpa_passphrase YOUR_SSID YOUR_PASS | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf

Replace YOUR_SSID with the name of your wireless network, and YOUR_PASS with it’s password.

Next, run the Raspberry Pi Configuration tool:

sudo raspi-config

Go to Interfacing Options -> SSH, and select YES.

Go to Interfacing Options -> Serial, and select NO when asked “Would you like a login shell to be accessible over serial?”, and YES when asked “Would you like the serial port hardware to be enabled?”.
Press TAB a couple of times, until the “Finish” button is activated, and press Enter. Reboot if asked & login again.

Now run this:

sudo rm /etc/ssh/ssh_host_*
sudo dpkg-reconfigure openssh-server

And finally reboot:

sudo reboot

After the Pi Zero reboots, it should be connected to your WiFi, and you should be able to connect to it via SSH, so you don’t need the keyboard & display anymore.

Install the latest updates:

sudo apt-get update
sudo apt-get dist-upgrade

Now you have to download & compile the ESP SDIO driver:

cd ~
git clone https://github.com/oshlab/esp8089.git
cd esp8089
sudo sh install

Sit back and relax. Or better yet – do something else. It WILL take some time.

I tested this driver with the 4.4.50+ kernel (at the moment of writing, it’s the kernel that comes with Raspbian Jessie Lite). It didn’t work with the newer kernels, so DON’T update the firmware using the rpi-update tool.

When it’s ready, reboot.
If you execute “ifconfig” now, you should see two wifi cards. Just disconnect the usb one, and you are ready!

You can now install OctoPrint as described here https://github.com/foosel/OctoPrint/wiki/Setup-on-a-Raspberry-Pi-running-Raspbian, and use the available usb port on the Pi Zero for connecting some cheap webcam.
The Raspberry Pi Zero is capable more than enough to perform these tasks, and it’s cheap!
If you use the new Pi Zero W, you don’t even need the SDIO module & driver – you just have to connect the UART pins to your Anet board, power the Pi from the 5V PSU, and install OctoPrint!

Leave a comment...