Thu, 26 Aug 2021
Itâs possible to put an embroidery machine (or a 3d printer, a cutting machine, a TV, or almost anything else that reads from a USB stick) on your wifi network, and set it up so that all you have to do is copy your embroidery files into a special folder on your PC (Windows, Linux, and probably Mac though I donât have one to test it with) and theyâll appear on your embroidery machine. Hereâs what youâll need.
December 2022 update: Not only are Raspberry Pi's almost impossible to find, the company itself has been running around on social media setting fire to their corporate goodwill. I think they're trying to be "edgy" but are falling short and landing on "we're a bunch of jerks." If you've got a Pi handy, do this, but don't give the company your money. I'm trying out alternate single-board computers myself, and will have updates soonish.
A Raspberry Pi Zero W
The official Raspberry Pi site will tell you where you can buy a Pi, either mail-order or in person. In the US, if you live near a Micro Center, you can buy one. Literally, one. Thatâs all you can mail-order as well. This is probably good, because Iâd buy half a dozen every time I was in a Micro Center because itâs so fun to set up a tiny computer. Theyâre ten bucks! Make sure you get the wireless one; thatâs the whole point of the exercise.
A case, maybe
You donât want to poke the circuit board while the Pi is turned on (or other times, really, because static), so maybe get a little case for it. You can get cheap ones, you can get fancy ones. My first Pi lived in a piece of folded cardboard. The one in the picture is from C4 Labs, also sold in person at Micro Centers.
A Micro SD card
This is what the Pi uses for a âdisk drive.â You donât need a very big one; 16GB or 32GB will do. Get a good name brand. I usually go with SanDisk đŚ, but depending on when youâre reading this, times may have changed.
A Micro SD card writer
If your computer doesnât have one built in, USB ones are super-cheap đŚ.
USB cables and power supply
The Pi has two USB-micro ports. One is for power, and the other is for data. You can power it from the data port, but that means your embroidery machine has to have enough power, and has to stay powered on.
Power is easy. Find a nice 5V power supply from an old cell phone. Make sure it is at least 2A.
Data is a little more complicated â if your embroidery machine supplies power to its USB port, you donât want that getting to the Pi, or worse yet the Pi trying to supply power to the embroidery machine. So you either need to strip the jacket off part of a USB cable and clip the red wire, or you need to cover one connection with a scrap of electrical tape, or you need to put a power blocker đŚ in between the embroidery machine and the Pi. Youâll want to put an extension cable đŚ between there too, so you can put the Pi safely out of the way.
The first setup, with the Pi plugged directly into the side of the embroidery machine, looked neat but I pretty quickly figured out that the Pi was going to get bumped and possibly damage the embroidery machineâs port. It lives under the table now, but thatâs not as photogenic. If youâre only hooking up one Pi, just get a 6âł USB cable, tape or cut the power line in it, and tape the Pi to the back of the embroidery machine or table. (Duct tape will hold in the heat though, so donât get carried away.)
Thatâs it! If youâve already got cables, can write SD cards, and have a nearby Micro Center, you can do this for under $25. If you have to go to Adafruit or somewhere mail-order, itâll be a little more, but still not bad.
Tip your server
Okay, this is purely optional, but I do have a ko-fi (which is also where freebie designs first appear).
Toss a coin to your stitcher! (Ko-Fi)
Software
Youâll need a few more things, but theyâre all free.
An SSH client
If your operating system doesnât have one built in, you can use something like Termius. This is how youâre going to talk to the Pi since it doesnât have its own keyboard and screen. Itâll open a window on your desktop PC instead.
An SD card imager
I use Etcher. Thereâs a version for Linux, Windows, and MacOS.
A Pi operating system
Itâs available in this repository. Click on âusbgadget.img
â and it should let you download just the image. Itâs based on the 2021-05-07 Raspberry Pi OS Lite, but Iâll try to keep it current.
If youâd like to build your own image, check the bottom of the page for the behind-the-scenes.
Putting it all together
Flashing the OS
Weâre going to unpack that image onto the SD card, in a format that the Pi will run off of. Put the SD card in the reader and open whichever imager youâve chosen. Both work the same way: pick a device, pick what you want to put on it, push the button. With Etcher youâll have to point it to the image youâve downloaded, with Imager youâll have to pick Lite. Both should find the card, though if you have other USB storage devices plugged in make sure you pick the right one. Thatâll take awhile.
Once thatâs done, your computer should recognize the SD card just like a thumb drive. It will have two partitions, boot
and rootfs
. Open boot
. Weâre going to tell the Pi the wifi password. Find the file named wpa_supplicant.conf
. It will look something like this:
<pre class="wp-block-preformatted">country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="WIFI_SSID"
scan_ssid=1
psk="WIFI_PASSWORD"
key_mgmt=WPA-PSK
}
Put in your actual wifi ssid (the network name) and password, of course. Save that file, unmount the SD card, and take it out of the reader.
Wake up the Pi
Put the SD card in the slot on the end of the Pi, and connect it to power (the USB port closer to the end of the stick). It should light up, and in a moment or two if all goes well it will be on your wifi network. If you connect the other USB port to your embroidery machine, using the no-power cable, it should recognize it.
Connecting from a PC
Now you can press Windows+e
to open the Windows explorer, type \\usbgadget
. You should see the usb_share folder, and be able to read, write, and delete files to it. Itâs open to your whole network, so be careful.
If you also want to mount it on a Linux machine, from that machine you just need to type:
<pre class="wp-block-preformatted">sudo mount -t cifs -o username=pi%guest,user=pi,uid=LOCALUSERNAME //XX.XX.XX.XXX/usb /mnt/usbgadget
(The mount point doesnât have to be named with the Pi hostname if you have a different convention on your machine.)
Thatâs it! Your Pi is now a wireless USB stick!
Donât forget to delete the usbgadget.img
image off your PC if you downloaded it there. It takes up a lot of space and you wonât need it again.
Care and feeding of the USB gadget
Okay, thatâs not entirely it. Youâll probably want to turn the Pi off at some point, and maybe youâll want to change its name. And maybe youâll want to get really fancy, since you now have a whole ânother computer sitting there (believe it or not), and let it do things like⌠do ad blocking for your whole network, or be an Internet radio station. Or maybe you and your embroidery machine tried to write to the virtual USB stick at the same time and now things are all confused. Itâs all here.
If this works for you, let me know!
(If it doesnât work for you, also let me know!)
Thanks to Russell Barnes of MagPi magazine, who wrote the watchdog script.
đŚ: Technically, that's an affiliate link. I recommend showrooming on Amazon and buying somewhere else though.