Introduction: Raspberry Pi Zero W IP Camera With Motion & Weaved
In this Instructable I'll show you how to make a cheap IP camera (accessible through internet around the world).
Basically we are using motion and weaved services. It is easy to make & endless uses as surveillance camera.
Step 1: Prerequisites
1. Raspberry Pi Zero W
2. 8 GB Class 10 microSD card or up.
3. USB OTG Cable
4. 5V - 1.5A Power adapter
5. USB Webcam (I'm using Logitech C270)
6. Keyboard & monitor for initial setup
7. Wifi (I'm using my Android phone as wifi hotspot)
8. Mini HDMI to HDMI adapter
9. HDMI Cable
10. Putty(Software) for ssh
Step 2: Getting Started
You need to download & burn latest Raspbian Jessie Extended Lite version from the www.raspberrypi.org to the microSD card. There are plenty of instructables available for this process so kindly check one.
Now place your microSD card into Pi Zero W. Connect mini HDMI to HDMI adapter to mini HDMI slot of Pi Zero W and connect your monitor to Pi using normal HDMI cable. Connect usb OTG cable to microUSB slot of Pi zero W and connect keyboard with it. Finally connect power adapter to PI and power it up.
Pi will ask you for username & password. By default user name is "pi" and password is "raspberry". Type this and you'll login to you Raspberry Pi Zero W.
Now you have to type following instruction to enable ssh
sudo raspi-config
In the menu select 1st option and expand file system.
After that scroll down to option 9 (Advance Options) and hit enter and search for ssh option and hit enter to enable it. The Pi will reboot as you enable the ssh. Wait and let it reboot.
Step 3: Setting Up Wifi
Now that your SSH is enabled you need to connect your Pi to internet. Raspberry Pi zero W comes with on board wifi and bluetooth 4.0 so we will use wifi to connect you router or mobile phone hotspot.
Now type following on terminal
sudo apt-get update
This command will update your Pi. After the update type following
sudo apt-get upgrade
This command will upgrade all installed software. This will take a minute or two so wait.
Now we will setup wifi connection. Type following command in terminal and hit enter.
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
This will open a file in which you'll need to add your country, SSID and password of your wifi network.
network={ ssid="your ssid"
psk="your password" }
Now for saving the file press Ctrl+X then Y and press enter. Now your wifi settings is completed.
Reboot your Pi by following command
sudo reboot
Wait till it starts.
Now type following command to check whether it is connected to your wifi or not.
sudo ifconfig
If you see an IP address in wlan0, it means your pi is now connected to your wifi network.
Step 4: Setting SSH Over Internet (weaved)
Now that you are connected to wifi, we can download Weaved software.
What is Weaved? - It is a software that will allow you to connect to your pi through various internet services like SSH , HTTP and many more. It will be a bit long but please bare with me.
In terminal type
sudo apt-get install weavedconnectd
and hit enter. It will install the software.
Now you'll need www.remot3.it account. So sign up to remot3.it and remember your login details.
remot3.it is the new name for weaved so don't get confused.
In terminal type
sudo weavedinstaller
hit enter and the software will start. Initially it will check your network compatibility. And then ask you to name your pi. You can choose any name. After you name your Pi, sign in to your remot3 account using menu options.
After you sign in, Select Option 1 (Attach/reinstall remot3.it to a Service)
This will open a new menu which will show you different options including SSH option.
As you select SSH option it will as you to change port. Simply let it be 22 and then name your SSH service.
I strongly suggest you to put "_ssh" after your service name so that you can identify it on remot3.it website.
Now it is almost complete. You need to login to you www.remot3.it account and check your manage device option. Your registered raspberry pi zero w will be there.
Now go through the images. Select your Pi on manage device, select ssh service and let the proxy service connect to your pi.
Copy the proxy URL and port.
Now use Putty software from your computer. Paste your proxy url and port and hit connect. You should connect to your Pi through internet (Not through local network).
Step 5: Installing Motion for Camera
Now that you have successfully connected to Wifi and SSH, you'll need to download some files before running your camera. Type following in your terminal:
sudo apt-get install motion
Let it get installed. It will take 2 - 3 minutes. Now "motion" is software that works as a server service from your Pi. It broadcasts your camera on its local IP & port. Most of the cameras are compatible with motion however it is better to check whether the camera have connected to pi or not.
Type lsusb in your terminal to check the connection status of the camera. IF it is there it means every thing is fine. If not ... you probably need another camera.
Step 6: Configure the Motion Software
Type following in the terminal
sudo nano /etc/motion/motion.conf
Then you have to change some settings in the .conf file. It might be difficult sometimes to find the settings but use 'ctrl + w' to find it. So follow the steps:
Make sure 'daemon' is ON.
Set 'framerate' anywhere in between 1000 to 1500.
Keep 'Stream_port' to 8081.
'Stream_quality' should be 100.
Change 'Stream_localhost' to OFF.
Change 'webcontrol_localhost' to OFF.
Set 'quality' to 100.
Set 'width' & 'height' to 640 & 480.
Set 'post_capture' to 5.
Press ctrl + x to exit. Type y to save and enter to conform.
Again type in the command 'sudo nano /etc/default/motion ' and press enter.
Set ' start_motion_daemon ' to yes. Save and exit.
Step 7: Configure HTTP Service in Weaved for Camera
As I mentioned, motion software will make your Raspberry Pi as a camera server. This server sends video footage (Live) on its IP & Port. Now we want to get access to this Live video for the same we once again have to open Weaved setup and set HTTP service.
Type following in terminal
sudo weavedinstaller
as you know by now you have to login to your remot3.it account. Then select attache/reinstall remot3 service.
Then select option 2 (Wen (http) on Port 80). Again you need to add a service name. I suggest you to put "_http" in the name just to know that this is http service. The same thing we have done with ssh.
After you name the service, software will ask you the port. Default port is 80. We want to change it to 8081 so type "n" (n for No) and system will ask you the port number. Simply type 8081 and hit enter. Your http service will be set and activated.
Step 8: Accessing Your IP Camera
Now everything is set. Reboot your Raspberry Pi Zero W.
Open and login to www.remot3.it
In device manager click on your Device (our Raspberry)
There will be two options
1. ssh
2. http
Now click on http option.
It will generate a proxy link.
Open it in a web browser and your done.
You have successfully completed this instructable.
Thank You for reading this instructable. I hope you like it. I have gathered information from internet to build this instuctable. I like to thank sat481 for his instructable for motion (Link here - Click Here).For any query and suggestions please comment. Once again thank you.