Introduction: Solar Powered Security Sensor

About: Started playing with electronics to add extra character to my model train layout. The hobby keeps growing.

This simple and inexpensive security sensor has a few notable features that may be of interest to hobbyists:

  • Solar powered with a small solar cell
  • rechargeable lithium battery
  • charging circuit can be powered by USB cable for initial charge or battery recharge
  • Mosfet latching circuit so power is ONLY constant to the microwave sensor until motion is sensed
  • microwave/radar sensor uses only microamps of power.
  • uses an inexpensive ESP-01 for notifications

The key aspect of this circuit is using a P channel mosfet to latch the circuit on when a signal is received from the sensor and then having another signal from the ESP-01 keeping the circuit on and the latch in place until the ESP-01 is ready to turn off. Once the circuit is triggered on by the sensor, the circuit stays on, even if the sensor trigger turns off, until the ESP-01 program has completed. This circuit avoids the problem of the ESP-01 being dependent on how long the trigger output of the sensor remains active. Some sensors can have their trigger times modified on the sensor, others are more difficult. With this configuration, a brief active trigger is all that is needed.

Step 1: How It Works

When the sensor is triggered, it will output a positive signal to transistor Q1. (I have used both the radar sensor and a PIR. Both seem to work equally well. The radar sensor is better for outdoor use as it will detect motion through a plastic container and even walls. PIR's are not so functional outdoors where solar power is more suitable.)

When Q1 turns on, it will turn on Q3 through diode D1. When Q3 turns on, the gate of mosfet Q2 will be drawn to ground, turning on the mosfet and allowing current to flow in the circuit to the small 3.3v regulator (used to power the ESP-01).

As soon as the ESP-01 turns on, the Rx pin is set HIGH which will now also apply an active signal to Q3 through diode D2. Now, if the sensor is triggered low, Q3 is still on power still flows through the mosfet and the ESP-01 is kept on. This module will stay on until it's internal program sets the Rx pin LOW and if the sensor trigger is still LOW this will shut off power to the module.

Step 2: Supplies

1 - IRLML6402 P-Channel Mosfet (I am using an SOT-23 version). These little guys are much less expensive compared to larger T0-92 style P-CH mosfets.

2 - 1N5817 Diodes

1 - LED your choice!

2 - 2P connectors for the solar cell input and the lithium battery input. Some lithium batteries come with JST connectors of different sizes so you may want to determine what kind of connector to use. The gerber files are configured for connectors with a 2.54mm spacing.

1 - 1000uf capacitor (not strictly necessary. You may adjust the size. This is for smoothing power to the ESP-01)

2 - 2n3904 transistors

1 - 220 ohm resistor

2 - 1k resistors

2 - 10k resistors

2 - 100k resistors

1 - 220k resistor

1 - 3 pin slide switch

1 - 3 pin header for sensor input

1 - ESP-01

1 - 2x4 (8 pin) female header for setting ESP-01

1 - 3.3 volt regulator circuit board like this

1 - RCWL-0516 Microwave/Radar Sensor like this

1 - Solar charger board like this

Step 3: Arduino Code for the ESP-01

I have provided two code files that you can use to test the circuit.

the LatchCircuitTest.ino file is the simple test circuit that will flash the onboard LED of the ESP-01 for about 10 seconds before letting go of the latch. I am using the Rx pin of the ESP-01 for the latch circuit. (Pin 3). As long as this pin is set HIGH, the circuit will stay powered. Once this pin is set to LOW (and assuming the trigger pin is also LOW) the circuit will turn off, leaving on the sensor still powered to be triggered again.

The second file, ESP-01_Email_Solar_Power_Latch_Simple.ino, is coded to send an email via gmail anytime the circuit is triggered.

This file needs to be edited with the following information:

  • Your wifi SSID
  • Your wifi password
  • Your gmail address
  • Your gmail password
  • A to address for the email message
  • A from address for the email message

The file also includes code to send an http web request to an ESP-01 powered buzzer module that will respond to the request. It is ideal to have a buzzer configured so that at night, when you may not be monitoring emails, the buzzer may sound when the sensor circuit is triggered.

There is an example of the simple buzzer board (ESP-01) in my first instructable!

Step 4: Build Your Own PCB

The schematic for this project was generated using Kicad software. The PCB that you see in the video was also created using the files generated from Kicad.

You can order PCB's for this project from jclpcb.com or any other pcb supplier.

Here is a link to the Gerber Files that were generated for this project.