Have you browsed /r/homeassistant and are you looking for a RTSP camera to complete your dashboard? Are you looking into Blue Iris, but all those camera’s are out of your budget? Are you like me and do you buy everything with Xiaomi infront of it? Then you came to the right place! Xiaomi is well known for selling excellent product at a really low price, with their camera’s being a prime example. The Xiaomi Xiaofang camera bring a lot of features to the table, at a low price of 14 euro. Like; 1080p @30fps, nightvision (up to 9 meter), 110 degree wide angle, Wi-Fi and more.
So why is this camera not all over your Reddit front page? That’s because you can only view the camera video feed through the Mi Home app (that still has some parts that are in Chinese), but that’s not even the biggest problem. Xiaomi completely locked the camera for anyone outside of China. If your Mi Home app is higher than version 4.0.11, the app will just show you a ‘regional restriction’ page that sends you back to the menu for Mi Home. So why even bother buying the camera? Well there are some cool people out there (@samtap), that created a ‘hack’ that is able to bring most of the features back. Not only that, but they even unlocked the true potential for this camera with features like RTSP, FTP, SSH and a webpage to manage the device. I will mainly focus on RTSP (Real Time Streaming Protocol) in this guide.
Unboxing the camera
Because this is more a guide then a review, I will briefly walk over the unboxing.
The ‘hacking’ is actually way, way easier than I thought it would! There’s no command line or anything like that involved. You’ll need the following to hack the camera:
- The Xiaofang camera
- Some sort of power, be it via an adapter or power bank
- SD card with a minimum space of 100MiB (more if you want to store video’s on the SD Card)
This is the point where I will show you how easy it is! The only thing you need to do is putting the necessarily files onto a SD card, put that SD card in the camera and all the hacking magic wizardoo will do its job!
Flashing the SD Card
- Get the needed files for hacking the camera at the GitHub page
- Download Etcher and install it.
- Open up Etcher
- Select the file you just downloaded from the GitHub page (.zip file)
- Select your SD Card, make sure you select the right card (it will be wiped).
- Double check if you have the correct file/SD Card selected and flash away!
- Now we are done with the flashing, time to unplug the SD Card from the PC.
Preparing the camera
- Open up the Mi Home app and create a account if you haven’t already.
- Click the ‘+’ icon in the top, click ‘Add manually’ and search ‘Xiaofang’.
- Follow the on screen instructions
- Enter your Wi-Fi name and password.
- Scan the QR code on your screen with the camera (aim the camera at the QR code)
- Add it to a ‘room’.
- If you click on it, you will be welcomed by the ‘regional restriction‘ message, luckily we have a fix for that!
Fitting it all together
- Power on the Xiaofang camera and wait for the status LED to turn solid blue, this means the camera is connected to your Wi-Fi.
- Now you’re safe to put the SD Card in the bottom of the camera (so do not put it in before you boot it).
- After 5-10 seconds you’ll hear a ‘ting ting’ or ‘ding ding’. This means the hack was successful!
- Now we need the internal IP for the camera, we need this to visit the web page.
- I use the app ‘Fing’ which is available on Android and iOS, it will scan your network and you will be able to find the camera.
- This a screenshot of my network scan, the IP I need to visit is 192.168.1.193.
- To visit the managment page, visit
http://<device-ip>/cgi-bin/status. So for me this would be:
- If everything went right, a beautiful little web page will appear. On my page you can see it says ‘Script is already installed’. If you don’t have this yet, make sure ‘Hacks enabled’ checkbox is checked and click ‘Apply’.
Now you are really done! You can go to ‘Manage scripts’ to make sure everything is running.
If you are antsy about Xiaomi watching your doorway, be careful before you Disable cloud applications. If for some reason your camera is unable to connect to the Wi-Fi, it’s proper useless without a fix.
Connecting to the camera
Real Time Streaming Protocol (RTSP)
- The URL for the RTSP stream is almost the same as the management URL. The RTSP URL is:
rtsp://<device-ip>/unicast, for me this would be:
- You can test if it works by installing VLC > Media (top left) > Open Network Stream and enter the RTSP URL.
- Boom! Sweet 1080p, 30FPS through a 110 degree lens for only 14 euro. That deserves a pat on the back (you can do it yourself if you’d like to…).
- At this point you can choose how you will utilize this camera, you can use any preferred software to watch the RTSP stream, like Zoneminder, Shinobi, Blue Iris, iSpy, VLC and way more. There are even amazing mobile apps like TinyCam, Android VLC and RTSP Camera Viewer that you can use to watch it on your phone.
Secure Shell (SSH) or Telnet
You can use a client like Putty to connect via SSH (port 22) to the camera, or even Telnet (port 2323). The credentials are:
File Transfer Protocol (FTP) & SSH File Transfer Protocol (SFTP)
Maybe your not accustomed to the command line or just want a GUI in front of you, this can be done with an FTP/SFTP client like WinSCP. The credentials for this are also:
I think this device + the hacks offer a whole lot for only 14 euro. It is of course more of a DIY solution, than something like Hikvision. For people starting out in the IP camera world or people that like to add an camera to their Home Assistant dashboard, this is a perfect entry camera with some fun tinkering involved. Again shout-out to @samptap for making this all possible, and Gearbest for sending me this camera (I will probably order a few more for my HA Dashboard).
Taking it a step further
Adding it to HomeAssistant
You can add this camera to your HomeAssistant dashboard. It will not be a live video feed, but an image that will refresh every 10 seconds. You need to add the following code to your Home Assistant configuration.yaml:
ffmpeg: camera: - platform: ffmpeg name: Candy Cam input: rtsp://<device-ip>:554/unicast
If you do not have ffmpeg installed, you need it for the component to work. You can see here how to install it.
Changing RTSP settings
If the camera is chugging all your Wi-Fi bandwidth, or the RTSP stream is a bit unstable, you can easily tone the camera down to any resolution you’d like. I will change mine to 1280×720, I experienced a more stable stream and FPS.
You need to edit the config file for RTSP this can be done via SSH, Telnet, FTP and SFTP. FTP and SFTP are easier since they have a GUI, but sometimes it acts a little funky. That is why I prefer to do it via SSH. You need to modifty the following file:
So if you SSH into your camera and type:
vi /media/mmcblk0p2/data/etc/scripts/20-rtsp-server, you can edit the file! Now look for the following line:
snx_rtsp_server -W 1920 -H 1080 -Q 10 -b 4096 -a >$LOG 2>&1 &
Change that to:
snx_rtsp_server -W 1280 -H 720 -Q 10 -b 2048 -a >$LOG 2>&1 &
You can also change the FPS by adding a -F variable, if you wanted to limit it to 15 FPS:
snx_rtsp_server -W 1280 -H 720 -Q 10 -F 15 -b 2048 -a >$LOG 2>&1 &
Running it on a powerbank
It might be obvious at this point, I even touched on it briefly in the guide. But you can run this bad boy on a power bank and use it as temporary/mobile IP camera solution! I was able to run it on a 1000mAh Xiaomi Power bank for 18+ hours. It only needs 5V 1A, so most power banks will be able to deliver enough power to the camera.
Disable infrared to place it close to a window
If you plan on placing your camera behind a Window, it might be a good idea to disable the infrared. This way you won’t get the IR glare in the window, so you can actually see something at night.