good evening gurus! I come to you with another serial communication question that I would desperately appreciate your help with. serial communication is something im still struggling/ working to understand better. thank you in advance.
concisely, i have an esp32 that is reading hx711 weight sensor readings and sending those readings to both the serial monitor and an arduino uno. the esp32 serial monitor displays the readings perfectly.
the arduino uno controls a nextion touch screen display that is meant to display the weight readings sent from the esp32. the nextion also displays voltage readings from the batteries. the voltage readings are acquired by the arduino uno rather than the esp32 like the weight readings are.
heres why that matters. when i press the update button to update the voltage readings, everything displays perfectly. but the weight readings from the esp32 only display on the nextion after i press the update button 2 times. the weight readings show up on the uno serial monitor everytime i press the update button, but upload to the nextion every other press.
posting this here and on nextion in case this is not a serial communication problem with the arduinos.
static boolean newDataReady = 0;
const int serialPrintInterval = 0; //increase value to slow down serial print activity
esp32 load sensor data code
// check for new data/start next conversion:
if (LoadCell.update()) newDataReady = true;
// get smoothed value from the dataset:
if (newDataReady) {
if (millis() > t + serialPrintInterval) {
float i = LoadCell.getData();
float lbs = ((i / 1000) * 2.2);
String wtData = String(lbs);
Serial2.println(wtData);
Serial.print(F("Load_cell output val: "));
Serial.println(lbs);
}
newDataReady = 0;
t = millis();
}
nextion display code
void b7PushCallback(void *ptr) {
float lbs;
if (espSerial.available() > 0) {
espSerial.setTimeout(10);
// Read The Incoming Data As A String
String wtData = espSerial.readString();//Until('\n');
float lbs = wtData.substring(0, 1).toInt();
nexSerial.print("t5.txt=\"");
nexSerial.print("\r\n");
nexSerial.print("\r\n");
nexSerial.print(wtData); //(lbs, 2)
nexSerial.print("\"");
nexSerial.write(0xff);
nexSerial.write(0xff);
nexSerial.write(0xff);
Serial.println(wtData);
delay(100);
}
}