How to live stream PiCamera on your devices​

In this section, you will learn how to stream the video taken by the PiCamera connected to the Raspberry Pi on any browser through Wi-Fi.

This can be useful to control the drone when you are far from it or to experience first person viewer (FPV).

However remember that you have to be connected to the Wi-Fi all the time while streaming so the drone can’t be too far from your router. A typical wireless router has a range of 50 meters.

The first thing you will have to do is to connect the PiCamera on the Pi. To do so make sure the Pi is OFF, and then locate the camera port that is highlighted in the following picture.




You have to pull from the black plastic parts on each side, insert in the right direction the wiring sheet and then push back the black plastic parts of the PiCamera module connection. Make sure it stays still even when you pull the PiCamera a little.😉

Next, you will have to enable the PiCamera. To do so, start the Pi and connect a mouse and a monitor to it. Click on the rasbian logo on the top left, go in preferences, then Raspberry Pi Configuration and then in the interfaces tab make sur Camera is checked as enabled. Then click on ok.

After, open the terminal on your Pi and type:

This will create a new file in /home/pi.

Then copy the following code and past ite on the terminal (don’t forget to paste on the terminal it’s Ctrl+Shift+V and not just Ctrl+V) (source of the code: random nerd tutorials)

Save your file by pressing Ctrl+X, then type Y and click on Enter. You can now launch your program that streams video from the PiCamera from the terminal with the following command:

Once the script is running you can access your video stream web server at : http://:8000. Replace with your own Raspberry Pi IP address, in my case http://192.141.1.112:8000.

If you don’t know your Pi IP Adress, you can know it by typing ifconfig in the terminal which gives you the address as you can see in the following image:


You can access the live streaming via any device connected to the same network as the Raspberry Pi. You just need to open the browser.

You can also launch this program from your smartphone. You just need to install Terminus app (if you have an IPhone).

Once, the app is installed, open it and click on hosts.

Then click on ''+'' to add your device.

Then click on new host.

After enter the IP Address of your Raspberry Pi as the hostname, enable use SSH and click on save.

Finally click on this icon to connect your phone to the Pi.

You should see that the Rasbian icon is red which indicates that the connection worked successfully.

By clicking on the icon, you can have direct assess to your Raspberry Pi terminal from your phone and type a command.

This is perfect if you want to launch a video stream from your smartphone without having to connect a monitor, a mouse and a keyboard to your Pi.

Now, it would be useful to launch the stream when you start your drone, so when the Pi is starting so you don’t have to type any command each time. To do that, set the program to be launched at boot by typing on the terminal:

Go at the last line and add

Save your file by pressing Ctrl+X, then type Y and click on Enter.

Then to make it effective, reboot your Pi by typing the following in the terminal.

Congratulations. 😃 You have now setup a live stream on your Raspberry Pi and you can use your drone to spy on your neighbors or to do some FPV racing!

Complete and Continue  
Discussion

0 comments