slow loop Arduino and Nextion

Hi all

I am writing a code to control my marine tank pumps and monitor the external water levels,

the code is working fine this is not a how too or cant work it out question,

The interface is via digital pins (level sensors) and digital outputs (Relays)

The Arduino Mega is interfaced with a Nextion EN 7", again this all works well and I can see the button presses coming in via the serial. THe hole package works

no with the issue, the code is part complete say 10-20%, thus the extra bytes and input/outputs not assigned as yet but the code is slow to cycle, about 1 second each loop (I changed an output to cycle each loop to test it)

as the code is very slow to cycle, it is missing the incoming bits from the Nextion (approx. 1 out of 10 presses change the state of the output), thus the Arduino is not acting on them. its only reading them if I happen to press the button when the code is in the right spot.

the sendCommands change the indications on the Nextion for the Pump and Level indicators.

is my formatting that wrong its slowing it down, can I somehow take some of the code out of the loop, have I completed the code “long hand” is there a better way, the rest of the code is repeats of the attached thus looking for help prior to writing it

Ben, thanks in advance******************

//Code attached

tanks.txt (10.2 KB)

There's lots of functions that I don't know the implementation of there, so I can't say with certainty, but it sounds like whatever that nextion thing is, you're communicating with it over serial. What baud rate? How many characters are you trying to send per loop()? serial writes will block if you fill the buffer, and if it's say, 9600 baud, you can only print about 1000 characters per second...

yes via serial, have upped it to 115200, seams to have helped