Hackster is hosting Hackster Holidays, Ep. 7: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 7 on Friday!
Shahariar
Published © CC BY-SA

Ambient Sun Light Reflector: Energy Harvesting

Sending sun light indoor with tracking mirror during day, logging lux level on the Cloud, BLE app controlled LED lamp for nighttime lighting

BeginnerFull instructions provided4 hours2,413

Things used in this project

Hardware components

RSL10-SENSE-GEVK
onsemi RSL10-SENSE-GEVK
×1
Stepper Motor
Digilent Stepper Motor
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
SparkFun Breadboard holder
×1
Arduino UNO
Arduino UNO
×1
SparkFun Slide Switch
×1
High Brightness LED, Cool White
High Brightness LED, Cool White
×6
Battery Holder, AAA x 2
Battery Holder, AAA x 2
×1
AAA Battery
×2
Perf+ 2
Crowd Supply Perf+ 2
×1
2N2222A transistor
×1
Adafruit UNL2003 Driver
×1

Software apps and online services

Atmosphere IoT
Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Hot glue gun (generic)
Hot glue gun (generic)

Story

Read more

Schematics

ASL reflector

Hacked Sch for extra GPIO

Code

Stepper_Servo_Mirror

C/C++
Controls reflector mirror with 1 stepper and 1 servo motors
#include <Servo.h>

Servo servo;
int servo_position = 0;
int servo_direction = 0;
int stepper_position = 50; // stepper motor center pos
int torque = 15; // higher torque will cause slow operation


void setup() 
{
DDRB = DDRB|B00001111; // set arduino D8, D9, D10, D11 as Output for stepper control
PORTB =PORTB&B11110000 ; // set logic LOW on D8, D9, D10, D11 
servo.attach(5); // 50 Hz servo control signal
}

void loop() 
{
  // reads RSL10's GIO pin and adjust mirror to improve lux level
  if (analogRead(A0) >500) 
  {
   sweep_stepper();
   sweep_servo();
  }
 

}

/////////////////////////////////////////////////////
/////////////////////////////////////////////////////

void sweep_stepper(void)
{

  // move stepper motor from left to right 50 steps
  if(stepper_position>50 && stepper_position<=101 )
  {
    stepper_position++;
    // rotate motor ccw
    for (int b=0; b<4;b++)
    {
      PORTB =PORTB&B11110000; // D8,D9,D10,D11 are set LOW to de-energize stepper coils
      PORTB =PORTB|(1<<b);    // set D8/D9/D10/D11 HIGH sequencially one at a time
      delay(torque);          // hold power on stepper motor's coils
    } 
    // check right end limit
    if(stepper_position==101)
    {
       stepper_position=50;
    }
    
  }

  // move stepper motor from right to left 50 steps
  if(stepper_position>=0 && stepper_position<=50 )
  {
        stepper_position--;
     // rotate motor cw
      for (int b=3; b>=0;b--)
    {
      PORTB =PORTB&B11110000;  // D8,D9,D10,D11 are set LOW to de-energize stepper coils
      PORTB =PORTB|(1<<b);     // set D11/D10/D9/D8 HIGH sequencially, one at a time
      delay(torque);           // hold power on stepper motor's coils
    }
    // check left end limit
    if(stepper_position==0)
    {
      stepper_position=51;
    }
  } 
}

////////////////////////////////////////////////////
////////////////////////////////////////////////////
void sweep_servo(void)

{
  if (stepper_position == 51) // check's one full sweep of stepper motor before enabling servo
  {
  if (servo_position<=180 && servo_direction == 0)  // servo cw movement
    {
    servo.write(servo_position);              
    delay(15);  
    servo_position += 10;                     
    }
    else
    {
      servo_direction = 1; // flip servo direction to ccw
    }

    if (servo_position>=0 && servo_direction == 1) // servo ccw movement
    {
    servo.write(servo_position);              
    delay(15);  
    servo_position -= 10;                     
    }
    else
    {
      servo_direction = 0; // flip servo direction ot cw
    }

  }
   
}

///////////////////////////////////////////////////
//////////////////////////////////////////////////

RSL10 BLE Lighting Sunlight Harvesting with NOA1305.zip

C/C++
Download, Unzip then import to Atmosphere Studio online IDE at
http://platform.atmosphereiot.com/
No preview (download only).

Credits

Shahariar

Shahariar

74 projects • 266 followers
"What Kills a 'Great life' is a 'Good Life', which is Living a Life Inside While Loop"

Comments