Skip to content

Turn a Raspberry PI and an old usb webcam into a smart home camera with an Android companion app

Notifications You must be signed in to change notification settings

carlevans719/home-monitor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Turn a Raspberry PI and an old usb webcam into a smart home camera with an Android companion app

Getting Started

  1. Install Motion on the raspberry pi
  2. Copy over the config files from etc_motion in this repo to /etc/motion on the pi
  3. Create the Monitor and Motion_Api directories on the pi in /home/pi
  4. Copy over the API source code from home-monitor-api in this repo to /home/pi/Motion_Api on the pi
  5. Fill in the bcrypt hash of your default password to constants.js in the Motion_Api folder on the pi (change the username to your name too)
  6. Install nodejs on the pi
  7. Globally install forever on the pi npm i -g forever
  8. Add the line in pi_home/.bashrc_additions to /home/pi/.bashrc on the pi
  9. Also add export API_KEY=<your api key> to the .bashrc
  10. Add the line in pi_home/crontab to the crontab on the pi with crontab -e
  11. Copy over the on_motion_detected_camera*.sh scripts from pi_home in this repo to /home/pi on the pi
  12. Set the executable bit on the scripts chmod 755 on_motion_detected*
  13. Create the motion_events.log file in /home/pi on the pi
  14. Set the group ownership on the Monitor directory & the motion_events.log, on_motion_detected_camera1.sh and on_motion_detected_camera2.sh files to "motion" - sudo chown pi:motion Monitor motion_events.log on_motion_detected*
  15. Restart the pi (or start the motion service and api - sudo service motion start && cd /home/pi/Motion_Api && forever start index.js)
  16. Add a domain to cloudflare and CNAME it to your duckdns.org domain name
  17. (optional) If you don't have the duckdns script running elsewhere on your LAN, copy it on to the pi and follow the steps on duckdns to add a crontab entry
  18. Download an origin certificate from cloudflare & copy the cert & key to /home/pi on the pi. Call them "server.crt" and "server.key"
  19. Set the SSL mode to "full (strict)" for the domain on cloudflare
  20. Add a port forwarding rule to your router that forwards external tcp port 8443 to internal tcp port 3000 and set your pi's internal IP address as the destination
  21. If you haven't already, make sure your pi has a static internal IP by adding an entry to the address reservation table on your router
  22. Add a new Firebase project and follow the steps to enable Firebase Cloud Messaging. Download the google-services.json and replace the one in home-monitor-app in this repo
  23. Copy the server key from the firebase project and upload it to expo
  24. Build the expo project to an APK and copy it on to your phone & install it
  25. Before opening the app, go to the app settings and then in permissions, open location and make sure "enabled all the time" is selected. This will allow background geofencing to detect when you leave your house. You will only get push notifications when you're not home
  26. When you sign in, the location of your phone will be set as your home, so make sure you're home when you sign in

About

Turn a Raspberry PI and an old usb webcam into a smart home camera with an Android companion app

Resources

Stars

Watchers

Forks