Wemos D1 R2 & mini blinkcloud timeout

I am trying to convert a blynk code from Bluetooth to Wemos D1 r2 & mini (wifi)
I believe everything should be working, no errors when uploading and in the serial monitor, upon startup it connects to the internet all fine. but after load up it keeps looping this phrase:
[506987] Connecting to blynk-cloud.com:80 [509048] Login timeout
Wifi scetch-

/*************************************************************
  Download latest Blynk library here:
    https://github.com/blynkkk/blynk-library/releases/latest

  Blynk is a platform with iOS and Android apps to control
  Arduino, Raspberry Pi and the likes over the Internet.
  You can easily build graphic interfaces for all your
  projects by simply dragging and dropping widgets.

    Downloads, docs, tutorials: http://www.blynk.cc
    Sketch generator:           http://examples.blynk.cc
    Blynk community:            http://community.blynk.cc
    Follow us:                  http://www.fb.com/blynkapp
                                http://twitter.com/blynk_app

  Blynk library is licensed under MIT license
  This example code is in public domain.

 *************************************************************

  You can receive x and y coords for joystick movement within App.

  App project setup:
    Two Axis Joystick on V1 in MERGE output mode.
    MERGE mode means device will receive both x and y within 1 message
 *************************************************************/

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

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

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "K-9 Wifi";
char pass[] = "Buster27";
 int x,y;
BLYNK_WRITE(V1) {
  int x = param[0].asInt();
  int y = param[1].asInt();

  // Do something with x and y
  Serial.print("X = ");
  Serial.print(x);
  Serial.print("; Y = ");
  Serial.println(y);
}
float LMotor_offset,RMotor_offset;
float Turn_Speed = 0, Turn_Speed_K = 0;
float Run_Speed = 0, Run_Speed_K = 0, Run_Speed_T = 0;
float LOutput=0;float ROutput=0;
//Variable en la que se va a almacenar el valor correspondiente a la distancia
int Dist,Dist1,Dist2;
// APP DEL MVIL
int MARCHA;
int INA=7;
int INB=8;
int ENA=5;

int INC=12;
int IND=4;
int ENB=9;

void setup()
{

  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);


  pinMode(INA,OUTPUT);
  pinMode(INB,OUTPUT);
  pinMode(INC,OUTPUT);
  pinMode(IND,OUTPUT);

  x=0;
  y=0;
  LOutput=0;
  ROutput=0;

}

void loop()
{
  Blynk.run(); // To Run Blynk
  XY_TO_RUN_TURN_SPEEDS(); //X of the Joystick represent the turn speed and Y the RUN speed
  PWMControl();// It controls the logic for the Motors H bridge
}

void XY_TO_RUN_TURN_SPEEDS(){
if(x!=128){
    Turn_Speed=map(x,0,255,160,-160);
}else{
  Turn_Speed=0;
}
if(y!=128){
  Run_Speed=map(y,0,255,-300,300);
}else{
  Run_Speed=0;
}
  LOutput = Run_Speed + Turn_Speed;
  ROutput = Run_Speed - Turn_Speed;  
  LOutput= -LOutput;
  }

  void PWMControl(){
  if(LOutput > 0){
    digitalWrite(INA, HIGH);
    digitalWrite(INB, HIGH);
  }
  else if(LOutput < 0){
    digitalWrite(INA, LOW);
    digitalWrite(INB, LOW);
  }
  else{
    digitalWrite(INA, HIGH);
    digitalWrite(INB, HIGH);
  }
  if(ROutput > 0){
    digitalWrite(INC, HIGH);
    digitalWrite(IND, HIGH);
  }
  else if(ROutput < 0){   
    digitalWrite(INC, LOW);
    digitalWrite(IND, LOW);
  }
  else{
    digitalWrite(INC, HIGH);
    digitalWrite(IND, HIGH);
  }

       
      
      
    }

I can post the original Bluetooth code if someone wants me to.
any help is appreciated :slight_smile:

Any reason this is smack in the middle of your pre-setup?

And these should not be in the void loop… as they are trying to run thousands of times a second. (And no, don’t bother with the “it worked on BT” :wink: as now you are dealing with a WiFi & server link).

Recommend using timers to call them instead.

i believe I have made the changes you said

  Download latest Blynk library here:
    https://github.com/blynkkk/blynk-library/releases/latest

  Blynk is a platform with iOS and Android apps to control
  Arduino, Raspberry Pi and the likes over the Internet.
  You can easily build graphic interfaces for all your
  projects by simply dragging and dropping widgets.

    Downloads, docs, tutorials: http://www.blynk.cc
    Sketch generator:           http://examples.blynk.cc
    Blynk community:            http://community.blynk.cc
    Follow us:                  http://www.fb.com/blynkapp
                                http://twitter.com/blynk_app

  Blynk library is licensed under MIT license
  This example code is in public domain.

 *************************************************************

  You can receive x and y coords for joystick movement within App.

  App project setup:
    Two Axis Joystick on V1 in MERGE output mode.
    MERGE mode means device will receive both x and y within 1 message
 *************************************************************/

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

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

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "K-9 Wifi";
char pass[] = "Buster27";
 int x,y;

float LMotor_offset,RMotor_offset;
float Turn_Speed = 0, Turn_Speed_K = 0;
float Run_Speed = 0, Run_Speed_K = 0, Run_Speed_T = 0;
float LOutput=0;float ROutput=0;
//Variable en la que se va a almacenar el valor correspondiente a la distancia
int Dist,Dist1,Dist2;
// APP DEL MVIL
int MARCHA;
int INA=7;
int INB=8;
int ENA=5;

int INC=12;
int IND=4;
int ENB=9;


#include <SimpleTimer.h>
SimpleTimer timer;         // creates a set of timers

// A timer call-back function - there can be more than one
void onTimer(void){  XY_TO_RUN_TURN_SPEEDS(); //X of the Joystick represent the turn speed and Y the RUN speed
  PWMControl();// It controls the logic for the Motors H bridge
}

void setup()
{

    Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
 timer.setInterval(1000L, onTimer); // set a 1-sec repeating timer

  pinMode(INA,OUTPUT);
  pinMode(INB,OUTPUT);
  pinMode(INC,OUTPUT);
  pinMode(IND,OUTPUT);

  x=0;
  y=0;
  LOutput=0;
  ROutput=0;

}

BLYNK_WRITE(V1) {
  int x = param[0].asInt();
  int y = param[1].asInt();

  // Do something with x and y
  Serial.print("X = ");
  Serial.print(x);
  Serial.print("; Y = ");
  Serial.println(y);
}

void loop()
{
  Blynk.run(); // To Run Blynk
}

void XY_TO_RUN_TURN_SPEEDS(){
if(x!=128){
    Turn_Speed=map(x,0,255,160,-160);
}else{
  Turn_Speed=0;
}
if(y!=128){
  Run_Speed=map(y,0,255,-300,300);
}else{
  Run_Speed=0;
}
  LOutput = Run_Speed + Turn_Speed;
  ROutput = Run_Speed - Turn_Speed;  
  LOutput= -LOutput;
  }

  void PWMControl(){
  if(LOutput > 0){
    digitalWrite(INA, HIGH);
    digitalWrite(INB, HIGH);
  }
  else if(LOutput < 0){
    digitalWrite(INA, LOW);
    digitalWrite(INB, LOW);
  }
  else{
    digitalWrite(INA, HIGH);
    digitalWrite(INB, HIGH);
  }
  if(ROutput > 0){
    digitalWrite(INC, HIGH);
    digitalWrite(IND, HIGH);
  }
  else if(ROutput < 0){   
    digitalWrite(INC, LOW);
    digitalWrite(IND, LOW);
  }
  else{
    digitalWrite(INC, HIGH);
    digitalWrite(IND, HIGH);
  }

       
      
      
    }
   


//Este mdulo calcula y devuelve la distancia en cm.
/*
Puedes poner el cdigo del mdulo directamente en el loop o utilizar el mdulo
para reducir el nmero de lneas de cdigo del loop o reutilizar el cdigo
*/

but its still giving me the blynk cloud timeout

Well, you are missing timer.run(); so your timed function isn’t even running :stuck_out_tongue_winking_eye: so there must be something else in your code causing a long enough delay to disconnect… at least I am guessing that is what is happening.

EDIT - nope… looks like you are not even connecting…

I suggest you play around with a simpler example on the Wemos D1, so as to get a better understanding of how it should work… including timers…

I have been able to have it running with just the x,y joystick where it connected and gave the x,y reading on serial monitor just fine. im not sure why it starts to time out when i add the rest

Edit- seems like it starts to timeout when i add

  pinMode(INA,OUTPUT);
  pinMode(INB,OUTPUT);
  pinMode(INC,OUTPUT);
  pinMode(IND,OUTPUT);

I see… the Wemos D1 doesn’t have some of these pins… (use the Arduino ones in BLUE)

And some of the pins have special purposes so you need to be careful which ones to use.

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266_SSL.h>


char auth[] = "746fe62d67dd4dbb90544671ccf54143";
char ssid[] = "K-9 Wifi";
char pass[] = "Buster27";

int x,y;
float LMotor_offset,RMotor_offset;
float Turn_Speed = 0, Turn_Speed_K = 0;
float Run_Speed = 0, Run_Speed_K = 0, Run_Speed_T = 0;
float LOutput=0;
float ROutput=0;
int Dist,Dist1,Dist2;
int MARCHA;
int INA=4;
int INB=3;
int ENA=5;

int INC=6;
int IND=7;
int ENB=2;

BLYNK_WRITE(V1) {
  int x = param[0].asInt();
  int y = param[1].asInt();

  // Do something with x and y
  Serial.print("X = ");
  Serial.print(x);
  Serial.print("; Y = ");
  Serial.println(y);
}

void setup()
{

  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);

  pinMode(INA,OUTPUT);
  pinMode(INB,OUTPUT);
  pinMode(INC,OUTPUT);
  pinMode(IND,OUTPUT);
}

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

void XY_TO_RUN_TURN_SPEEDS(){
if(x!=128){
    Turn_Speed=map(x,0,255,160,-160);
}else{
  Turn_Speed=0;
}
if(y!=128){
  Run_Speed=map(y,0,255,-300,300);
}else{
  Run_Speed=0;
}
  LOutput = Run_Speed + Turn_Speed;
  ROutput = Run_Speed - Turn_Speed;  
  LOutput= -LOutput;
  }

  void PWMControl(){
  if(LOutput > 0){
    digitalWrite(INA, HIGH);
    digitalWrite(INB, HIGH);
  }
  else if(LOutput < 0){
    digitalWrite(INA, LOW);
    digitalWrite(INB, LOW);
  }
  else{
    digitalWrite(INA, HIGH);
    digitalWrite(INB, HIGH);
  }
  if(ROutput > 0){
    digitalWrite(INC, HIGH);
    digitalWrite(IND, HIGH);
  }
  else if(ROutput < 0){   
    digitalWrite(INC, LOW);
    digitalWrite(IND, LOW);
  }
  else{
    digitalWrite(INC, HIGH);
    digitalWrite(IND, HIGH);
  } 
    }

ive changed the pins, but its still not acting correctly

serial monitor’s output:

[6856] Connecting to K-9 Wifi
[14199] Connected to WiFi
[14199] IP: 192.168.0.102
[14199] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.5.0 on Arduino

[14288] Got time: Thu Jan  1 08:00:07 1970

[14319] Connecting to blynk-cloud.com:8441
[17259] Certificate OK
[17569] Ready (ping: 307ms).
?)⸮⸮

at the point it says

?)⸮⸮

it disconnects from my phone

As stated in last post

Pin 3 is Serial RX

Pin 6 & 7 don’t exist (for coding purpose)

Are there 6 pins that are actually useable?

Look up… way up… to my post with the charts… that is what you have to work with.

On the Motor Controller, I usually jumper the Enable pins or wire them in parallel for a single digital pin.

on your tracked rover code, the Wemos doesn’t seem to get past

Blynk.begin(auth, ssid, pass, "10.10.3.13", 8442);

in the setup

Don’t just copy/paste and expect code in older posts to work… there is always something changing in the Blynk world :wink:

Besides… that is MY Local Server internal IP, so not going to do you any good :stuck_out_tongue:

PS… in one of your last code posts, I see you are using SSL…

Don’t… the ESP8266 is not quite fast enough from what I understand and that will just add to connection instability.