Bienvenido, Invitado
Nombre de Usuario: Contraseña: Recordarme
  • Página:
  • 1

TEMA:

ARDUINO DEJA DE RECIBIR DATOS DE NEXTION 5 años 3 semanas antes #130

Saludos, tengo un inconveniente con nextion y arduino. Estoy utilizando librería no oficial, cuando se prende la pantalla se comunica correctamente con nextion, pero al transcurso de unos 10 min arduino ya no recibe datos. Solo vuelve a funcionar cuando reinicio arduino o cuando lo apago todo.
#include <SoftwareSerial.h>
#include <Nextion.h>

SoftwareSerial nextion(2, 3);// Nextion TX to pin 2 and RX to pin 3 of ATMEGA328
Nextion myNextion(nextion, 9600); //create a Nextion object named myNextion using the nextion serial port @ 9600bps


//ENTRADAS Y SALIDAS 
#define EN 9 //ENABLE PWM
#define PA 5 //MOTOR
#define PB 6 //MOTOR
#define SENSOR_C1AR 7//PIN SENSOR 1 ARRIBA
#define SENSOR_C1AB 8//PIN SENSOR 2 ABAJO

int VAL_SENSOR_SENSOR_C1AR = 0;//varible para leer estado
int VAL_SENSOR_SENSOR_C1AB = 0;//variable para leer estado

int cuenta = 0;// PARA EVITAR ERRORES
//FIN IO

void setup()
{
	Serial.begin(9600);
  	myNextion.init();

  	pinMode(PA, OUTPUT);//MOTOR1 +-
	pinMode(PB, OUTPUT);//MOTOR1 +-
	pinMode(EN, OUTPUT);//ENABLE PWM
  	pinMode(SENSOR_C1AR,INPUT);
  	pinMode(SENSOR_C1AB,INPUT);
}

void loop()
{
	VAL_SENSOR_SENSOR_C1AR = digitalRead(SENSOR_C1AR);//LECTURA ESTADO SENSOR ARRIBA
 	VAL_SENSOR_SENSOR_C1AB = digitalRead(SENSOR_C1AB);//LECTURA ESTADO SENSOR ABAJO

 	int M1 = myNextion.getComponentValue("VESTIDOR_UNO.DATO");
 	int ARRIBA = myNextion.getComponentValue("VESTIDOR_UNO.ARR");
 	int ABAJO = myNextion.getComponentValue("VESTIDOR_UNO.ABA");
 		

 	if(M1 == 11){

 		estado_sensoresM1();
 		
 	
 		if(ARRIBA == 17){ arriba(); cuenta = 1;}
		if(VAL_SENSOR_SENSOR_C1AR == LOW && cuenta == 1){apagado();cuenta = 0;
			myNextion.setComponentValue("VESTIDOR_UNO.AR",1);
			myNextion.setComponentText("VESTIDOR_UNO.TEXTO","ARRIBA");
			myNextion.setComponentValue("VESTIDOR_UNO.AB",0);
		}

		if(ABAJO == 19){ abajo(); cuenta = 2;}
		if(VAL_SENSOR_SENSOR_C1AB == LOW && cuenta == 2){apagado();cuenta = 0;
			myNextion.setComponentValue("VESTIDOR_UNO.AB",1);
			myNextion.setComponentText("VESTIDOR_UNO.TEXTO","ABAJO");
			myNextion.setComponentValue("VESTIDOR_UNO.AR",0);
		}
	}else if(M1 == 10){apagado(); cuenta = 0;
		myNextion.setComponentValue("VESTIDOR_UNO.AR",0);
		myNextion.setComponentValue("VESTIDOR_UNO.AB",0);
		myNextion.setComponentText("VESTIDOR_UNO.TEXTO","");
		
		}


	
}

void estado_sensoresM1(){
	if(VAL_SENSOR_SENSOR_C1AR == LOW){myNextion.setComponentValue("VESTIDOR_UNO.AR",1);}
	else if(VAL_SENSOR_SENSOR_C1AR == HIGH){myNextion.setComponentValue("VESTIDOR_UNO.AR",0);}

	if(VAL_SENSOR_SENSOR_C1AB == LOW){myNextion.setComponentValue("VESTIDOR_UNO.AB",1);}
	else if(VAL_SENSOR_SENSOR_C1AB == HIGH){myNextion.setComponentValue("VESTIDOR_UNO.AB",0);}
}

void arriba(){
	analogWrite(EN, 180);
	digitalWrite(PA, HIGH);
	digitalWrite(PB, LOW);
}
void abajo(){
	analogWrite(EN, 50);
	digitalWrite(PA, LOW);
	digitalWrite(PB, HIGH);
}
void apagado(){digitalWrite(EN, LOW);digitalWrite(PA, LOW);digitalWrite(PB, LOW);}

Por favor, Identificarse para unirse a la conversación.

ARDUINO DEJA DE RECIBIR DATOS DE NEXTION 5 años 3 semanas antes #131

Entiendo el problema, pero mi consejo seria que en primer lugar nos explicaras que es el proyecto ( para no tener que deducirlo en el codigo ) y en segundo lugar publicar tambien el fichero de para la nextion.

Luego, has verificado si el arduino se cuelga y no envia nada por el puerto serial, o bien envia datos que no son interpretados correctamente por la Nextion ?

Por favor, Identificarse para unirse a la conversación.

  • Página:
  • 1
Tiempo de carga de la página: 0.084 segundos
Gracias a Foro Kunena

Login