[PYTHON] Indoor monitoring using Raspberry Pi

Introduction

This is Qiita's first post. Thank you.

Suggestion

I wanted to make an inexpensive monitoring system with Raspberry Pi and sensors. Specifically, it is a monitoring system that installs RaspBerryPi Zero, RaspBerryPi camera, and motion sensor (HC-SR501) in the laboratory, takes a picture with a camera when a person is detected, and sends the image to Slack (unfinished).

Equipment used

・ Raspberry Pi zero ・ Raspberry Pi camera ・ HC-SR501 Human body infrared sensitive module ・ 3 jumper wires (female / female)

35B3DEB4-8FBA-453F-943E-1122772F86F7.jpg

Implementation

If the motion sensor detects a person, the program to shoot with the Raspberry Pi camera is as follows.

monitoring.py


import time
import picamera
import RPi.GPIO as GPIO

INTERVAL = 5

SLEEPTIME = 1

GPIO_PIN = 18

GPIO.setmode(GPIO.BCM)
GPIO.setup(GPIO_PIN,GPIO.IN)

if __name__ == '__main__':
    try:
        print("CTRL to cancel processing+C")
        while True:

            if(GPIO.input(GPIO_PIN) == GPIO.HIGH):
                with picamera.PiCamera() as camera
                    camera.resolution = (1024,768)
                    camera.brightness = 70
                    camera.capture('picture.jpg')
            else:
                time.sleep(INTERVAL)
    except KeyboardInterrupt:
        print("All processing finished")
    finally:
        GPIO.cleanup()

Execution result

I built a local web server and confirmed that the images were acquired.

キャプチャ picture.PNG

in conclusion

Currently, this system is incomplete because the process of sending data to Slack has not been implemented. After implementation, I would like to pursue the usefulness of this system by comparing it with other monitoring systems.

Recommended Posts

Indoor monitoring using Raspberry Pi
Raspberry Pi system monitoring
USB over ethernet using Raspberry pi
Try using ArUco on Raspberry Pi
Using a webcam with Raspberry Pi
Pet monitoring with Rekognition and Raspberry pi
Detect "brightness" using python on Raspberry Pi 3!
Make Raspberry Pi speak Japanese using OpenJtalk
Raspberry Pi backup
Run servomotor on Raspberry Pi 3 using python
Detect temperature using python on Raspberry Pi 3!
Detect slide switches using python on Raspberry Pi 3!
Try using a QR code on a Raspberry Pi
Detect magnet switches using python on Raspberry Pi 3!
Automatic launch of Raspberry Pi programs using Systemd
Send data from Raspberry Pi using AWS IOT
Sound the buzzer using python on Raspberry Pi 3!
Create a visitor notification system using Raspberry Pi
Connect your Raspberry Pi to your smartphone using Blynk
What is Raspberry Pi?
GPGPU with Raspberry Pi
pigpio on Raspberry pi
Raspberry Pi video camera
Raspberry Pi Bad Knowledge
Let's do Raspberry Pi?
DigitalSignage with Raspberry Pi
Raspberry Pi 4 setup memo
Cython on Raspberry Pi
Build an OpenCV4 environment on Raspberry Pi using Poetry
Create a color sensor using a Raspberry Pi and a camera
Using the digital illuminance sensor TSL2561 with Raspberry Pi
Using Akizuki Denshi's 4WD car FT-MC-004 with Raspberry Pi
Monitor temperature using Raspberry Pi + Alibaba cloud IoT platform
Try using the temperature sensor (LM75B) on the Raspberry Pi.
Output to "7-segment LED" using python on Raspberry Pi 3!
Introduced python3-OpenCV3 to Raspberry Pi
Raspberry Pi 4B initial setting
Mutter plants with Raspberry Pi
Install Raspberry Pi OS (Raspbian)
Cross-compiling for Raspberry Pi Zero on Debian-Try using shared libraries
Detect "temperature (using A / D converter)" using python on Raspberry Pi 3!
I talked to Raspberry Pi
Website change monitoring using python
Access google spreadsheet using python on raspberry pi (for myself)
Introducing PyMySQL to raspberry pi3
Raspberry Pi + Python + OpenGL memo
I tried using the DS18B20 temperature sensor with Raspberry Pi
I tried to automate [a certain task] using Raspberry Pi
Check! Let's develop Raspberry Pi Zero remotely-Try using Arafruit WebIDE
Raspbian initial settings (Raspberry Pi 4)
raspberry pi 1 model b, python
Introduced pyenv on Raspberry Pi
How to get temperature from switchBot thermo-hygrometer using raspberry Pi
Construction of Cortex-M development environment for TOPPERS using Raspberry Pi
Use NeoPixel on Raspberry Pi
Get the weather using the API and let the Raspberry Pi speak!
Install OpenCV4 on Raspberry Pi 3
Install TensorFlow 1.15.0 on Raspberry Pi
Control the motor with a motor driver using python on Raspberry Pi 3!
Make a simple CO2 incubator using Raspberry PI and CO2 sensor (MH-Z14A)
Weighing instrument using raspberry pi and hx711 (GUI display on Tkinter)