Sorry I did not know how to send the data from the serial monitor and the mobile screen so that I could see that the connection remains active despite using “delay”. I repeat the connection is active throughout the time delay is ignored like the rest of the code that I wrote.
I have tried to remove delay and my problem remains the same.
the outputs at the beginning of the program are set to high level and not low level
I am setting the code correctly or do I have a fault in how I am doing it?
Select the lines of serial monitor output using your mouse or CTRL-A then copy using CTRL-C.
Paste into the forum as normal, with triple backticks at the beginning and end.
Attach a screenshot of your app project in Stopped mode, so that it shows which pins the widgets are connected to, along with your serial output.
When you put #define BLYNK_PRINT Serial at the start of your code, then initialise your serial output using Serial.begin(baud rate) it will print details of the IP address allocation, Blynk connection and re-connection process, ping time and any disconnects and reconnects that occur. As in the screenshot you provided with the other code.
If you aren’t seeing this, and assuming that you have the serial monitor set to the correct baud rate that you defined in your sketch, then you have a problem that is greater than simply your custom code not being executed.
Try moving your Serial.begin command to the top of your void loop and adding a line after it that prints a simple message.
With this I get something on the serial monitor. but quickly disconnects from the app, but I do not see the disconnection reflected.
I suppose the disconnection occurs because the void loop must remain clean.
Do you know what my problem may be?
Where is this message coming from? It doesn’t look like a Blynk message, but there are no serial prints in the code you’ve posted that would create this.
Are you running different code to what you’ve previously shared?
I understood that I would add a line of code after serial.begin () to print a simple message and I did. I added the flashing lights message.
because if I only change the serial.begin () to the void loop I still receive nothing. I have tried to put it in several ways and I still do not receive anything.
I am sorry to tell you that this code as it is does not send any data. remove delays so they don’t cause problems.
would not have to add something else for data to be sent?
#define BLYNK_PRINT Serial
#define Abrir 2 // Nombre para el led en el pin 2
#define Cerrar 3 // Nombre para el led en el pin 3
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
// Deberías obtener el token de autenticación en la aplicación Blynk.
// Ir a la configuración del proyecto (icono de tuerca).
char auth[] = "token";
#define W5100_CS 10
#define SDCARD_CS 4
// Esta función se llamará cada vez que deslice el widget
// en la aplicación Blynk escribe valores en el Pin virtual V1
BLYNK_WRITE(V1)
{
int pinValue = param.asInt(); // asignar valor entrante del pin V1 a una variable
// procesar el valor recibido
if (pinValue == 1)
{
digitalWrite (Abrir , HIGH);// el widget de interruptor abrir está activado durante el tiempo indicado
}
else
{
digitalWrite (Abrir, LOW); // el widget de interruptor abrir está apagado
}
}
BLYNK_WRITE(V2)
{
int pinValue = param.asInt(); // asignar valor entrante del pin V1 a una variable
// procesar el valor recibido
if (pinValue == 1)
{
digitalWrite (Cerrar, HIGH);// el widget de interruptor cerrar está activado durante el tiempo indicado
}
else
{
digitalWrite (Cerrar, LOW); // // el widget de interruptor abrir está activado
}
}
void setup()
{
pinMode (Abrir, OUTPUT);
pinMode (Cerrar, OUTPUT);
// ahora es Estado inicial (todas apagadas)
digitalWrite (Abrir,LOW); // (para que la salida 2 este apagada)
digitalWrite (Cerrar,LOW); // (para que la salida 3 este apagada)
// Consola de depuración
pinMode(SDCARD_CS, OUTPUT);
digitalWrite(SDCARD_CS, HIGH); //Anule la selección de la tarjeta SD
Blynk.begin(auth);
// También puedes especificar el servidor:
//Blynk.begin(auth, "blynk-cloud.com", 80);
//Blynk.begin(auth, IPAddress (192,168,1,100), 8080);
}
void loop()
{
Serial.begin(9600);
Blynk.run();
}
`` `
should be the first line of your void setup, not void loop.
It would also help if you added this as your second line of your void setup: Serial.println(“Serial port initialised”);
It seems that now the initial message is reproduced on the serial monitor but everything else still does not appear on the serial monitor, I activate the buttons from the App to activate the outputs but there is no result.
I think it is finally fixed and it works !!
I just realized that changing the code LOW for HIGH, and HIGH for LOW, now my relays work as desired and remain off when the program starts.
I don’t know very well why this happens, do you know why this happens?
My last question and I hope not to bother you in a long time, what should I do so that the output is activated for 40 seconds without using a delay so as not to cause problems with Blynk.run?
So the code remains after the changes of LOW for HIGH, and HIGH for LOW
#define BLYNK_PRINT Serial
#define Abrir 2 // Nombre para el led en el pin 2
#define Cerrar 3 // Nombre para el led en el pin 3
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
// Deberías obtener el token de autenticación en la aplicación Blynk.
// Ir a la configuración del proyecto (icono de tuerca).
char auth[] = "";
#define W5100_CS 10
#define SDCARD_CS 4
// Esta función se llamará cada vez que deslice el widget
// en la aplicación Blynk escribe valores en el Pin virtual V1
BLYNK_WRITE(V1)
{
int pinValue = param.asInt(); // asignar valor entrante del pin V1 a una variable
// procesar el valor recibido
if (pinValue == 1)
{
digitalWrite (Abrir , LOW);// el widget de interruptor abrir está activado durante el tiempo indicado
digitalWrite (Cerrar, HIGH);
}
else
{
digitalWrite (Abrir, HIGH); // el widget de interruptor abrir está apagado
}
}
BLYNK_WRITE(V2)
{
int pinValue = param.asInt(); // asignar valor entrante del pin V1 a una variable
// procesar el valor recibido
if (pinValue == 1)
{
digitalWrite (Cerrar, LOW);// el widget de interruptor cerrar está activado durante el tiempo indicado
digitalWrite (Abrir, HIGH);
}
else
{
digitalWrite (Cerrar, HIGH); // // el widget de interruptor abrir está activado
}
}
void setup()
{
// Consola de depuración
Serial.begin(9600);
Serial.println ("Puerto serie inicializado");
pinMode (Abrir, OUTPUT);
pinMode (Cerrar, OUTPUT);
// ahora es Estado inicial (todas apagadas)
digitalWrite (Abrir,HIGH); // (para que la salida 2 este apagada)
digitalWrite (Cerrar,HIGH); // (para que la salida 3 este apagada)
Serial.println ("Salidas Apagadas");
pinMode(SDCARD_CS, OUTPUT);
digitalWrite(SDCARD_CS, HIGH); //Anule la selección de la tarjeta SD
Blynk.begin(auth);
Serial.println ("iniciando blynk");
// También puedes especificar el servidor:
//Blynk.begin(auth, "blynk-cloud.com", 80);
//Blynk.begin(auth, IPAddress (192,168,1,100), 8080);
}
void loop()
{
Blynk.run();
}
`` `
Certainly I just reviewed all the relays that I have and they are active by low level, I would swear that when I tried it they were active by high level. my fault about the relays.
Very well I will look for information about the blynk timers in the forum. very grateful for your great help, thank you very much.