I realized that the cables connecting sensor with the Pi are picking up some WiFi interference as they are placed quite close to the dongle. At some point I noticed that sensor works normally again when the WiFi dongle is switched off. But when I built it in a mirror there was a problem – a sensor output was always in high state! I’ve lost a lots of nerves trying to find what was the reason for malfunction. When I tested the PIR sensor for the first time it worked like a charm. Each of these contains simple tvservice command and everything would be easy-peasy if there wasn’t that HDMI/VGA babble. Now, this is an interesting part: monitor is turned on/off by calling a shell scripts monitor_on.sh and monitor_off.sh. The script basically reads the sensor state from the 7th GPIO pin and depending on its state and the time since the last activity it turns on or off the monitors. Subprocess.call(& amp quot sh /home/pi/Documents/PIR/monitor_off.sh& amp quot, shell=True) Subprocess.call(& amp quot sh /home/pi/Documents/PIR/monitor_on.sh& amp quot, shell=True) If not turned_off and time.time() & amp gt (last_motion_time + SHUTOFF_DELAY): Simple Python script can easily access those pins and read out the PIR sensor’s state. I connected mine to 26th pin of the header which corresponds to the 7th GPIO port. You can use R Pi’s general purpose input/output pins (GPIO) to connect the sensor. Adafruit has a pretty helpful tutorial on these thingies. It has only one output pin that is logic high (3.3V) when the motion is detected and low (0 V) otherwise. It usually comes on a board with a regulation circuitry, BISS0001 motion detector IC, and plastic cap that focuses the radiation. So it senses your body heat when you move around. There are many options of motion detection, and the most popular one is arguably a PIR sensor which is basically an IR sensitive JFET. Well done! Adding a motion detector HC-SR501 PIR motion detector I used If needed, you can rotate your screen (if you use it in vertical mode) by adding "DISPLAY_ROTATE=1" in /boot/config.txt (I didn’t need it).Īt this point you should have the R Pi running the Michael’s code with your private settings. You can also disable the cursor showing in the middle of your screen by installing unclutter ( sudo apt-get install unclutter). It will also disable the screen going off eventually. I used Midori as web-browser, and I edit /home/pi/.config/lxsession/LXDE-pi/autostart to include commands s s -e Fullscreen -a that will ensure that R Pi opens a Midori browser on your homepage in fullscreen mode right after it boots up.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |