# Elegoo SLA Printer USB Network Storage

![](https://300043352-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MG07fVTFwl7BGAtPX4o%2Fuploads%2FBf5gx9Sx1w675UQwytD6%2FIMG_0398.jpg?alt=media\&token=ef154bd8-6ad2-4d29-acfa-a4fac8d14ce8)

## Supplies

* Raspberry Pi Zero W
* Class 10 Micro SD Card (>= 32Gb)
* Case
* (Qty 2) USB to Micro USB
* [Barrel Whip](https://smile.amazon.com/gp/product/B07MKJK1CM) (5.5mm x 2.5mm - Male Plug)
* [Barrel Whip](https://smile.amazon.com/gp/product/B07MKJK1CM) (5.5mm x 2.5mm - Female Plug)
* [USB Buck Converter](https://smile.amazon.com/HiLetgo-Module-6V-32V12V24V-Charging-Converter/dp/B07KWVL77T)

## 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.

Instructional: [Make a Pi Zero W Smart USB flash drive](https://magpi.raspberrypi.com/articles/pi-zero-w-smart-usb-flash-drive)

Instructional: [Headless Pi Zero W Wifi Setup](https://desertbot.io/blog/headless-pi-zero-w-wifi-setup-windows)

### Installing the OS

There are many instructionals online to walk you through setting up your raspberry pi.  I use the "[Raspberry Pi Imager](https://www.raspberrypi.com/software/)" with the Raspberry Pi OS Lite image.

![](https://300043352-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MG07fVTFwl7BGAtPX4o%2Fuploads%2FWIUleJQGqWQkLkKQUcYp%2F2022-01-14%2016_57_27-Window.jpg?alt=media\&token=e035d845-83d9-4268-9b0d-eafbefab5dcf)

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](https://desertbot.io/blog/headless-pi-zero-w-wifi-setup-windows)" 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](https://magpi.raspberrypi.com/articles/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](https://magpi.raspberrypi.com/articles/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.

![](https://300043352-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MG07fVTFwl7BGAtPX4o%2Fuploads%2FVysQ2wQUYOfmuWXIWD8Q%2FIMG_0420.jpg?alt=media\&token=34cc1cb2-58d0-40ca-9b0c-dfa5e3231d76)

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](https://magpi.raspberrypi.com/articles/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](https://magpi.raspberrypi.com/articles/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

{% file src="<https://300043352-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MG07fVTFwl7BGAtPX4o%2Fuploads%2FzIZfa52prYuLm0QVxw9b%2Fssh?alt=media&token=4de91f09-4d3a-4016-89b1-1537075cdc62>" %}

{% file src="<https://300043352-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MG07fVTFwl7BGAtPX4o%2Fuploads%2FxWQZWgLdcm8EOM0dmjQy%2Fwpa_supplicant.conf?alt=media&token=d0a0eea9-8ed0-4950-a58e-86d43dd98c0b>" %}
