My friend Dominic asked me to install some spotlights in the Wang Tong Art alley. The requirements were:
- 6 spotlights
- 2 LED strips
- 2 motion detectors for people approaching from both sides
- battery-powered with solar charging
I decided to use a 12V lead-acid battery, after having experimented a bit with Lithium 3.7V cells. We monitor the system via an ESP32-based voltage/current sensor, providing data to a ThingsBoard dashboard.
PIR motion sensors
We’re using the common Arduino-style PIR modules, which can be powered from 12V, but only output a signal of around 3V. We’re combining the 2 outputs in an OR gate using 2 diodes, resulting in a signal of around 2V. We’re using a logic-level N channel MOSFET (IRLZ14S) which has a Gate-Source Threshold value of 1-2V, but to conduct more than 1A, it needs more than 3V, so we need to boost the PIR signal to a higher voltage. Based on this example, we used the below circuit. It boosts the signal to 50% of VBAT, so around 6V, and can deliver the 3A we need for our spotlights.
I soldered this circuit on a perf board, and mounted it in a waterproof box with the 2 PIR modules glued to circular holes on the side. The black power cables are VBAT_IN and V_OUT.
By default these PIR modules work in daylight and in the dark, while we only want our spotlights to switch on during night time. The modules can easily be hacked to operate only in the dark, by adding an LDR. I used LDRs that go to 100Kohm in darkness.
SPOTLIGHTS
We’re using 12-24V DC spotlights, rated 3W; at 12V they draw about 200mA (2.4W). To make the cabling assembly waterproof, we’re using a system of barrel jack cables and connectors. I disassembled the spotlights to solder a cable with connector directly to the spotlight’s PCB.
LED STRIPS
To light up a few semi-transparent art works in window frames, we mounted 2 sticks with 12V RGB LED strips on the sides of window frames behind the art work. Each stick has 30 pixels (non-addressable), and full white (R+G+B) draws about 1000mA at 12V (60 LEDs as in below picture). To reduce the power draw, we use a PWM dimmer based on a 555 timer as in this example. It works exactly as advertised, we used a P channel MOSFET (27P06) and added 2x 220uF decoupling capacitors, and mounted it in a waterproof box.
SOLAR CHARGED BATTERY
We started with a common Sealed Lead-Acid battery 12V 7Ah but depleted after a few days without sunshine, so we upgraded to a 12V 26Ah (YUASA NP26-12B). For solar charging, we use the DFR0580 module, built around the CN3767 charger IC. It is intended for use with 18V solar panels, and claims to have an MPPT feature, but that actually means just a fixed solar voltage of 18V. An interesting discussion about its features/limitations can be found here. It has the usual protection features, and switchable VBAT and 5V outputs. The over-discharge protection voltage is set to 10.8V, which is very low, so in our system, we want to disable the VBAT output at a higher level, e.g. 11.5V to increase the battery life. I have written another blog post about testing the DFR0580.
The charger is monitored by an ESP32 based TTGO T-Display with an INA219 voltage/current sensor. The ESP32 board is powered by the 5V output of the DFR0580 charger. The INA219 sensor measures the battery voltage and charge/discharge current. The solar voltage is measured via a voltage divider that feeds into an ADC GPIO pin. The VBAT output of the DFR0580 is controlled with another GPIO pin. Below picture shows the T-Display with INA219 sensor in the top left, the DFR0580 board bottom left, and the SLA battery on the right. All fits into a waterproof storage box, with 2 waterproof WEIPU SP13 connectors.
We tested the system extensively with this simple setup with 1 spotlight.
Now the box as installed on brackets in the art alley, with a large YUASA NP26-12B battery (12V 26Ah).
The solar panel is place on top of the wall, and gets a good 4 hours of sunshine from 10am to 2pm.
This is the dimmer for the LED strips.
REMOTE MONITORING
The ESP32 T-Display module is connected to a nearby WiFi network, and communicates with a cloud server via MQTT. The cloud server runs ThingsBoard, a popular open-source IoT platform that stores the data and can visualize it in dashboards. Below example screenshot shows the battery was charging up to 3300mAh on 28 Dec (blue graph). It shows float charging at 13.5V when the battery is full (26 and 27 Dec). When one of the PIR sensors is triggered, it shows a large voltage drop of about 0.8V due to the internal resistance of the battery. The pink curve (charge/discharge current) shows that the charging current can reach around 1000mA, which means we get around only 12-13W out of our 20W panel, probably due to sub-optimal conditions (winter sun, relatively horizontal panel position).
When the PIRs trigger, the battery discharges around 2400mA, to switch on 6 spotlights (200mA each) and 4 strips of RGB LEDs with 30 pixels each, dimmed with PWM as detailed above. The PIR sensors are set to remain high for only a short 10 seconds. As long as VBAT remains above a certain threshold (e.g. 11.4V), the system is powered on constantly, and the switching is directly controlled by the PIRs.
The dashboard can also show us the hourly count of the PIR triggers, and we can adjust a few parameters remotely, such as the data sending interval, the sleep threshold voltage, the sleep interval.