Ever wished your solar lights were smarter and a bit more fun? Don’t let the sunset mean the fun is over; simply upgrade your lighting instead. With Arduino, this can be a simple and low-cost reality for any outdoor space. While some options exist that would probably meet the requirements, the real purpose of this project is to get lights on the play set and to solar power an Arduino for future upgrades.

What's needed?

Here is a list of components needed to start:

  • 1x solar powered LED lights
  • 1x passive infrared (PIR) sensor
  • 1x photoresistor
  • 1x Arduino nano
  • 4x 2N2222 NPN transistors
  • 4x 220 ohm resistors
  • 1x 1 kOhm resistor
  • 1x project box

Also needed is a playset in need of some lighting customization.

Taking things apart

Many of the needed components come from the store-bought security light. Most of these lights use the same type of setup. A solar panel on top collects power and charges a rechargeable battery and typically some type of control board as well. The lights in this project had a solar panel, rechargeable battery, control board, PIR sensor, photoresistor and three LED panels.

Let's take a look at some of these components in detail.

LED panels

LED panels are a great way to pump out a great deal of light with a small amount of power. LEDs have minimum voltage, under which the panel won’t light up at all. For these panels, that measured to be about 1.5 V DC. Being a diode, the LEDs require DC voltage applied in the correct direction. If the LEDs aren’t lighting, make sure that the wires aren’t swapped.

LEDs work great when paired with an Arduino and transistor because the voltage applied to the LED panel can be varied between the minimum and maximum. This will allow for two brightness levels in this scenario.

Photoresistor

Photoresistors are resistors that are sensitive to light output. As the light hitting them increases, their resistance typically goes down. These resistors with a voltage divider will determine how much light is detected.

PIR sensor

Passive infrared (PIR) sensors detect heat or motion moving in front of their sensors. These sensors use a fresnel lens to collect the infrared light in the viewing area and transmit directly to the sensor. Although the solar lights used in this project had a PIR sensor built in, they were replaced here with one that allows for the sensitivity and duration of the output to be adjusted.

Taking things apart

Most of these lights are simply held together with Phillips head screws; taking the screws out will allow for the whole assembly to come apart. After removing the solar panel section, open the central LED panel to expose the circuit board.

The circuit board houses the old PIR sensor, a timer IC and an on/off switch among other things. After carefully examining the wiring, begin cutting and removing all wires from the circuit board to be able to remove the left and right LED panels.

Soldering back together

The four wires shown connect to the battery and the solar panel. With everything disconnected, begin wiring up the Arduino and soldering everything together.

The wiring is very simple. The positive leads from the solar panel and battery are tied together and connected to the positive rail of the breadboard. The negative leads for the battery and solar panel are likewise tied together and connected to the ground rail on the breadboard. The inputs and outputs for the system are detailed below.

PIR sensor — Input

The wiring for the PIR sensor is straightforward: VCC, output,and ground. Two wires were soldered to the power and ground rails on the breadboard while the output wire was soldered to digital pin 2 on the Arduino. The other end of the wires had female header pins that securely connected to the sensor. The potentiometers on the PIR sensor can be adjusted to control sensitivity and output. In the code, the lights run at a low light level. If the PIR sensor detects motion, the value on digital input 2 goes high and the brightness of the lights increases.

Photoresistor — Output

The photoresistor helps keep from draining the battery during the day. The photoresistor is in series with a 1 kOhm resistor to form a voltage divider. One end of the photoresistor is connected to the positive rail and the other to the resistor. The other end of the resistor is connected to ground. A wire is connected to the junction of the resistor and photoresistor and connected to analog input 1 on the Arduino. As the sunlight received by the sensor increases, the resistance goes down. As the light falls, the resistance goes up and the voltage measured at A1 decreases. The code will only turn on the lights if the voltage measured at A1 is below the threshold.

Transistors — Outputs

Four 2N2222 NPN transistors will power the lights without all of the amperage running through the Arduino. Transistors work like solid state switches, enabling a quick power on/power off. Transistors have three connections and come in many different sizes. Current flows from the source to the drain when a voltage is applied to the gate. For these transistors, no voltage on the gate means no current will flow either.

Because there are three lights, each LED panel is connected to a transistor. Included is a fourth transistor for a future upgrade to have lights that fade in and out with time. Use a 220 ohm resistor in series between the outputs from the Arduino and the gate of the transistor to prevent excessive amperage from damaging the Arduino or transistor.

The outputs from the transistor and a ground wire are soldered to screw terminals mounted to the breadboard. Using screw terminals makes attaching the wires in the field much easier.

How the code works

The code takes inputs from the photoresistor first. If it detects light, nothing happens. The Arduino stays on but keeps everything else off to let the battery charge. When the sun goes down, then the fun starts.

When no light is detected, the code turns the transistors on to a low setting via pulse width modulation (PWM). PWM works by simulating an analog signal with a digital signal. If the desired outcome is to turn the lights on halfway, then turn them on half the time and turn them off the other half. If this is done quick enough, it results in half of the light being output.

For this Arduino project, any digital output that is PWM enabled can do this switching. In the code, write a value between 0 and 255 (0% and 100%) to determine how much current flow is allowed. In the code, the lights turn on to 15% automatically when the sun goes down.

When the PIR sensor detects movement, the lights need to be turned up to 100%, and this also starts a time delay. Five minutes after the last motion is detected, the lights will go back to 15% and wait for more motion.

The fourth transistor outputs current in a wave pattern. Feel free to hook up an LED panel to that screw terminal to get an idea of what having an Arduino in the loop can do.

Mounting everything

With the code working and everything soldered together, it’s time to start mounting. Put the solar panel in a good location where it will get sun most of the day.

Mount one of the LED panels in each of the main sections of the playset using L brackets, wood screws and the nut and bolt that came with the light originally. Cut a hole in the project box to allow wires to pass through when it's sealed up.

After running all the wires back to the project box, connect them to the screw terminals. Mount the photoresistor in a secure position where it can see the sunlight but not the LED panels. Otherwise, the lights will continuously cycle on and off. After everything is wired up, use silicone to seal any opening where water could leak in. Cover the photoresistor and check that everything looks right.

Get ready to enjoy some late summer nights now that lighting won’t be a problem. With a solar powered Arduino, there are many options for expansion. Have fun and tell us below some similar success stories!

About the author

Nick Ysidron is an engineer who specializes in product development and technical writing. He previously worked for an OEM equipment manufacturer leading a team of engineers and designers in building custom equipment for the commercial and industrial HVAC sectors. Nick currently designs IoT devices, as well as lending his talents to DIY and maker type projects.

To contact the author of this article, email engineering360editors@globalspec.com