My first Blynk sketch. Patience ready only :)

Paste your formatted sketch.
Maybe you are pushing the baud rate too high. You have to crawl at 9600 with shields rather than 115200 for real ESP8266 connections.

1 Like

Then will try to flash it with lower baudrate. Thank you for assistance. Will try tomorrow.

Anybody knows most stable AT firmware? In one bin file?

This is the one mentioned in the docs - http://help.blynk.cc/how-to-connect-different-hardware-with-blynk/arduino/esp8266-with-at-firmware

http://www.electrodragon.com/w/File:At_firmware_bin1.54.zip

1 Like

There 2 files, one of them AiThinker_ESP8266_DIO_8M_8M_V1.5.4.bin
Its about 1mb, but what means 8m?

Flashed that firmware. Now I getting from Arduino serial - “failed to disable echo”. Esp8266 in serial giving me: “ai thinker. Ready”. Guess problem is in Blynk? I found some topic with same problem, but it a bit old though… [SOLVED] “Failed to disable echo” PROBLEM

Guess again :slight_smile:

Maybe that firmware in documentation is not correct version for Blynk?

Maybe you are not setting the baud with the correct AT commands as per the docs.

Maybe you re not setting the correct baud rates in your sketch.

As per the docs (my translation), you have to be mad to try ESP shield connection method when plug and play method is so much easier.

Speaking of OLD… sounds like your library is also OLD… Your screenshot shows v0.4.8 but that version got rid of the “Cannot disable echo” for a more understandable “ESP is not responding”.

So it sounds like you may have some corruption in your Blynk libraries?? Perhaps remove all of them and reinstall from the source.

1 Like

Working now all fine. Was some problem with flasher software. I change it, now it’s all fine. At 9600 working without timeout. Just at the moment don’t have much time. Will continue threat later.

Looks like got some time now.
Here what I done so far -

#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <Stepper.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "b0d68bxxxxxxxxxb2d02a7185";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Prxxxxx3";
char pass[] = "ghxxxxxx0";

// or Software Serial on Uno, Nano...
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3); // RX, TX

// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600

ESP8266 wifi(&EspSerial);

const int stepsPerRevolution = 500;
int state = 5;
Stepper rightStepper(stepsPerRevolution, 8,10,9,11);
Stepper leftStepper(stepsPerRevolution, 4,6,5,7);

void setup()
{
  // Debug console
  Serial.begin(9600);

  delay(10);

  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  delay(10);

  Blynk.begin(auth, wifi, ssid, pass);

   rightStepper.setSpeed(60);
  leftStepper.setSpeed(60);

  //move forward
  if (state == 1) {
    rightStepper.step(1);
    leftStepper.step(-1);    
  }
  //move backward
  if (state == 2) {
    rightStepper.step(-1);
    leftStepper.step(1);    
  }
  //move right
  if (state == 3) {
    rightStepper.step(1);
    leftStepper.step(1);    
  }
  //move left
  if (state == 4) {
    rightStepper.step(-1);
    leftStepper.step(-1);    
  }
  //do nothing
  if (state == 5) {
    rightStepper.step(0);
    leftStepper.step(0);
  }
}
BLYNK_WRITE(V0) {
  if (param.asInt() == 1) {
   state = 1; // forward
  } else {
    state = 5; // stop
  }
}
BLYNK_WRITE(V1) {
  if (param.asInt() == 1) {
   state = 2; // backward
  } else {
    state = 5; // stop
  }
}
BLYNK_WRITE(V3) {
  if (param.asInt() == 1) {
   state = 3; // right
  } else {
    state = 5; // stop
  }
}
BLYNK_WRITE(V2) {
  if (param.asInt() == 1) {
   state = 4; // forward
  } else {
    state = 5; // stop
  }
}

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

Looks like your “controls” are in setup(), that will not work as they are one time functions.

Either put them into each of the relevant BLYNK_WRITE() functions or create one function with all the controls and call the function from the BLYNK_WRITE()'s along with the state variable.

Like that? -
P.S. I added some terminal widget… But not getting Blynk version, as in setup() - why?

#define BLYNK_PRINT Serial

#include <Stepper.h>
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "b0d68xxxxxxxxxbbc973bb2d02a7185";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Prxxxxx3";
char pass[] = "ghxxxxxx00";

// or Software Serial on Uno, Nano...
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3); // RX, TX

// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600

ESP8266 wifi(&EspSerial);

const int stepsPerRevolution = 2048;
Stepper rightStepper(stepsPerRevolution, 8,10,9,11);
Stepper leftStepper(stepsPerRevolution, 4,6,5,7);
int state = 5;

WidgetTerminal terminal(V5);

BLYNK_WRITE(V5)
{
  if (String("echo") == param.asStr()) {
    terminal.println("echo OK") ;
  } else {
    terminal.println("FAIL") ;}
  }

void setup()
{
  // Debug console
  Serial.begin(9600);

  delay(10);

  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  delay(10);

  rightStepper.setSpeed(18);
  leftStepper.setSpeed(18);

  Blynk.begin(auth, wifi, ssid, pass);
  
terminal.println(F("Blynk v" BLYNK_VERSION ": Device started"));
 
}
BLYNK_WRITE(V0) {
  if (param.asInt() == 1) {
   state = 1; // forward
  } else {
    state = 5; // stop
  }
 Control();
}
BLYNK_WRITE(V1) {
  if (param.asInt() == 1) {
   state = 2; // backward
  } else {
    state = 5; // stop
  }
  Control();
}
BLYNK_WRITE(V3) {
  if (param.asInt() == 1) {
   state = 3; // right
  } else {
    state = 5; // stop
  }
  Control();
}
BLYNK_WRITE(V2) {
  if (param.asInt() == 1) {
   state = 4; // left
  } else {
    state = 5; // stop
  }
  Control();
}

void Control() {
  //move forward
  if (state == 1) {
    rightStepper.step(1);
    leftStepper.step(-1);    
  }
  //move backward
  if (state == 2) {
    rightStepper.step(-1);
    leftStepper.step(1);    
  }
  //move right
  if (state == 3) {
    rightStepper.step(1);
    leftStepper.step(1);    
  }
  //move left
  if (state == 4) {
    rightStepper.step(-1);
    leftStepper.step(-1);    
  }
  //do nothing
  if (state == 5) {
    rightStepper.step(0);
    leftStepper.step(0);
  }
}
void loop()
{
  Blynk.run();
}

Now stepper motor driver changing states, but not rotating wheel… well, it rotating but about 100th part of whole wheel rotation to 180 degrees. Whats wrong there? I have uln2003 drivers and 28byj-48 motors.

You could put the commands in a for loop to step more than the current 100th.

Not really understand what you mean. Can you please post example?
You mean loop some string? How I can do that?
Much thanks.

if (state == 1) {
    for( int i = 0; i < 10; i++){
      rightStepper.step(1);
      leftStepper.step(-1);   
    } 
  }

Same process for each Control. I don’t know how long the current step takes but it will be trial and error with the value 10. Start low and then if you need a bigger step try 20, 40 etc.
If the step starts to take too long you might need a Blynk.run() right at the start of the function but try it without first.

There is no loop… Heard to many times :slight_smile:
Will try tomorrow. Thanks.

It’s working. But motors sometime acting strange. Think it’s because they cheap maybe. Anyway I have another question. When steps in progress how I can immediately interrupt it? It’s not listening any commands till it not finish current steps.