What i know: The third parameter for the "addt" command is "qty", the number of bytes that will follow. So how i understood it: After the addt command, the nextion is in an kind of mode to recive data in a hex format. So now the Nextion is ready to recive 10 numbers in hex.
I have not myself used addt, it is on my list of things to experiment with. Your description seems right to me.
My datapoints are stored in plotValues[t]. Now i have to convert every stored data into hex or what?
Unless I have misread your previous posts I think your variable plotValues is an array of floats. Whether you are using add or addt the Nextion is expecting a value between 0 and 255, which is not a float. According to the Nextion instruction set it is indeed expecting a single byte. I suggest you convert your float value to uint8_t then use Serial.write to send it, as Serial.write sends the byte itself, not the value converted to ASCII. You can do this 'on the fly' just prior to sending the data, a byte at a time. Remember that just about any micro-controller can do conversions like this a lot faster than a serial port can shovel the data out. I also suggest that if you are storing the data in plotValues only to be sent to the waveform and not for anything else then it makes sense to store them as an array of uint8_t not floats, as you may as well store them in the form they will be used.
Maybe (not tested)
uint8_t temp;
for(int t=0;t<z;t++)
{
temp = (uint8_t) plotValues[t];
Serial2.write (temp);
Serial2.write(0xFF);
Serial2.write(0xFF);
Serial2.write(0xFF);
Serial.print (temp);
}
The line you will have to play with is the conversion from float to uint8_t, I don't know it what I have put will work. Note that for sending to the Nextion I put Serial.write, this sends just the byte, and for sending to the serial monitor I used Serial.print, which converts it to ASCII first.
Please share with me what you get working, both to satisfy my curiosity and for the benefit of others reading this in future.
Something as an aside, not directly related to what you have asked me but you need to be aware of and change in future:
Here I have my function that writes my data with "add" into the waveform:
String str = String("addt 3,0,")+String(t);
Don't use Strings (as in String with a S) they cause memory problems. I don't know the exact details, but a search of this web site should give you lots of information about NOT using String. Use C strings instead, for example this is from my own code for driving a Nextion waveform:
(This is just an excerpt from a bigger function, but it does the same kind of thing you are trying to do).
#define serial_write_buffer_size 28
char printbuffer[serial_write_buffer_size];
if (i < imax) {
sprintf(printbuffer, "add %1u,%1u,%1u", 1, 0, (unsigned char) round (5 * (temperature_log[0][d] + 15)));
Serial.print(printbuffer);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
++i;
}
Finally, it's nice helping someone who is obviously making an effort rather than expecting someone on here to provide all the answers, finished and working. (Just read some of the other questions and you'll see). For making a decent effort ++Karma;