Elegoo SLA Printer USB Network Storage
Sick of the USB thumb drive... make your printer smarter with network mass storage using a Raspberry Pi Zero!

Supplies

Setting Up the Pi

This instructional revolves more around setting up a device that can be used as a network mass storage device. I will focus on more of the hardware sides of things and when it comes to setting up the Pi refer you to instructionals I used to make this project possible.

Installing the OS

There are many instructionals online to walk you through setting up your raspberry pi. I use the "Raspberry Pi Imager" with the Raspberry Pi OS Lite image.
Once the SD card has the OS written you will need to enable ssh and configure wifi. Use the resource files below ("ssh" and "wpa_supplicant.conf") the "Headless Pi Zero W Wifi Setup" article to configure these files for your network.

Post OS Install Pre-rec's

(1) Update apt
sudo apt update
(2) Install Python3 / PIP (It should already be installed)
sudo apt install python3-pip

Configure the Mass Storage

Follow the steps in "Make a Pi Zero W Smart USB flash drive" but there are some tweaks and changes that will be noted here with the steps they pertain to.

STEP-01 through STEP-08

Follow the instructions as they are originally written. ("Make a Pi Zero W Smart USB flash drive")

STEP-09: Creating a Test file and Slices Directory

Now we are going to create a file and directory that will eventually be visible on the Elegoo printer. The Raspberry Pi Zero W should be plugged into the printer from the designated USB port on the pi and you should have a power supply hooked up to the pi as well. The stock USB port on the Elegoo does not supply enough power to power the pi.
sudo touch /mnt/usbshare/hello.world.txt
sudo mkdir /mnt/usbshare/Slices

STEP-10: Test mass storage device mode

Now comes the moment of truth. Let’s see whether the 3D printer is going to be friends with the Pi Zero W. The command below will enable USB mass storage device mode, and the Elegoo printer should pop up a dialogue box. If it doesn’t, you may need to back out of the menu to the main menu page and get back into the storage.
sudo modprobe g_mass_storage file=/piusb.bin stall=0 ro=0 removable=1
The printer should provide the file and directory we previously created on the printer screen.
Once you’re satisfied that all is well, try a dismount:
sudo modprobe -r g_mass_storage

STEP-11 through STEP 12

Follow the instructions as they are originally written. ("Make a Pi Zero W Smart USB flash drive")

STEP-13

In order for the printer to detect any changes we’ve made over the network (for example, file or folder creations and deletions), it needs to be tricked into thinking that the USB device has been removed and reinserted.
We can use a Python library called watchdog (magpi.cc/2sLL1fi), which is designed for monitoring file system events and responding to them. Install this with the command below:
sudo pip3 install watchdog
We then need some code to start a timer whenever something changes in the shared folder. The timer is reset to zero every time a new change occurs, and the USB reconnect is only triggered if we see 30 seconds of inactivity after a change. This avoids spamming the printer while we’re copying over multiple files.
The article refers to a program written to do this. To download it, type:
sudo wget http://rpf.io/usbzw -O /usr/local/share/usb_share.py
sudo chmod +x /usr/local/share/usb_share.py
You will need to go into the usb_share.py program and modify line 7 to read like the following...
CMD_MOUNT = "modprobe g_mass_storage file=/piusb.bin stall=0 ro=0 removable=1"
To modify the program, type:
sudo nano /usr/local/share/usb_share.py
Press CTRL+O followed by Enter to save, and then CTRL+X to quit.

STEP-14

Follow the instructions as they are originally written. ("Make a Pi Zero W Smart USB flash drive")

Conclusion

Now that you are done you should have a SLA printer that is a little smarter and more convenient to use when it comes to providing your slices to your printer.

Resources

ssh
0B
Binary
wpa_supplicant.conf
149B
Binary