https://github.com/ahmednuaman/rpi-magnetic-sensor
A nodejs project to get a magnetic sensor to work with a Raspberry PI
https://github.com/ahmednuaman/rpi-magnetic-sensor
Last synced: 2 months ago
JSON representation
A nodejs project to get a magnetic sensor to work with a Raspberry PI
- Host: GitHub
- URL: https://github.com/ahmednuaman/rpi-magnetic-sensor
- Owner: ahmednuaman
- License: mit
- Created: 2016-11-07T11:51:58.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-12-20T16:31:26.000Z (over 8 years ago)
- Last Synced: 2025-02-10T14:09:01.434Z (4 months ago)
- Language: JavaScript
- Size: 80.1 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rpi-magnetic-sensor
A nodejs project to get a magnetic sensor to work with a Raspberry PI## Setting up the hardware parts
You'll need:* A Raspberry PI, I'm using v3 (with OS installed, plus git, daemontools, and node)
* A magnetic sensor (eg [this one from eBay](http://www.ebay.co.uk/itm/White-Door-Window-Contacts-Magnetic-Reed-Switch-Sensor-PK-/331806213523?hash=item4d41310593:g:We4AAOSwr7ZW7Bou))
* GPIO connectors (I've used [female-to-female](http://www.ebay.co.uk/itm/40pcs-Dupont-Cables-FEMALE-TO-FEMALE-Jumper-GPIO-Wire-Ribbon-Breadboard-Arduino-/262202710636?hash=item3d0c7fda6c:g:v~gAAOSwuAVWzUtn))This is my hardware set up:
I use PINs 12 (BCM 18) and 14 (Ground) to connect to the sensor (you're able to change this in the code). Here's a handy chart: https://pinout.xyz/
## Setting up the software parts
1. Do everything as *root* (I know, I know)
2. Open `/etc/rc.local` and add `svscan /service &` before `exit 0`
3. Make a folder `/service`
4. `cd` into `/service` and clone the repo, this'll create a folder within called `rpi-magnetic-sensor`
5. `cd` into the repo folder, run `chmod +x run`
6. Copy `config.json.sample` to `config.json` and fill it out*
7. Reboot the PI!*If you're using Gmail you'll need to enable your account to be logged in via less secure apps, see: http://stackoverflow.com/a/40308643/398939