ST25DV64KC - how to write a simple text string to payload

Hi Mark (@mbiasotti ),

sprintf should work well for your application.

Looking at the memory dump in your second post, the code has written “Days user has taken their medication = 3” to the first text record. But in your code you used the parameters: false, true); // MB=0, ME=1 . That’s only valid if you are writing two or more records and this is the final record. Message Begin not true; Message End true.

If you write only one record, use: true, true); // MB=1, ME=1

If this is the first of (e.g.) two records, use: true, false); // MB=1, ME=0
The final record should have ME set true.

The code documentation is here.

Also “Days user has taken their medication = 3” is exactly 40 characters. Your buffer needs to be large enough to hold the full message plus a NULL (0) terminating character. I’d suggest increasing the size of buffer to 50 to give yourself some headroom. The writeNDEFText will stop writing when it finds the NULL. snprintf is memory-safe and can prevent you overunning the buffer.

I hope this helps,
Paul