BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

ESP8266 esp01 + arduino uno

esp8266
arduino
#21

What do you mean by it doesn’t work?

What are you calling in your first code that uses code from that header?
Because that header isn’t included in the second one that you tried and said that does work.

1 Like

#22

Sorry, it IS included on the second code, but I forgot to paste it in the message. Here is a sketch i could improve, that works perfectly.The problem is that if I use the comand Blynk.email, or if I put all the functions that I need (like the ones from the first code) it gets stuck on blynk.beging.
Here is the sketch that works.



#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[] = "7c454bcfd36340d7851fcebb1d2161d6";

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



// 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);


WidgetLCD lcd(V2);//asignación del pin virtual 2
SimpleTimer timer2;
int timerID;
int repeticiones;
String cadena;
int ej;
BLYNK_WRITE(V0)
{
  ej = param.asInt();//Lee el ejercicio escogido
  switch (param.asInt())
  {
    case 1://se elige el ejercicio 1
      Blynk.virtualWrite(V1, 1); //se cambia la imagen 1 en el widget de IMAGE GALERY
      repeticiones=30;
      cadena="";
      lcd.clear();
      lcd.print(0, 0, "Has elegido ejercicio 1");
      delay(2000);
      break;
    case 2://se elige el ejercicio 2
      Blynk.virtualWrite(V1, 2); //se cambia la imagen 2
      repeticiones=30;
      cadena="";
      lcd.clear();
      lcd.print(0, 0, "Has elegido ejercicio 2");
      delay(2000);
      break;
    case 3://se elige el ejercicio 3
      Blynk.virtualWrite(V1, 3); //se cambia la imagen 3
      repeticiones=30;
      cadena="";
      lcd.clear();
      lcd.print(0, 0, "Has elegido ejercicio 3");
      delay(2000);
      break;
    case 4://se elige el ejercicio 4
      Blynk.virtualWrite(V1, 4); //se cambia la imagen 4
      repeticiones=30;
      cadena="";
      lcd.clear(); 
      lcd.print(0, 0, "Has elegido ejercicio 4");
      delay(2000);
      break;
    case 5://se elige el ejercicio 5
      Blynk.virtualWrite(V1, 5); //se cambia la imagen 5
      repeticiones=30;
      cadena="";
      lcd.clear();
      lcd.print(0, 0, "Has elegido ejercicio 5");
      delay(2000);
      break;
    default:
      lcd.clear();
      lcd.print(0, 0, "no se elije nada");

  }

}

void leedatos()
{
  const int analogPin = A0;//variable que almacena el valor del potenciometro
 // bolaVal = digitalRead(2); //lee del interruptor bola
  int value = analogRead(A0);      // realizar la lectura analógica raw
  int position = round(map(value, 0, 1023, 0, 320));  // convertir a porcentaje el potencimetro
  Blynk.virtualWrite(V5, position);//escribe en la aplicacion en el widget SUPERCHART
}

BLYNK_WRITE(V3)
{
  if (param.asInt() == 1)//El boton en la aplicación está a 1
  {
    timer2.disable(timerID);//deshabilita el temporizador que llama a Leedatos
    lcd.clear();//Borra LCD
    lcd.print(0, 0, "has salido del ejercicio");//Imprime en LCD
    delay(3000);
  }
  else
  {
    timer2.enable(timerID);//habilita el temporizador que llama a leedatos
    lcd.clear();//borra de LCD
    lcd.print(0, 0, "empieza el ejercicio");//Imprime en LCD
    delay(3000);
  }

}




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

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

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

  Serial.println("Waiting for connections...");
  timerID= timer2.setInterval(500L, leedatos);//inicializacion del timer de leedatos cada 250ms
  Blynk.syncAll();//sincroniza la aplicacion blynk todos los pines virtuales

}

void loop()
{
  Blynk.run();
  timer2.run();
 // Serial.println("hello world");
  // You can inject your own code or combine it with other sketches.
  // Check other examples on how to communicate with Blynk. Remember
  // to avoid delay() function!
}
0 Likes

#23

Have you tried using BlynkTimer instead of SimpleTimer? - I’m pretty sure the BlynkTimer fixes some issues that SimpleTimer has.

Also without sounding rude - if you don’t post the exact code that works then we are never going to be able to help.

2 Likes

#24

Thanks for the ideas, i’ve just solved the issue. The problem was with de dynamic memory of the arduino uno. When the program reached 67% of the dynamic memory it stops working. I fixed it using an arduino mega 2560 instead of the arduino uno.
Thank you for all the replies!

1 Like