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;
}
}