March 1, 2023: This is a draft, I plan to extend this guide.
I have only tested this in a Raspberry PI Zero 2 with an Anycubic Photon Ultra and works fine. This setup allows to connect remotely to your Raspberry PI to upload some files and then just go to your printer and hit print. This is not intented to act as a remote orchestrator for your printer. It is just a commodity because I hated to move the usb.
Using the Raspberry PI Imager install Raspberry Pi OS on a microSD card.
I picked Raspberry PI OS Lite (64-bit) as we don't need the desktop environment.
In the imager you can configure a wifi network that the RP will automatically connect on startup.
I used a hostname ultra.local
and username pi
to later connect via ssh.
Plug the RP to a power supply, and wait for it to start.
Then you can connect to the PI via SSH. In my case ssh pi@ultra.local
After you have connected to your PI. Create a file named startup_script.sh
. Then copy the contents of the file as below.
You can use nano startup_script.sh
to create and paste the contents of the file.
Depending on your microSD capacity, I recommend you to not exceed the 70% of it with the next commands.
sudo dd if=/dev/zero of=/home/pi/piusb_fat32.bin bs=1 count=0 seek=128M
sudo mkdosfs /home/pi/piusb_fat32.bin -n FAT32VOL11
This will create a binary file that will later act as the mounted storage you will use with your printer.
The seek=128M
will create a 128 megabyte file. Thas is enough and fast.
Be aware that bigger files will take a lot of time to create and format.
After creating and mounting the storage we will need to mount the storage.
To do this we need to create a folder that will act as a mount place for our drive.
sudo mkdir /home/pi/.thumbserve
Then we need to mount the binary file as a fat drive, but we want that to stay like that restart after restart, so lets save that to the /etc/fstab.
sudo echo "/home/pi/piusb_fat32.bin /home/pi/.thumbserve/uploads vfat users,uid=pi,gid=pi,umask=000 0 2 " >> /etc/fstab
After that we need to put the following line to the /etc/rc.local
file so everytime we power the pi, the USB can act as a USB Thumbdrive.
sh /home/pi/startup_script.sh
For reference you can look at the /etc/rc.local file I attached.
After last step you can use sudo reboot
to reboot your RP and see the changes.
I connected my PI to a power supply and then the microUSB port to the printer.
I used an SFTP client to upload my files to the RP.
Then I go to my printer and just plug-in the cable and hit print. I CAN upload more files WHILE printing but be careful when doing that. I plug it off the printer when not in use because my cable provides some voltage to my printer and wakes it up. You need to wait the file is fully uploaded before starting a print. I havent encountered any big problems. I've had tons of sucessful prints with this setup. Ocacionally one faliure, but I think I was moving files around.
Thanks to JayKay5532 at StackExchange post that guide me a lot on this journey. The startup_script.sh is provided as-is from this post. StackExchange - Change Raspberry Pi Zero USB Gadget name from Linux File-Stor Gadget