Skip to main content

Magnetic contact state monitor

Project description

Magnetic contact state monitor, completely written in Python.

RPi.MC is using magnetic contact switch (door/window sensor) with Raspberry Pi GPIO.

To connect to Raspberry Pi plug into GPIO PIN 17 (Physical pin 11) and POWER PIN. Install and execute raspi-mc and it should work. Alternatively you can user different PIN and execute raspi-mc with parameter: raspi-mc --pin pin_number.

doc/RPi.MC.png

RPi.MC supports number of parameters and also configuration file. For more details see raspi-mc --help or sample config.

Sensor is based on RPi.Sensor library, which make base for implementing different types of sensors in Python.

Pre-Installation requirements

  • Update system and install required dependencies:

    sudo apt-get update
  • Update system and install required dependencies:

    sudo apt-get install build-essential python3-dev python3-pip

Installation

  • Install the latest released version using pip:

    pip install https://github.com/ricco386/RPi.MC/zipball/master
  • Alternatively install latest released version from pypi:

    pip install --upgrade RPi.MC

Integration as a systemd service

  • Make sure all dependencies (listed below) are installed (done automatically when installing via pip)

  • The raspi-mc command should be installed somewhere in your PATH (done automatically when installing via pip), make sure raspi-mc.service has corect path in ExecStart set to raspi-mc executable.

  • Systemd scripts are available: https://github.com/ricco386/RPi.MC/tree/master/init.d to install them you will need root privileges, so we execute them as sudo:

    sudo cp init.d/raspi-mc.conf /etc/tmpfiles.d/
    sudo cp init.d/raspi-mc.service /etc/systemd/system/
    sudo systemd-tmpfiles --create /etc/tmpfiles.d/raspi-mc.conf
    sudo systemctl enable raspi-mc.service  # Enable service to start at system boot
    sudo systemctl start raspi-mc.service  # Start

Systemd scripts should be run under default Raspberry Pi user (pi), scripts have to be able access GPIO.

Dependencies:

Usage

You have to create a .sensor.cfg file and place into /home/pi/.sensor.cfg you can find example file in RPi.Sensor repo: https://github.com/ricco386/RPi.Sensor/blob/master/raspi_sensor/sensor.cfg.example and create section [Magnetic_Contact] where you can override default values.

raspi-mc also support multiple parameters to overwrite config parameters. For more info run:

raspi-mc --help

Zabbix support

In directory zabbix_template there is a Zabbix template that can be imported to Zabbix and monitor systemd process if it is running and how much memory it consumes. It also supports Zabbix trapper rpi.mc-state that can receive a sensor state changes.

License

For more information see the LICENSE file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

RPi.MC-0.5.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

RPi.MC-0.5.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file RPi.MC-0.5.0.tar.gz.

File metadata

  • Download URL: RPi.MC-0.5.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3

File hashes

Hashes for RPi.MC-0.5.0.tar.gz
Algorithm Hash digest
SHA256 2e78d5ac46dfb41844cde429aa05305a02a5f5979210c5d3f5f08b68089b2844
MD5 00ec2cf609d5573c4efa7599b4832c05
BLAKE2b-256 507e6c13cb55130505d31bbb5ec92efac9a3e953a450f69d6b4faa95140fe2fb

See more details on using hashes here.

File details

Details for the file RPi.MC-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: RPi.MC-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3

File hashes

Hashes for RPi.MC-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 edfc8194d8ce5dc754bdcd2c0cfdcdc4030a6f262127228794ec427f53e68fbe
MD5 fb894ee1b95093cbd32fee48f914eb8f
BLAKE2b-256 94455c1872c74381ffb1d72390464ec365b83fcbd72d5a87eef6f542a69da57d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page