Step motor not working! ESP8266, Curtain Project

I can get the step motor to work, but when I change the stepsPerRevolution to a higher amount, the motor just vibrates, dosen’t turn. Any ideas?

// Libraries
#include <PubSubClient.h>
#include <ESP8266WiFi.h>
#include <Stepper.h>

#define wifi_ssid “”
#define wifi_password “”

#define mqtt_server “192.168.1.8”
#define mqtt_user “”
#define mqtt_password “”
#define ptopic “/home”
#define ppayload “.=yes”
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
WiFiClient espClient;
PubSubClient client(espClient);
const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
int status_testing = 0;
Stepper myStepper(stepsPerRevolution, D5, D6, D7, D8);
char message_buff[100];

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

void setup() {
// set the speed at 60 rpm:
myStepper.setSpeed(60);
// initialize the serial port:
Serial.begin(9600);
setup_wifi();
client.setServer(mqtt_server, 1883);
client.setCallback(callback);
client.subscribe("/hello");

}

// Closes curtains full amount
void closeCurtainsFull() {
// step one revolution in one direction:
Serial.println(“clockwise”);
myStepper.step(stepsPerRevolution);

}

// Opens curtains full amount
void openCurtainsFull(){
Serial.println(“counterclockwise”);
myStepper.step(-stepsPerRevolution);

}

void callback(char* topic, byte* payload, unsigned int length) {
Serial.print(“Message arrived [”);
Serial.print(topic);
Serial.print("] “);
int i=0;
for (i=0;i<length;i++) {
Serial.print((char)payload*);*
message_buff = payload*;*
* }*
* String msgString = String(message_buff);
_ if (msgString.equals(“OFF”)) {
client.publish(”/home/ok",“acknowedging OFF”);
closeCurtainsFull();
}
else if(msgString.equals(“ON”)){
client.publish("/home/ok",“acknowedging ON”);
openCurtainsFull();
}
Serial.println();
}
void setup_wifi() {
delay(10);
// We start by connecting to a WiFi network*
* Serial.println();
Serial.print(“Connecting to “);_
Serial.println(wifi_ssid);
WiFi.begin(wifi_ssid, wifi_password);
while (WiFi.status() != WL_CONNECTED) {
_ delay(500);
Serial.print(”.”);
}
Serial.println("");
Serial.println(“WiFi connected”);
Serial.println(“IP address: “);
Serial.println(WiFi.localIP());
}
//Recounted*
void reconnect() {
* // Loop until we’re reconnected*
* while (!client.connected()) {
Serial.print(“Attempting MQTT connection…”);
// Attempt to connect*
* if (client.connect(“arduinoClient”)) {
Serial.println(“connected”);
// Once connected, publish an announcement…
client.publish(“openhab”,“himitsu sensor, reporting in”);
// … and resubscribe*
* client.subscribe(“openhab/himitsu/command”);
} else {
Serial.print(“failed, rc=”);
Serial.print(client.state());
Serial.println(” try again in 5 seconds”);
// Wait 5 seconds before retrying*
* delay(5000);
}
}
}*_

void loop(){
if (!client.connected()) {
* reconnect();*
* }*
* client.loop();*
}

Please use code tags (</> button on the toolbar) when you post code or warning/error messages. The reason is that the forum software can interpret parts of your code as markup (for example, the italics in your code above), leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier to read your code and to copy it to the IDE or editor. If your browser doesn’t show the posting toolbar then you can just manually add the code tags:
[code]``[color=blue]// your code is here[/color]``[/code]
Using code tags and other important information is explained in the How to use this forum post. Please read it.

joeltetava:
I can get the step motor to work, but when I change the stepsPerRevolution to a higher amount, the motor just vibrates

What is the value of stepsPerRevolution when it works?

What is the value of stepsPerRevolution when it doesn’t work?

joeltetava:
I can get the step motor to work, but when I change the stepsPerRevolution to a higher amount, the motor just vibrates, dosen't turn. Any ideas?

How many steps per revolution are there on your motor?

These links may help

Stepper Motor Basics
Simple Stepper Code

also look up the AccelStepper library - it is much better than the standard Stepper library.

...R

Why are you using a stepper motor for curtains? Do you need to control how wide they are opened with an accuracy of a millimeter? I think you chose the wrong type of motor. A DC motor with a gearbox and some limit switches would be more appropriate.

pert:
What is the value of stepsPerRevolution when it works?

What is the value of stepsPerRevolution when it doesn't work?

200 Steps working, 400 not.

"D5, D6, D7, D8"
Stepper drivers only need AFAIK two pins, for step and direction.
So are you using an L293D or L298 brushed DC motor driver to drive a stepper motor?
Leo..

joeltetava:
200 Steps working, 400 not.

Which is correct for the motor you are using?

Post a link to the motor's datasheet.

Perhaps you are storing the number of steps in a byte variable (which has a max value of 255) and if so you should use an int.

...R

Wawa:
“D5, D6, D7, D8”
Stepper drivers only need AFAIK two pins, for step and direction.
So are you using an L293D or L298 brushed DC motor driver to drive a stepper motor?
Leo…

Some basic stepper motor drives have 4 pins. They are just a uln2003. The mcu must activate the motor coils in the correct sequence to make control the speed & direction.