Skip to content

Latest commit

 

History

History
34 lines (28 loc) · 1.27 KB

File metadata and controls

34 lines (28 loc) · 1.27 KB

hackathon2016sensor

Raspberry Pi-based light sensor developed as part of the 2016 BMS hackathon.

Utilizes a BH1750 light sensor in order to detect whether the toilet is occupied or empty. Sensitivity threshold and other low-level parameters (ie. refresh delay) can be customized in light-sensor.py.

Configuration

Use config.py in order to set up the endpoint where statuses will be reported to. In general, reporting happens once in 30 secs and every time the occupied status changes, so the delay is kept minimal.

Running

python light-sensor.py

Setting up as a system service

We used systemd in order to manage our system service. In order to set it up:

  • Copy Python scripts to /opt/light-sensor. The directory should contain three scripts (bh1750.py, light-sensor.py and config.py)
  • Create a /lib/systemd/system/light-sensor.service file with the following content:
[Unit]
Description=Light sensor
After=multi-user.target

[Service]
Type=idle
ExecStart=/usr/bin/python2 /opt/light-sensor/light-sensor.py
WorkingDirectory=/opt/light-sensor

[Install]
WantedBy=multi-user.target
  • Register and enable the service with following commands:
sudo systemctl daemon-reload
sudo systemctl enable light-sensor.service
sudo systemctl start light-sensor.service