Overview
This is a step-by-step tutorial on how to power your Arduino Uno and a servo motor with a 6V 2W solar cell. Powering your device with a solar cell can be useful if there is no accessible wired energy source, or it portability is required. Please check your motor’s voltage and current requirements to determine the power requirements of the solar cell and battery. This tutorial uses concepts drawn from the following resources:
Hannah Bonestroo’s tutorial, Powering Arduino Uno with Solar Cell
https://www.youtube.com/watch?v=Q5bi9-oQezE
https://www.youtube.com/watch?v=YC4kIGQYld4
For more details on how to apply the servo motor to track light and optimize the solar cell, refer to Delfina Vildosola’s tutorial, Using photoresistors and a servo motor to make a single axis solar tracker.
Parts
Solar panel: Select a solar panel with a power output rating that will be sufficient power supply for your motor. In this tutorial, we will use a solar cell with a total output of 6V and 2W. Multiple solar cells could be wired in a series to duplicate power supply. Generally, the current will depend on the amount of sunlight and angel of the panel.
Solar charge controller: Choose a solar charge controller with a built-in voltage regulator.
Battery: Choose a rechargeable battery with a capacity that can store enough energy to power your Arduino Uno and motor for the desired duration in case there’s no direct solar power.
Boost Converter: If the voltage output of the solar cell is lower than the voltage required by your components, then you will need to use a boost converter to increase the voltage to the required level.
Arduino Uno: You will need an Arduino Uno board to control the motor and other components.
Servo Motor: Choose a motor with specifications that match the power supply and voltage requirements of your system. (Refer to Delfina’s tutorial for details on servo motor.)
Wires and connectors: You will need wires, soldering kit, and connectors to connect the components together.
Wiring and Testing
- Solder the positive (+) and negative (-) terminals of the solar panel to the input terminals of the solar charge controller using M-M jumper wires.
- Solder the positive (+) and negative (-) terminals of the solar charge controller to the corresponding terminals of the battery using M-M jumper wires.
- Solder the output wires from the battery holder to the TP4056 battery charge controller B+ and B- terminals.
- Solder output wires from the battery charge controller to the input terminal of the XL6009 – Voltage Adjustable DC-DC (5v-35v) Boost Converter. Use a voltmeter connected to the output terminals to determine the output voltage.
- Connect the output terminals of the solar charge controller to the Vin (+) and GND (-) pins of the Arduino Uno board. Powering the Arduino Uno through the Vin port requires an input between 7 and 12 Volts, so the desired output from the Boost Converter is 9V. The voltage output can be adjusted by turning the knob located on the blue rectangle.
- Connect your motor to your Arduino Uno board using an appropriate motor driver such as the L293D. Be sure to connect the motor driver to the appropriate digital pins on the Arduino Uno.
- Write a program on your Arduino Uno board to control the motor based on your desired specifications. See <Code> section below for details on this tutorial’s program.
- Test the system by exposing the solar panel to sunlight and verifying that the Arduino Uno and motor are receiving power and operating correctly.
Code
This code is basic foundation to help manage the speed of the motor. Generally, required code to manage the solar panel is limited with the boost converter and power manager wired in.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
int motorPin = 9; // The digital pin to which the motor driver is connected int speed = 255; // The speed of the motor (0-255) void setup() { pinMode(motorPin, OUTPUT); } void loop() { // Read the voltage from the boost converter float voltage = analogRead(A0) * 5.0 / 1023.0; // If the voltage is less than 12V, turn off the motor if (voltage < 12.0) { digitalWrite(motorPin, LOW); } // If the voltage is greater than or equal to 12V, turn on the motor else { digitalWrite(motorPin, HIGH); analogWrite(motorPin, speed); } } |
Example Application
Photo of prototype set-up of solar cell charging battery pack and powering an Arduino and servo motor that tracks light with photoresistors