Solar tracker with Nema17 stepper motor and two photoresistors

Trying to tinker with a solar panel + 2 photoresistors on the sides.
The idea is for two photoresistors to get the readings and rotate to the side which has higher value.

The issue I observe is, that when there is a stepper motor, the analog readings of the photoresistors are rather low (in Serial Monitor those are 17 and 19), as opposed to 700-800 when I don't have the stepper motor and if condition in the code.

// Include the Stepper library:
#include <Stepper.h>

// Define number of steps per revolution:
const int stepsPerRevolution = 160;    // Change to your specific stepper motor count per revolution

// Initialize the stepper library on pins 8 through 11:
Stepper myStepper = Stepper(stepsPerRevolution, 8, 9, 10, 11);

#define LDRpinL A0
#define LDRpinR A1

int LDRValueL = 0;
int LDRValueR = 0;

void setup() {
  // Set the motor speed (RPMs):
  myStepper.setSpeed(60); // Change to your specific stepper motor count per revolution
  Serial.begin(9600);
}

void loop() {
  LDRValueL = analogRead(LDRpinL);
  Serial.println(LDRValueL);
  
  LDRValueR = analogRead(LDRpinR);
  Serial.println(LDRValueR);
  
 
if (LDRValueL > LDRValueR) {
      myStepper.step(20);           // put - if opposite direction
      delay(50);
    }

  else if (LDRValueL < LDRValueR) {     // remove - if opposite direction
      myStepper.step(-20); 
      delay(50);
    }

  else {
    // we want a case with do nothing
     
  }  

Arduino Uno R3 (original, but not from Italy)
Stepper motor Nema17
Driver - L298D
PSU - 12V 1A adapter



Hi, @infatum99
Welcome to the forum.

You need to have your LDRs together side by side and a divider between them, this will cast a shadow over either of the LDRs when they are out of alignment.

Can you please post a circuit diagram?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.

Tom.. :smiley: :+1: :coffee: :australia:

Hi,
Can you please post link to your stepper?
Can you please post link to your stepper driver?

What are you using as a power supply?
Do you have a DMM? Digital MultiMeter?

Tom.. :smiley: :+1: :coffee: :australia:

Arduino Uno R3 (original, but not from Italy)
Stepper motor Nema17
Driver - L298D
PSU - 12V 1A adapter

Hello infatum99

Welcome to the worldbest Arduino forum ever.

Have you thought about using a local clock to control the solar panel?

Hi,
Is this your stepper?

Is this your stepper driver?

L298 Driver Module Features & Specifications:

  • Driver Model: L298N 2A
  • Driver Chip: Double H Bridge L298N
  • Motor Supply Voltage (Maximum): 46V
  • Motor Supply Current (Maximum): 2A
  • Logic Voltage: 5V
  • Driver Voltage: 5-35V
  • Driver Current:2A
  • Logical Current: 0-36mA
  • Maximum Power (W): 25W
  • Current Sense for each motor
  • Heatsink for better performance
  • Power-On LED indicator

Please a circuit diagram.

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

  1. Yes! That is the stepper and the driver.

  2. Circuit diagram. Software I used is called Fritzing. The circuit diagram has 220 Ohm resistor, but in reality it is 100 Ohms. There was no 100 Ohm element. Quick search gave me other nominal resistance resistors. So I used whatever closest was there.

Also, I use 12V 1A for power, but Fritzing has no such element. So, I just placed a 9V battery.

Jumper wires on L293D driver are in present as well.

That's interesting idea. Never thought of that. Using RTC module. That would require adjusting for local time and having a wireless module if there are daylight changes.

The sun don´t know daylight changes.

2 Likes

I'm tempted to get on my [soapbox] lol...

Tom.. :smiley: :+1: :coffee: :australia:

A post was split to a new topic: L298N driver heats up very much

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.