AccelStepper.h + Blynk Slider

Hi,

I want to control my thermostat with blynk so i compile the code below. If i increase step number, device disconnects. Im working on nodeMCU, esp8266-01.

I put my stepper codes in BLYNK_WRITE, now i attached time interrupt. Still not working properly. just working for around 250 steps.


#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
BlynkTimer timer;

#include "AccelStepper.h"
AccelStepper stepper(1, 0, 2);  

int previous = 0;
int long newval = 0;
int val;
char auth[] = "...........................";
char ssid[] = "yurdakul";
char pass[] = "Yurdakul2409.";

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  pinMode(3, OUTPUT);
  digitalWrite(3, HIGH);
  stepper.setMaxSpeed(350);
  stepper.setAcceleration(600);

    timer.setInterval(2000L, stp);
}

void loop()
{
  Blynk.run();
  timer.run();
}

BLYNK_WRITE(V0) {
  int value = param.asInt();
  val = value;
  
}

void stp () {
 
  if ((val > previous) || (val < previous)) {
    newval = map(val, 0, 80, 0, 220);
    digitalWrite(3, LOW);
    stepper.runToNewPosition(newval);
    digitalWrite(3, HIGH);
    previous = val;
  }
}

Because of the nature of stepper motor control, either a specialised controller that takes the load off the MCU (I am guessing they exist), or a Arduino <-- serial/I2c link – > Blynkified MCU option may be required.

https://community.blynk.cc/t/turning-old-arduinos-into-perfectly-usable-iot-devices/23456/2

1 Like

I will try and add results. Thank you.

I found something. I wanted to move stepper pretty slow so reduced setMaxSpeed. On this configuration, i faced problem that i mentioned before.

Now its runnung on esp8266 and nodeMCU. I set steep to 600 and acceleration to 500. Now i can run around 600 steps without problem.


P.S. I am configuring stepper and thermostat angle with map function, getting values from blynk slider. Maybe map function can be placed in slider widget. I want to show temperature on slider but send angle data.

Thanks…