Project Outdoor Light

Please watch my video on Youtube.https://youtu.be/n2i-DcMmE_s
HyperLink

Description:

The outdoor light I had was going on if there was movement. Nothing more, nothing less. Unfortunately the motion sensor has broken, so time to fix and improve.

The “new” outdoor light goes on for 30% when the sun goes down, goes off then the sun goes up and when there is movement, it goes smoothly to 100% and smoothly back to 30% after 5 minutes no movement.

What do we need? - Shopping list
Component Price total - jan. 2020
Old Outdoor lighFree
1 * NODE MCU8266 V3€ 2.01
1 * Step Down Converter 12V to 3.2V€ 0.45
1 * PIR AM312€ 0.97
3 * 1 K Ohm resistor€ 0.05
3 * 2N2222 Transistor€ 0.24
1 * Print Circuit Board€ 0.20
A small peace of LED Strip€ ?.??
1 * Power Adapter 12V 2A€ 3.52
TOTAL spend€ 7.44

The components I have used are all ordered in China but you can get them everywhere. The components are universal and cheap, so why should I throw away the old lamp and spend a fortune on a new one?

I need special tools?
Nope, no special tools are needed for the design. I decided to use my soldering iron and solder all the wires and I decided to hot glue everything. I it going to hang outside and I want to have good contacts but is it possible to use components with screw connectors and Dupont Line female – female wires.

Schematic - Outdoor light

Schematic Outdoor Light
The original design was with one 2N2222 transistor for the LED strips. By measuring the Ampere of the total length of LED strip, I notified the current was 0.77A and the max current for the 2N2222 transistor was 0.8A.
To avoid warming up the 2N2222 to much I decided to do this times 3 and uses 3 ports of the NODE MCU8266.

You can make this design for your own with some Dupont wires as an experiment, use a small peace of LED strip for testing.

I have chosen for the SP312 PIR. Ben from Bruh Automation has done some research and found out the SP312 PIR is the only one working fine. Thanks Ben, it saved me a lot of trouble. In this Video  Ben explanes everything on 4:27. Interesting video and Ben is one of the guys I've learned a lot from.

Code for the NODE MCU8266 to make the Outdoor light project work

I have written some code for this project and by clicking this link you can download it to your computer. Make some changes and upload it to you own NODE MCU8266.

I have made it myself a little bit easy to configure the time the sun was coming up and the time the sun was going down. In my Home Automation I was using the Sunset and Sunrise for more projects like the lights in the kitchen, etc. So I have been a little bit lazy and used my Home Automation to control the Sunset and Sunrise for the Outdoor Light. A full description of this function can found Here.
Another solution could be a time function in the NODE MCU8266 and turn it on and off at pre-configured times ..... not the way I like and the NODE MCU8266 needs to connect to the internet to get the right time and synchronize it from time to time, so you still need a WiFi connection.
The solution with the Home Automation makes it also possible to give the Sunrise and Sunset signal using LORA instead of WiFi. LORA uses less power and can be used on a bigger distance. One of my next projects will be an Outdoor Light for the back of my garden using LORA. Making changes The code I used is written by me and made for my home environment. You have to make some little changes to let it work on your environment.
In the first part, I have written all the code you need to change to make the Outdoor light work in your own home environment.

Connect to your WiFi and my Home Automation server (HASSIO):
// WiFi connection and MQTT connection
const char* ssid = "...";
const char* password = "...";
const char* mqtt_server = "...";
const char* mqtt_user = "...";
const char* mqtt_password = "...";
// End WiFi & MQTT setup

I have added some variables:
const int iDelayTime = 150; // Seconds
const int iStndBy = 125; // Standby light by night
to set the Delay time for the motion detection, it is in seconds and created a variable for the amount of light when the lamp is on and there is no motion, standby light.



I really hope you enjoyed this project. Please feel free to contact me for questions, improvements or whatever you want to tell me.

Ap Matteman

Please take contact with me