Kutluhan AktarJLCPCB
Published © CC BY

Light Intensity and Solar Energy Detector with Tilt Sensor

Evaluate the possible magnitude of solar energy by the light intensity in a given direction to charge batteries efficiently.

AdvancedFull instructions provided1 hour2,441
Light Intensity and Solar Energy Detector with Tilt Sensor

Things used in this project

Hardware components

JLCPCB Customized PCB
JLCPCB Customized PCB
×1
Arduino Nano R3
Arduino Nano R3
×1
Adafruit 10mm Photoresistor
×4
SparkFun Tilt Sensor (Mercury Sensor)
×1
Buzzer
Buzzer
×1
5 mm LED: Red
5 mm LED: Red
×4
5 mm LED: Yellow
5 mm LED: Yellow
×4
5 mm LED: Green
5 mm LED: Green
×4
Resistor 220 ohm
Resistor 220 ohm
×13
Resistor 1k ohm
Resistor 1k ohm
×5
DC POWER JACK 2.1MM BARREL-TYPE PCB MOUNT
TaydaElectronics DC POWER JACK 2.1MM BARREL-TYPE PCB MOUNT
×1

Software apps and online services

Arduino IDE
Arduino IDE
KiCad
KiCad

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free

Story

Read more

Custom parts and enclosures

Gerber Files

Fabrication Files

Schematics

PCB_1

PCB_2

PCB_3

Code

Light_Intensity_and_Solar_Energy_Detector.ino

Arduino
         /////////////////////////////////////////////  
        //    Light Intensity and Solar Energy     //
       //        Detector with Tilt Sensor        //
      //             ---------------             //
     //             (Arduino Nano)              //           
    //             by Kutluhan Aktar           // 
   //                                         //
  /////////////////////////////////////////////

// Evaluate the possible magnitude of solar energy by the light intensity in a given direction to charge batteries efficiently.
//
// The amount of energy generated by a solar panel is related to the amount of solar radiation. Which is why, I used light intensity values as a substitute to calculate it approximately.
//
// Threshold indicators for each direction:
//
// Red - Low
// Yellow - Moderate
// Green - High 
//
// I determine the thresholds for each level by conducting tests with my solar panel: I observed time passed in a given light intensity value to full-charge a 3.7V Li-Po battery.
//
// So, do not forget to change the thresholds according to your experiments with your battery and solar panel.
//
// Connections
// Arduino Nano :           
//                                direction_1_LOW
// D4  ---------------------------
//                                direction_1_MODERATE
// D3  ---------------------------
//                                direction_1_HIGH
// D2  ---------------------------
//                                direction_2_LOW
// D7  ---------------------------
//                                direction_2_MODERATE
// D6  ---------------------------
//                                direction_2_HIGH
// D5  ---------------------------
//                                direction_3_LOW
// D8  ---------------------------
//                                direction_3_MODERATE
// D9  ---------------------------
//                                direction_3_HIGH
// D10 ---------------------------
//                                direction_4_LOW
// D13 ---------------------------
//                                direction_4_MODERATE
// A4  ---------------------------
//                                direction_4_HIGH
// A5  ---------------------------
//                                Buzzer
// D11 ---------------------------
//                                Tilt Sensor
// D12 ---------------------------
//                                direction_1_LDR
// A0  ---------------------------
//                                direction_2_LDR
// A1  ---------------------------
//                                direction_3_LDR
// A2  ---------------------------
//                                direction_4_LDR
// A3  ---------------------------


// Define indicators (red, yellow, green) for each direction.
#define direction_1_LOW 4
#define direction_1_MODERATE 3
#define direction_1_HIGH 2
#define direction_2_LOW 7
#define direction_2_MODERATE 6
#define direction_2_HIGH 5
#define direction_3_LOW 8
#define direction_3_MODERATE 9
#define direction_3_HIGH 10
#define direction_4_LOW 13
#define direction_4_MODERATE 18
#define direction_4_HIGH 19

// Define LDR pins for each direction to gather light intensity values.
#define direction_1_LDR A0
#define direction_2_LDR A1
#define direction_3_LDR A2
#define direction_4_LDR A3

// Define the buzzer pin and the tilt sensor pin.
#define buzzerPin 11 
#define tiltPin 12

// Define the solar panel (SP) specifications which differ amid different brands. So, change these variables with that of your solar panel.
#define SP_area 0.0088
#define SP_efficiency 6.2
#define SP_coefficient 0.75

// Define thresholds by experimenting.
#define low 9.15
#define moderate 19.48 
  
// Define data holders:
int LDR_1, LDR_2, LDR_3, LDR_4;


void setup() {
  Serial.begin(9600);
  Serial.print("\nDevice Activated:\n");
  Serial.print("Do not forget to change solar panel specifications and thresholds!\n");
  
  pinMode(direction_1_LOW, OUTPUT);
  pinMode(direction_1_MODERATE, OUTPUT);
  pinMode(direction_1_HIGH, OUTPUT);
  pinMode(direction_2_LOW, OUTPUT);
  pinMode(direction_2_MODERATE, OUTPUT);
  pinMode(direction_2_HIGH, OUTPUT);
  pinMode(direction_3_LOW, OUTPUT);
  pinMode(direction_3_MODERATE, OUTPUT);
  pinMode(direction_3_HIGH, OUTPUT);
  pinMode(direction_4_LOW, OUTPUT);
  pinMode(direction_4_MODERATE, OUTPUT);
  pinMode(direction_4_HIGH, OUTPUT);
  
  pinMode(tiltPin, INPUT);

}

void loop() {
  // Gather light intensity data from photoresistors.
  get_Light_Intensity();

  // Activate the tilt sensor to get accurate results with photoresistors.
  Tilt(digitalRead(tiltPin));

  // Initiate threshold detection for each direction:

  // Direction (1):
  Indicate_Thresholds(Solar_Panel_Energy(SP_area, SP_efficiency, LDR_1, SP_coefficient), direction_1_LOW, direction_1_MODERATE, direction_1_HIGH, 1);
  
  // Direction (2):
  Indicate_Thresholds(Solar_Panel_Energy(SP_area, SP_efficiency, LDR_2, SP_coefficient), direction_2_LOW, direction_2_MODERATE, direction_2_HIGH, 2);
  
  // Direction (3):
  Indicate_Thresholds(Solar_Panel_Energy(SP_area, SP_efficiency, LDR_3, SP_coefficient), direction_3_LOW, direction_3_MODERATE, direction_3_HIGH, 3);
  
  // Direction (4):
  Indicate_Thresholds(Solar_Panel_Energy(SP_area, SP_efficiency, LDR_4, SP_coefficient), direction_4_LOW, direction_4_MODERATE, direction_4_HIGH, 4);
 
}

void get_Light_Intensity(){
  LDR_1 = analogRead(direction_1_LDR);
  LDR_2 = analogRead(direction_2_LDR);
  LDR_3 = analogRead(direction_3_LDR);
  LDR_4 = analogRead(direction_4_LDR);

}

void Tilt(int tilt){
  // Get notified if the device moves into a sloping position.
  if(tilt == HIGH){
    tone(buzzerPin, 350);
  }else if(tilt == LOW){
    noTone(buzzerPin);
  }
}
  
float Solar_Panel_Energy(float Area, float Efficiency, int Radiation, float Coefficient){
  // Calculate the possible magnitude of solar energy by using the light intensity values as a substitute for radiation. 
  float Energy = Area * Efficiency * Radiation * Coefficient;
  return Energy;
}

void Indicate_Thresholds(float predictedEnergy, int red, int yellow, int green, int direction){
  // Print the selected direction.
  Serial.print("Direction ("); 
  Serial.print(direction); 
  Serial.print(") = \t");
  Serial.print(predictedEnergy);
  Serial.print("\n");
  // THRESHOLDS:       
  if(predictedEnergy < low){
    digitalWrite(red, HIGH);
    digitalWrite(yellow, LOW);
    digitalWrite(green, LOW);
  }else if(low <= predictedEnergy && predictedEnergy < moderate){
    digitalWrite(red, HIGH);
    digitalWrite(yellow,HIGH);
    digitalWrite(green, LOW);
  }else if(predictedEnergy >= moderate){
    digitalWrite(red, HIGH);
    digitalWrite(yellow, HIGH);
    digitalWrite(green, HIGH);
  }
          
}
     

Credits

Kutluhan Aktar

Kutluhan Aktar

79 projects • 290 followers
Self-Taught Full-Stack Developer | @EdgeImpulse Ambassador | Maker | Independent Researcher
JLCPCB

JLCPCB

68 projects • 38 followers
JLCPCB, is the largest PCB and PCB Assembly prototype enterprise in Asia. Coupon code "JLCPCBcom" for all and permanantly available.

Comments