NANDHINI P
Published © GPL3+

Harvest Natural and Artificial Light Using Solar Cell

To obtain power from artificial lights in the night time and sunlight in the day time by conventional solar cell using IoT

IntermediateFull instructions provided1 hour974
Harvest Natural and Artificial Light Using Solar Cell

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
Arduino UNO
Arduino UNO
×1
LDR, 5 Mohm
LDR, 5 Mohm
×2
Resistor 221 ohm
Resistor 221 ohm
×2
Resistor 330 ohm
Resistor 330 ohm
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
LED (generic)
LED (generic)
×1
solar cell
×1

Software apps and online services

Bolt IoT Android App
Bolt IoT Android App
Arduino IDE
Arduino IDE

Story

Read more

Custom parts and enclosures

Working video

Schematics

Cicuit diagram

connection should be made as per the diagram. power supply is given to the Arduino board only, it powers up the bolt Wi-Fi module.

Code

Arduino code for harvest natural and artificial light using solar cell

C/C++
This is the code to control servo rotation through manual control or automated.this should be typed in the Arduino IDE
#include <BoltIoT-Arduino-Helper.h>// add bolt library to bolt Arduino IDE
#ifndef API_KEY
#define API_KEY   "0e2ec95c-9722-4620-a810-2feca1e3d776"
#endif
#ifndef DEVICE_ID
#define DEVICE_ID "BOLT1349568"
#endif
#include <Servo.h>
Servo servo;   // Create a servo object to control the servo
int eLDRPin = A0; // Assign pins to the LDR's
int wLDRPin = A2;
int eastLDR = 0; //Create variables to store to LDR readings
int westLDR = 0;
int difference = 0; //Create a variable to compare the two LDR's
int servoSet = 0; //Variable for position of servo - will be different for each device
int led1=5;
int a;
 
// To set it as PWM
String runPwmCommand(String *data){
  int pwmChannel=data[0].toInt();
  int pwmValue=data[1].toInt();
  analogWrite(pwmChannel,pwmValue);
  return "Pin "+String(pwmChannel)+" set to PWM value "+String(pwmValue);
}

void setup() {
  // put your setup code here, to run once:
boltiot.begin(Serial);
boltiot.setCommandString("SetPWM",runPwmCommand,2,'.');  //The command and argument should be seperted by a '.' character. example SetPWM.6.200. . 
servo.attach(9);   //attaches the servo object to PWM pin 9
Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
 a=analogRead(led1);
if(a==255)
{servo.write(155);}//inside
if(a==0)
{
   eastLDR = analogRead(eLDRPin); //Read the LDR values
    westLDR = analogRead(wLDRPin);
     Serial.print(eastLDR);     
    Serial.print("   -   ");    
    Serial.print(westLDR);      
    Serial.print("   -   ");
    if (eastLDR < 400 && westLDR < 400) {  
        servo.write(155);(denotes inside)
   }  
    difference = eastLDR - westLDR ; //Check the difference
   //Outside 
    if (difference > 5) {     //Send the panel towards the LDR with a higher reading
      if (servoSet <= 50) {
        servoSet ++;
        servo.write(servoSet);
      }
    }
    Serial.print(difference);   
    Serial.print("   -   ");
    Serial.print(servoSet);     
    Serial.print("   -   ");
    Serial.println(".");
    delay(1000);
  }
boltiot.handleCommand();
}

Credits

NANDHINI P

NANDHINI P

1 project • 3 followers

Comments