Activity › Forums › Questions & Troubleshooting › Software & Firmware › Serial overload- Sensor readout in conflict with Nextion display communication?
-
Serial overload- Sensor readout in conflict with Nextion display communication?
-
Hello an .ino file shall establish the communication between I2c sensors, Nextion display and a Controllino Maxi Automation.The Serial2 port is set at 115200 baud. Initially I am trying to readout a BME280 sensor and want to display the values on a Nextion enhanced display. Therefore I use void pressure_temperature_humidity(). Next to reading out the values I also want to let follow actions on touching buttons.
If pressure_temperature_humidity(); is commented out in the loop() the button touching is followed by correct actions(i.e.setting Digital outputs).
The serial monitor returns no recvRetNumber err for Nextion com. This is not the case if pressure_temperature_humidity();
is implemented. So I guess that the serial communication is overloaded and correct messaging is not possibly anymore. How can I prevent such overload. I already added a delay behind the bme readouts without success. Unfortunetaly I cannot attach the ino file.
Code:void pressure_temperature_humidity() {
float tempoffset = -3.0;
float temperatureC = bme.readTemperature() + tempoffset;
//delay(10);
Serial.print(“Temp =”); Serial.println(temperatureC);
/*
float pressureKPA = bme.readPressure();
//delay(10);
Serial.print(“Press. =”); Serial.println(pressureKPA);
float altitude = bme.readAltitude(SEALEVELPRESSURE_HPA);
//delay(10);
Serial.print(“Alt. =”); Serial.println(altitude);
float humidity = bme.readHumidity();
//delay(10);
Serial.print(“humidity =”); Serial.println(humidity);String pre_TXT = String(pressureKPA / 100.0, 0); //Will show no decimal place
memset(buffer, 0, sizeof(buffer));
pre_TXT.toCharArray(buffer, 10);
if (strcmp(buffer, buffer_pres)) //compares buffer with previous set buffer_pres. If it differs buffer_pres will be updated
{
t16.setText(buffer);
strcpy(buffer_pres, buffer);
}
delay(10);
memset(buffer, 0, sizeof(buffer));
String temp_batTXT = String(temperatureC, 0); //Will show no decimal place
temp_batTXT.toCharArray(buffer, 10);
if (strcmp(buffer, buffer_temp_bat))
{
t6.setText(buffer);
strcpy(buffer_temp_bat, buffer);
}
delay(10);
memset(buffer, 0, sizeof(buffer));
String humidityTXT = String(humidity, 0); //Will show no decimal place
humidityTXT.toCharArray(buffer, 10);
if (strcmp(buffer, buffer_humidity))
{
t23.setText(buffer);
strcpy(buffer_humidity, buffer);
}
delay(10);*/
}
-
Issue could be solved by adding delays after execution of functions related to getValue and setValue out of ITEAD Library from Nextion.
Log in to reply.