{"id":1085,"date":"2022-07-24T04:18:01","date_gmt":"2022-07-24T04:18:01","guid":{"rendered":"https:\/\/blog.embeddedexpert.io\/?p=1085"},"modified":"2022-07-24T04:56:49","modified_gmt":"2022-07-24T04:56:49","slug":"stm32-and-nextion-display-part-2-sending-strings","status":"publish","type":"post","link":"https:\/\/blog.embeddedexpert.io\/?p=1085","title":{"rendered":"STM32 and Nextion Display Part 2: Sending Strings"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/m.media-amazon.com\/images\/S\/abs-image-upload-na\/9\/AmazonStores\/ATVPDKIKX0DER\/4551205750cd023df17bdecd5dbbb3ee.w400.h400.jpg\" alt=\"\" \/><\/figure><\/div>\n\n\n\n<p>In the previous guide (<a rel=\"noreferrer noopener\" href=\"https:\/\/blog.embeddedexpert.io\/?p=1081\" data-type=\"URL\" data-id=\"https:\/\/blog.embeddedexpert.io\/?p=1081\" target=\"_blank\">here<\/a>), we saw how to setup Nextion editor and STM32F4 to work with Nextion display. In this guide, we shall see how to send some strings from STM32 to Nextion display.<\/p>\n\n\n\n<p>In this guide, we will cover the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Nextion Display setup<\/li><li>STM32F4 setup.<\/li><li>Demo.<\/li><\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. Nextion Display Setup:<\/h2>\n\n\n\n<p><\/p>\n\n\n\n<p>We start of by opening Nextion editor. Then, File, New:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"736\" height=\"900\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-06-42.png\" alt=\"\" class=\"wp-image-1086\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-06-42.png 736w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-06-42-245x300.png 245w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-06-42-400x489.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-06-42-250x306.png 250w\" sizes=\"(max-width: 736px) 100vw, 736px\" \/><\/figure>\n\n\n\n<p>Then give the project a name.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>After that, select your model (mine is NX3224K024_011):<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"758\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-09-52-1024x758.png\" alt=\"\" class=\"wp-image-1087\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-09-52-1024x758.png 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-09-52-300x222.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-09-52-768x569.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-09-52-1536x1138.png 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-09-52-1150x852.png 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-09-52-750x555.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-09-52-400x296.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-09-52-250x185.png 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-09-52.png 1758w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Select the direction:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"776\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-10-37-1024x776.png\" alt=\"\" class=\"wp-image-1088\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-10-37-1024x776.png 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-10-37-300x227.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-10-37-768x582.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-10-37-1536x1164.png 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-10-37-1150x871.png 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-10-37-750x568.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-10-37-400x303.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-10-37-250x189.png 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-10-37.png 1726w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>In my case, horizontal 90.<\/p>\n\n\n\n<p>Finally press OK.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>After that, you will be greeted by empty project.<\/p>\n\n\n\n<p>From left toolbox, select text:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"933\" height=\"1024\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-13-01-933x1024.png\" alt=\"\" class=\"wp-image-1089\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-13-01-933x1024.png 933w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-13-01-273x300.png 273w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-13-01-768x843.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-13-01-1400x1536.png 1400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-13-01-1150x1262.png 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-13-01-750x823.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-13-01-400x439.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-13-01-250x274.png 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-13-01.png 1524w\" sizes=\"(max-width: 933px) 100vw, 933px\" \/><\/figure>\n\n\n\n<p>Resize the text size according to your screen.<\/p>\n\n\n\n<p>From right side, attribute, note the objname and set txt_maxl to 30:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"322\" height=\"1024\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-14-15-322x1024.png\" alt=\"\" class=\"wp-image-1090\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-14-15-322x1024.png 322w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-14-15-94x300.png 94w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-14-15-400x1271.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-14-15-250x794.png 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-14-15.png 430w\" sizes=\"(max-width: 322px) 100vw, 322px\" \/><\/figure><\/div>\n\n\n\n<p>Then, we need to generate fonts as following:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"983\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-16-38-1024x983.png\" alt=\"\" class=\"wp-image-1093\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-16-38-1024x983.png 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-16-38-300x288.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-16-38-768x737.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-16-38-1150x1104.png 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-16-38-750x720.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-16-38-400x384.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-16-38-250x240.png 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-16-38.png 1198w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Select the type of font you like and give a name to the font:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"900\" height=\"878\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-18-44.png\" alt=\"\" class=\"wp-image-1094\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-18-44.png 900w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-18-44-300x293.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-18-44-768x749.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-18-44-750x732.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-18-44-400x390.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-18-44-250x244.png 250w\" sizes=\"(max-width: 900px) 100vw, 900px\" \/><\/figure>\n\n\n\n<p>Press Generate font and save the file<\/p>\n\n\n\n<p>After that, press yes.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"960\" height=\"376\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-19-26.png\" alt=\"\" class=\"wp-image-1095\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-19-26.png 960w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-19-26-300x118.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-19-26-768x301.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-19-26-750x294.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-19-26-400x157.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-19-26-250x98.png 250w\" sizes=\"(max-width: 960px) 100vw, 960px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Now you good to go.<\/p>\n\n\n\n<p>After that, press on debug to see the result:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"330\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-21-30-1024x330.png\" alt=\"\" class=\"wp-image-1097\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-21-30-1024x330.png 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-21-30-300x97.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-21-30-768x248.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-21-30-1150x371.png 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-21-30-750x242.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-21-30-400x129.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-21-30-250x81.png 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-21-30.png 1222w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>In String area, type the following and press enter:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">t0.txt=&quot;hello&quot;<\/pre><\/div>\n\n\n\n<p>You should see something similar:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"771\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-23-16-1024x771.png\" alt=\"\" class=\"wp-image-1098\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-23-16-1024x771.png 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-23-16-300x226.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-23-16-768x578.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-23-16-1536x1156.png 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-23-16-2048x1542.png 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-23-16-1150x866.png 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-23-16-750x565.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-23-16-400x301.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-23-16-250x188.png 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Now, press on hex:<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"940\" height=\"618\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-24-07.png\" alt=\"\" class=\"wp-image-1099\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-24-07.png 940w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-24-07-300x197.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-24-07-768x505.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-24-07-750x493.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-24-07-400x263.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-24-07-250x164.png 250w\" sizes=\"(max-width: 940px) 100vw, 940px\" \/><\/figure>\n\n\n\n<p>You will get the equivalent hex format to t0.txt=&#8221;hello&#8221; and extra 3  0xFF which indicate the end of the command. This shall be sent at the end of each string in our code.<\/p>\n\n\n\n<p>Now, insert an SD-Card to your computer and generate TFT file to load it to our display:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"946\" height=\"1024\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-28-06-946x1024.png\" alt=\"\" class=\"wp-image-1100\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-28-06-946x1024.png 946w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-28-06-277x300.png 277w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-28-06-768x831.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-28-06-750x812.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-28-06-400x433.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-28-06-250x271.png 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-28-06.png 1138w\" sizes=\"(max-width: 946px) 100vw, 946px\" \/><\/figure>\n\n\n\n<p>After that, select your SD-Card:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"858\" height=\"364\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-30-43.png\" alt=\"\" class=\"wp-image-1101\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-30-43.png 858w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-30-43-300x127.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-30-43-768x326.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-30-43-750x318.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-30-43-400x170.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2022\/07\/2022-07-24_07-30-43-250x106.png 250w\" sizes=\"(max-width: 858px) 100vw, 858px\" \/><\/figure>\n\n\n\n<p>Press on output to copy the file to SD-Card.<\/p>\n\n\n\n<p>Now, insert the SD-Card into your Nextion display:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/12\/nextion-micro-sd.jpg?resize=501%2C265&amp;quality=100&amp;strip=all&amp;ssl=1\" alt=\"\" class=\"wp-image-48126\" \/><\/figure><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>You should see a message on the display saying the code is being uploaded.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/12\/copy-sd-card-nextion.jpg?resize=501%2C271&amp;quality=100&amp;strip=all&amp;ssl=1\" alt=\"\" class=\"wp-image-48125\" \/><\/figure><\/div>\n\n\n\n<p>When it is ready, it should display the following message:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/12\/upload-success-nextion.jpg?resize=700%2C303&amp;quality=100&amp;strip=all&amp;ssl=1\" alt=\"\" class=\"wp-image-48127\" \/><\/figure><\/div>\n\n\n\n<p>Remove the power from the Nextion display, and unplug the microSD card.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>After than, you should see newtxt is being displayed on the screen. This is the end of step one.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. STM32F4 Setup:<\/h2>\n\n\n\n<p><\/p>\n\n\n\n<p>The function that will send the string to Nextion display shall take two arguments:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>First one character pointer to the id.<\/li><li>Second one character pointer to the string to be sent.<\/li><\/ul>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">void nextion_write_text(char *id,char * p)<\/pre><\/div>\n\n\n\n<p>Inside the function, we declare character array of 5 to hold the data:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">char buf[50];<\/pre><\/div>\n\n\n\n<p>Then using sprintf, we shall combine the id and the string into single character array:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">sprintf(buf,&quot;%s.txt=\\&quot;%s\\&quot;&quot;,id,p);<\/pre><\/div>\n\n\n\n<p>Send the buffer:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">send_uart(buf);<\/pre><\/div>\n\n\n\n<p>Write the 3 0xFF:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">\tuart1_write(0xFF);\n\tuart1_write(0xFF);\n\tuart1_write(0xFF);<\/pre><\/div>\n\n\n\n<p>Hence, the entire function as following:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">\nvoid nextion_write_text(char *id,char * p)\n{\n\tchar buf[50];\n\tsprintf(buf,&quot;%s.txt=\\&quot;%s\\&quot;&quot;,id,p);\n\tsend_uart(buf);\n\tuart1_write(0xFF);\n\tuart1_write(0xFF);\n\tuart1_write(0xFF);\n\n}\n<\/pre><\/div>\n\n\n\n<p>In main function:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">#include &quot;delay.h&quot;\n#include &quot;string.h&quot;\n#include &quot;nextion_uart.h&quot;\n\n\/*Nextion Buffer size*\/\n#define NEXTION_BUFF_LENG 10\nvolatile char NEXTION_BUFF[NEXTION_BUFF_LENG];\nvolatile uint32_t itr;\n\nchar data_send[10];\nuint8_t counter;\nint main(void)\n\t{\n\tSCB-&gt;CPACR |= ((3UL &lt;&lt; 10*2)|(3UL &lt;&lt; 11*2));\n\tsystick_init_ms(16000000);\n\tnextion_uar_init(115200,16000000);\n\n\twhile(1)\n\t\t{\n\t\tsprintf(data_send,&quot;Count=%d&quot;,counter++);\n\t\tnextion_write_text(&quot;t0&quot;,data_send);\n\t\tdelay(100);\n\t\t}\n\t}\n<\/pre><\/div>\n\n\n\n<p>Note: my Nextion display works with 115200 baudrate.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. Demo:<\/h2>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Text Mode on Nextion Display with STM32F4\" width=\"1170\" height=\"658\" src=\"https:\/\/www.youtube.com\/embed\/ArCjoPMrOEE?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>Happy coding \ud83d\ude42 <\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the previous guide (here), we saw how to setup Nextion editor and STM32F4 to work with Nextion display. In this guide, we shall see how to send some strings from STM32 to Nextion display. In this guide, we will cover the following: Nextion Display setup STM32F4 setup. Demo. 1. Nextion Display Setup: We start [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,19,11,12],"tags":[],"class_list":["post-1085","post","type-post","status-publish","format-standard","hentry","category-embedded-systems","category-lcd","category-peripheral-drivers","category-stm32"],"_links":{"self":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/1085"}],"collection":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1085"}],"version-history":[{"count":3,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/1085\/revisions"}],"predecessor-version":[{"id":1104,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/1085\/revisions\/1104"}],"wp:attachment":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1085"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1085"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1085"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}