It is dark here on the mountain and a light was needed out front. All the outside lights are being changed so they can be turned on by a single action. This is needed when predators come around. A rustic looking fixture blends well in the forest, but if you make it, you can design any fixture you want. The ease of a mechanical switch for manual on/off allow the light to be turned on at the box. PIR detection is a great addition. Just anything else one could think of to enhance the use is great like weather reporting.
By the use of a Raspberry Pi and a Pi Face Digital this was easily accomplished.
The Light Fixture:
The cedar box was made for the rustic look. It is screwed and glued. The LEDs are 10Watt 12 Volt DC. These run quite hot and need a heat sink. A 90x10mm Quality HEAVY Aluminum Round Spiral Heat Sink works well and looks good. These heat sinks are press fit into a 3 1/2 inch hole in the cedar box. There was concern at first about venting but the cedar box closed in the back does not hinder the heat sink ability to keep the LEDs cool enough. The LEDs are wired in parallel with no resistors needed as they are 12 volt DC devices. Standard 2.1x5.5MM DC Power connectors and zip cord connect the lamp and the enclosure.
The enclosure for the controls is a 5133710 NEMA, Screw Cover, Enclosure which is watertight.
However that also means it contains the heat. Not good. Adding two 1 1/2 inch vented plugs allow enough convection flow to keep the Pi cool. Inside the enclosure, a single 12VDC 6 amp supply provides power. A buck converter provides the 5VDC for the Pi and PIR. A Pi Face Digital provides the input from two momentary push button switches and the relay output for the light. Weather is important on the mountain so we added an AdaFruit BME280 temperature, humidity and barometric pressure sensor.
The temperature sensor was located on the bottom of the enclosure, but the heat of the enclosure gave inaccurate readings so it is being moved to the fence.
The louvered vent plugs should keep rain out. The mountain gets a lot of rain so it is important to do all possible to combat it. For that reason, the switches although listed as weather proof are mounted on the side and all other connections are mounted on the bottom. A power indicator LED is mounted inside, and a clear plastic rod couples the light through the box cover without compromising the weather seal.
Assembly is pretty intuitive. The switches connect to the first two inputs of the PiFace and ground. The PIR sensor connects to input 17 or 18 (GPIO.BCM) of the PI, 5 VDC and ground. The BME280 is connected to the I2C inputs of the Pi, 3.3VDC and ground. Leave enough wire length between the hardware and the Pi so it can be lifted out for testing without disconnecting everything. The Pi is mounted on a plastic base which has Velcro on the back to adhere it to the enclosure. The power supply is also held to the enclosure by Velcro. This allows for easy maintenance. The BME280 is external and a 5 pin connector was soldered directly to the top of the Pi Face Digital GPIO connector on physical pins 1, 3, 5, 7 and 9. The connection to pin 7 is unused. A ribbon cable runs to a daughter board which has a connector for the BME28. This same daughter board has an intermediate connector for the PIR which links the output of the PIR to a connector on physical pins 11 and 12 (GPIO 17 and 18) of the Pi Face Digital GPIO connector. These two seem from experience to be the most reliable inputs for the PIR with a Pi Face connected.
There are many projects at Tiger Mountain Springs and ease of maintenance is crucial.
The Raspberry Pi is running headless via WiFi which can be a problem. If the WiFi router reboots, the Raspberry Pi is loath to reconnect. There are a number of discussions on correcting the problem.
There are a number of code blocks for the system. The AdaFruit BME280 is stored every 10 minutes by a crontab entry. Since the interrupt handling of the inputs from the switches and PIR are done by threaded procedures, they need to be cleaned up so there are two code blocks. One to start the system and one to shut it down. Crontab entries switch the light on at dusk and off at 10 PM.
There is also a web interface that is used to remotely switch the light. The software is Python and PHP. The HTML page calls PHP routines for the on and off which in turn call PHP routines for the actual switching of the light and return the status to the web page. The Python daemon software creates child processes. One for the on switch and one for the off switch and the third for the PIR. A MySql database keeps track of the light state and how it was set. If it is manually turned by switch, the PIR activity should not try and turn off the light. These child processes wait for input and are thus sleeping and a shut down or attempt to stop the daemon would leave those processes running so, as the processes are started, the process numbers are recorded in the database and the init.d stop entry runs the kill program to stop the processes.
The AdaFruit readings are taken by a crontab entry every 10 minutes and recorded to the network database for inclusion in the weather charts on our web page.
More is being added all the time so there may be edits of this page. Thanks for looking at it.