But the main program still does not work ... I do not understand anything.
"Does not work" is ambiguous. What do you mean, specifically? After re-reading the entire thread, I will make a guess. I don't like to guess.
I will guess that blocking operations in the DS18B20 and HX711 libraries are interfering with reading from a software serial port. Writing to a serial port is also blocking, but NeoSWSerial can read at the same time even though other interrupts are blocked (as you know).
The quickest blocking operation in the DS18B20 library takes 66us. Receiving one bit of a character at 9600 baud takes 104us. You can see that DS18B20 operations are very likely to interfere with the timing of received bits.
Here are a few alternatives:
__* __ Use Serial for the Nextion, and use AltSoftSerial on pins 8 & 9 for debug messages. You will need a serial-to-USB converter (aka FTDI adapter) to connect these pins to your PC. You will have to move the pump to pins 2 & 3.
__* __ Use Serial for the Nextion, and use NeoSWSerial on pins 2 & 3 for debug messages. You will need a serial-to-USB converter (aka FTDI adapter) to connect these pins to your PC.
__* __ Use AltSoftSerial on pins 8 & 9 for the Nextion, and move the pump to 2 & 3. AltSoftSerial timing is not as susceptible to blocking, but it may still be affected if the blocking is too long.
__* __ Use NeoSWSerial on pins 2 & 3.
The first two choices will never lose Nextion data, even when using the DS18B20 and HX711 libraries. Printing debug information will block for one character time. Then Serial will be able to handle incoming characters, and another debug character will get written.
IMHO, the 3rd choice will probably lose some Nextion data.
The 4th choice will definitely lose data, because the Nextion is constantly transmitting, and the DS18B20 & HX711 libraries will prevent NeoSWSerial from handling received bits of a character. (You already know this.)
However, the 3rd and 4th choices might work if you pause the Nextion touch packets by setting the System Variable "sendxy=0" before using the DS18B20 & HX711 libraries. After you have the temperature and the weight, enable Nextion touch packets again with "sendxy=1". Another possibility is "tsw 255, 0" and "tsw 255, 1" (Enable/disable component touch function). After disabling touches, you may need to loop until no more characters are received, perhaps for a few milliseconds. Some packets may be "on their way".
BTW, touches would be ignored until the temperature and weight are read and the touches have been re-enabled.
Cheers,
/dev