Required equipment:
- Raspberry Pi 3 B+ with Raspbian OS + motion for Camera module
- Camera module
- 2 SG90 servo motor, holder for camera and SG90
- Android device
The required equipment in this projects are Raspberry Pi 3 Model B+, Camera module, 2 SG90 servo motors, holder for motor and camera module, Android device to monitor and control CCTV.
If you didn't install Raspbian OS and motion software on your Raspberry Pi, you need to check this first.
<Fig.> Home IoT architecture for CCTV
The source codes consist of two parts for the server(Raspberry Pi) and the client(Android device).
In the server side, there are Node.js, html and python code. In the client side, there is an android project code.
Node.js communicates with the client(Android app.) through html using socket connection and also can control the GPIO of Raspberry Pi.
In this project, the python code directly controls the angle of 2 sg90 servo motors whenever the client requests it.
To download the newest version of Node.js (Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine.),
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
To install Node.js,
sudo apt-get install -y nodejs
To check the version of Node.js, installed,
node -v
Place the source codes such as cctv_control.js, public/cctv_control.html and camera_move.py in the same directory on Raspberry Pi.
To run Node.js on Raspberry Pi, you have to use npm, Node.js package manager which is installed with Node.js. After that, run Node.js file, cctv_control.js. (npm is a package manager for the JavaScript programming language. It is the default package manager for the JavaScript runtime environment Node.js.)
npm init
npm install socket.io --save
node cctv_control.js
Watch the video to check how this project works.