Designing the userinterface with the Nextion editor software is a convenient und quick task. In comparison with the task to convert individual fonts and images to c byte arrays as well as drawing the screens with primitives like drawRect, fillRect in the sourcecode in several iterations till all coordinates match a nice design, the Nextion way of doing takes very less time. One advantage is the possibility to simulate the whole display, even if the ordered display is still on it´s way to you. I found it a little tricky to programm some little if then operations and variable assignments within the Nextion. The syntax is alike c but so simple the few lines were, i encountered several syntax errors messages while trying to compile them. Seems like it´s a bug in the editor software, which were to fix by adding line feeds and removing spaces.
I started with a Arduino Nano but switched to the Arduino Leonardo compatible ProMicro because it provides more interrupt pins. I found online several functions to read the 24bits send synchronously from the calipers. Copy and pasted it in my code and reworte them for supporting multiple calipers. Boom - live values on the Nextion - but wait the code did not respond to the touch events. Searching the problem in the Nextion setup, switching Hardware/Software Serial com, analyzing the problem with Serial debugging, did not help. Next day i came up with the idea to turn on a led as long as the code is in the function for receiving a measurement value. Looking at the led, it seems the led never turns off. A look back to the function showed the problem - blocking while loops. The author used while (digitalRead(clkpin,HIGH))... and while (digitalRead(clkpin,LOW))... to detect the clock pulses, leading the programflow to remain in this loops most of the runtime and not to recognise the serial communication coming from the display. So i rewrote the functions as interrupt service routines called by falling edges of the clockpins and therefore i needed more interrupt pins on the micro. Now the touch events are firing, It is possible to overload the nextion with serial updates of the textfields, which leads to unresponsive touch events. Therefore it is better to update only, it there is really a change in values.
Even if my calipers look like the ones i read online about, their software implementaion are not the same. There should be the possibility to activate a fast readout and a modeswitch be adding pullups to the clock an data lines. But this does not apply in my case. There is no way to interact with the calipers. So i had to implement absolute and incremental measurement in software. To reset the caliper to zero value i used a transistor to turn the caliper supply off for 50ms.
The devices are low voltage so a signal level conversion for clock an data lines to the Arduino IOs was needed. This was simply achieved by transistors. This makes the signal levels active low. Power is supplied by a AMS1117 3.3V LDO and a 50% voltage divider.