Installing Xiaomi XiaoFang with OctoPrint

I wanted to have a live video stream from my Snapmaker 2.0 since it now has got a space in a closet. After a couple of tries to use a live video stream from the XiaoFang camera I realized it would not be a good solution. Quite a lot of tweaking to get it to work and it would require quite some resources from the Raspberry and thus might affect prints. But I still wanted to use that camera since I already had it.
OctoPrint video

After looking through the OctoPrint forum I saw that some people had used a special firmware on Wyze cameras to just make them into webcameras and connect directly to the Raspberry. The Wyze camera and the XiaoFang are the same camera, but wonder if it would just work to use that firmware? Found an article indicating it should work so gave it a try. Went to the firmware page and followed the instructions. Built a USB A to USB A cable and connected the camera to my PC. Wow, it is a webcam! Connected it the the Raspberry and entered the default settings for camera. Voila!

Configure WLAN on Raspberry Pi Z W

To setup my Raspberry Pi Z W I have combined two different guides since editing the files on the SD did not work, nor did I had the energy to setup Vagrant.

Start by flashing a micro SD card as described here using Etcher.

Insert the card into a Mac or PC and add enable_uart=1 to the end of config.txt as described here.

Insert the SD card in the Raspberry Pi and boot it as described here using a USB serial cable. Then in a terminal window run screen /dev/tty.usbserial-A7005Gpd 115200 (change to your device tty) to connect to the serial terminal on the Raspberry Pi.

Now you can follow this guide from step 3. Though I did not configure mine for two networks and here are how my configuration files look like:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf


country=SE
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
ssid="SSID_OF_NETWORK_1"
psk="password"
id_str="home"
}

sudo nano /etc/network/interfaces


source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

iface eth0 inet manual

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

iface home inet dhcp