4: WiFi live streaming USB camera (PC)

The original camera module of Raspberry Pi is convenient to code but the resolution of the Pi-camera may suffer. In this tutorial, we will develop a webcam server via USB camera. You need a Raspberry Pi 4B, a smartphone with WIFI hotspot and a USB camera. After you complete this tutorial, your camera should be able to live stream multiple computers/smartphones as long as they are connected to the same WIFI source

Step 1: Plug the USB Camera to the USB port of Raspberry Pi.


Step 2: Connect to the WIFI emitted from your smartphone.

Step 3: Type "sudo apt-get update" and "sudo apt-get upgrade"

Step 4: Install Buster 

"sudo apt install autoconf automake build-essential pkgconf libtool git libzip-dev libjpeg-dev gettext libmicrohttpd-dev libavformat-dev libavcodec-dev libavutil-dev libswscale-dev libavdevice-dev default-libmysqlclient-dev libpq-dev libsqlite3-dev libwebp-dev"

Step 5: Go to github and download " Motion"

sudo wget https://github.com/Motion-Project/motion/releases/download/release-4.2.2/pi_buster_motion_4.2.2-1_armhf.deb

Step 6: Install the deb

"sudo dpkg -i pi_buster_motion_4.2.2-1_armhf.deb"

Step 7: Edit the conf file and set "daemon on" and "stream_localhost off"

"sudo nano /etc/motion/motion.conf"

If the live streaming is frozen, set "picture_output off" and "movie_output off"

Click Ctrl+S before EXIT

Step 8: Edit motion file and set "start_motion_daemon=yes"

sudo nano /etc/default/motion

Click Ctrl+S before EXIT

Step 9: Let's live stream it!

"sudo service motion start"

Step 10: Check your IP address by typing "hostname -I". You should see something like 192.168.xx.xx

Step 11: Open your browser and type 192.168.xx.xx:8081. Your USB camera should live stream now. The camera can live stream multiple computers/Smartphones as long as they are connected to the same WIFI source



If fail, type "sudo service motion restart".

If still fail, restart your Raspberry Pi and type "sudo service motion start" again

Step 12: To take picture, install fswebcam

"sudo apt install fswebcam"

Step 13: To save the picture as abc.png, you should type the following command.

"sudo fswebcam abc.png"

Step 14: To stop streaming, type "sudo service motion stop" before unplugging the USB camera



*The above code are modified from open source platform

Comments