{"id":196,"date":"2022-03-03T10:36:44","date_gmt":"2022-03-03T10:36:44","guid":{"rendered":"https:\/\/www.bleuio.com\/blog\/?p=196"},"modified":"2022-07-01T10:25:47","modified_gmt":"2022-07-01T10:25:47","slug":"bluetooth-le-based-lcd-messenger-using-stm32-and-bleuio","status":"publish","type":"post","link":"https:\/\/www.bleuio.com\/blog\/bluetooth-le-based-lcd-messenger-using-stm32-and-bleuio\/","title":{"rendered":"Bluetooth LE based LCD messenger using STM32 and BleuIO"},"content":{"rendered":"\n<p>The aim of this project is to send message via Bluetooth using a web browser or smartphone to a LCD display which is connected to STM32 board.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. Introduction<\/h2>\n\n\n\n<p>The project is based on&nbsp;<strong>STM32 Nucleo-144<\/strong>&nbsp;which controls&nbsp;<strong>LCD display<\/strong>&nbsp;using BleuIO.<\/p>\n\n\n\n<p>For this project, we will need two BleuIO USB dongles, one connected to the Nucleo board and the other to a computer, running the web script.<br>When the BleuIO Dongle is connected to the Nucleo boards USB port the STM32 will recognize it and directly start advertising. This allows the Dongle on the computer port connect with the web script.<\/p>\n\n\n\n<p>With the web script on the computer, we can send message to LCD screen connected to STM32 using BleuIO.<\/p>\n\n\n\n<p>We have used a STM32 Nucleo-144 development board with STM32H743ZI MCU (STM32H743ZI micro mbed-Enabled Development Nucleo-144 series ARM\u00ae Cortex\u00ae-M7 MCU 32-Bit Embedded Evaluation Board) for this example. This development board has a USB host where we connect the BleuIO dongle.<\/p>\n\n\n\n<p>If you want to use another setup you will have to make sure it support USB Host and beware that the GPIO setup might be different and may need to be reconfigured in the .ioc file.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">About the Code<\/h2>\n\n\n\n<p>The project source code is available at Github.<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/smart-sensor-devices-ab\/stm32_bleuio_lcd.git\">https:\/\/github.com\/smart-sensor-devices-ab\/stm32_bleuio_lcd.git<\/a><\/p>\n\n\n\n<p>Either clone the project, or download it as a zip file and unzip it, into your STM32CubeIDE workspace.<\/p>\n\n\n\n<p>If you download the project as a zip file you will need to rename the project folder from \u2018stm32_bleuio_lcd-master\u2019 to \u2018stm32_bleuio_lcd\u2019<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"476\" height=\"259\" src=\"https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/pin-configuration.jpg\" alt=\"\" class=\"wp-image-197\" srcset=\"https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/pin-configuration.jpg 476w, https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/pin-configuration-300x163.jpg 300w\" sizes=\"auto, (max-width: 476px) 100vw, 476px\" \/><\/figure>\n\n\n\n<p>Connect the SDA to PF0 on the Nucleo board and SCL to PF1.<\/p>\n\n\n\n<p>Then setup I2C2 in the STM32Cube ioc file as follows. (Make sure to change the I2C speed frequency to 50 KHz as per LCD display requirements.)<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"344\" height=\"69\" src=\"https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/stm32cubeide_pins-1.png\" alt=\"\" class=\"wp-image-198\" srcset=\"https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/stm32cubeide_pins-1.png 344w, https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/stm32cubeide_pins-1-300x60.png 300w\" sizes=\"auto, (max-width: 344px) 100vw, 344px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"548\" height=\"106\" src=\"https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/stm32cubeide_NVIC.png\" alt=\"\" class=\"wp-image-199\" srcset=\"https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/stm32cubeide_NVIC.png 548w, https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/stm32cubeide_NVIC-300x58.png 300w\" sizes=\"auto, (max-width: 548px) 100vw, 548px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"648\" height=\"698\" src=\"https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/LCD-I2C-configuration.jpg\" alt=\"\" class=\"wp-image-200\" srcset=\"https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/LCD-I2C-configuration.jpg 648w, https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/LCD-I2C-configuration-279x300.jpg 279w\" sizes=\"auto, (max-width: 648px) 100vw, 648px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"995\" height=\"1024\" src=\"https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/05\/lcd-stm32-web-bluetooth-995x1024.jpg\" alt=\"\" class=\"wp-image-286\" srcset=\"https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/05\/lcd-stm32-web-bluetooth-995x1024.jpg 995w, https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/05\/lcd-stm32-web-bluetooth-292x300.jpg 292w, https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/05\/lcd-stm32-web-bluetooth-768x790.jpg 768w, https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/05\/lcd-stm32-web-bluetooth-1493x1536.jpg 1493w, https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/05\/lcd-stm32-web-bluetooth.jpg 1536w\" sizes=\"auto, (max-width: 995px) 100vw, 995px\" \/><\/figure>\n\n\n\n<p>In the USBH_CDC_ReceiveCallback function in USB_HOST\\usb_host.c we copy the CDC_RX_Buffer into a external variable called dongle_response that is accessable from the main.c file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>void USBH_CDC_ReceiveCallback(USBH_HandleTypeDef *phost)\n{\n  \tif(phost == &amp;hUsbHostFS)\n  \t{\n  \t\t\/\/ Handles the data recived from the USB CDC host, here just printing it out to UART\n  \t\trx_size = USBH_CDC_GetLastReceivedDataSize(phost);\n\t\tHAL_UART_Transmit(&amp;huart3, CDC_RX_Buffer, rx_size, HAL_MAX_DELAY);\n\n\t\t\/\/ Copy buffer to external dongle_response buffer\n\t\tstrcpy((char *)dongle_response, (char *)CDC_RX_Buffer);\n\n\t\t\/\/ Reset buffer and restart the callback function to receive more data\n\t\tmemset(CDC_RX_Buffer,0,RX_BUFF_SIZE);\n\t\tUSBH_CDC_Receive(phost, CDC_RX_Buffer, RX_BUFF_SIZE);\n  \t}\n\n  \treturn;\n}\n<\/code><\/pre>\n\n\n\n<p>In main.c we create a simple intepreter so we can react to the data we are recieving from the dongle.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>void dongle_interpreter(uint8_t * input)\n{\n\n\tif(strlen((char *)input) != 0)\n\t{\n\t\tif(strstr((char *)input, \"\\r\\nADVERTISING...\") != NULL)\n\t\t{\n\t\t\tisAdvertising = true;\n\t\t}\n\t\tif(strstr((char *)input, \"\\r\\nADVERTISING STOPPED\") != NULL)\n\t\t{\n\t\t\tisAdvertising = false;\n\t\t}\n\t\tif(strstr((char *)input, \"\\r\\nCONNECTED\") != NULL)\n\t\t{\n\t\t\tisConnected = true;\n\t\t\tHAL_GPIO_WritePin(GPIOE, GPIO_PIN_1, GPIO_PIN_SET);\n\t\t}\n\t\tif(strstr((char *)input, \"\\r\\nDISCONNECTED\") != NULL)\n\t\t{\n\t\t\tisConnected = false;\n\t\t\tHAL_GPIO_WritePin(GPIOE, GPIO_PIN_1, GPIO_PIN_RESET);\n\t\t}\n\n\n\t\tif(strstr((char *)input, \"L=0\") != NULL)\n\t\t{\n\n\t\t\tisLightBulbOn = false;\n\t\t\t\/\/HAL_GPIO_WritePin(Lightbulb_GPIO_Port, Lightbulb_Pin, GPIO_PIN_RESET);\n\t\t\tlcd_clear();\n\n\t\t\twriteToDongle((uint8_t*)DONGLE_SEND_LIGHT_OFF);\n\n\t\t\tuart_buf_len = sprintf(uart_tx_buf, \"\\r\\nClear screen\\r\\n\");\n\t\t\tHAL_UART_Transmit(&amp;huart3, (uint8_t *)uart_tx_buf, uart_buf_len, HAL_MAX_DELAY);\n\t\t}\n\n\t\tif(strstr((char *)input, \"L=1\") != NULL)\n\t\t{\n\t\t\t\tisLightBulbOn = true;\n\t\t\t\twriteToDongle((uint8_t*)DONGLE_SEND_LIGHT_ON);\n\n\n\t\t\t\tlcd_clear();\n\n\t\t\t\tlcd_write(input);\n\n\t\t}\n\n\t}\n\tmemset(&amp;dongle_response, 0, RSP_SIZE);\n}<\/code><\/pre>\n\n\n\n<p>We put the intepreter function inside the main loop.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/* Infinite loop *\/\n  \/* USER CODE BEGIN WHILE *\/\n  while (1)\n  {\n    \/* USER CODE END WHILE *\/\n    MX_USB_HOST_Process();\n\n    \/* USER CODE BEGIN 3 *\/\n    \/\/ Simple handler for uart input\n    handleUartInput(uartStatus);\n\n    \/\/ Inteprets the dongle data\n    dongle_interpreter(dongle_response);\n\n\t\/\/ Starts advertising as soon as the Dongle is ready.\n\tif(!isAdvertising &amp;&amp; !isConnected &amp;&amp; isBleuIOReady)\n\t{\n\t\tHAL_Delay(200);\n\t\twriteToDongle((uint8_t*)DONGLE_CMD_AT_ADVSTART);\n\t\tisAdvertising = true;\n\t}\n  }\n  \/* USER CODE END 3 *\/<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Using the example project<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">What we will need<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li>Two BleuIO dongles (<a href=\"https:\/\/www.bleuio.com\/\">https:\/\/www.bleuio.com\/<\/a>)<\/li><li>A board with a STM32 Microcontroller with a USB port. (A Nucleo-144 development board: NUCLEO-H743ZI2, was used developing this example. (<a href=\"https:\/\/www.st.com\/en\/evaluation-tools\/nucleo-h743zi.html\">https:\/\/www.st.com\/en\/evaluation-tools\/nucleo-h743zi.html<\/a>)<br>To connect the dongle to the Nucleo board a \u201cUSB A to Micro USB B\u201d-cable with a USB A female-to-female adapter can be used.)<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"467\" height=\"350\" src=\"https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/adapter.jpg\" alt=\"\" class=\"wp-image-201\" srcset=\"https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/adapter.jpg 467w, https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/adapter-300x225.jpg 300w\" sizes=\"auto, (max-width: 467px) 100vw, 467px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>STM32CubeIDE (<a href=\"https:\/\/www.st.com\/en\/development-tools\/stm32cubeide.html\">https:\/\/www.st.com\/en\/development-tools\/stm32cubeide.html<\/a>)<\/li><li>Liquid Crystal Display Module \u2013 NHD-0420D3Z-NSW-BBW-V3 (<a href=\"https:\/\/www.digikey.com\/en\/products\/detail\/newhaven-display-intl\/NHD-0420D3Z-NSW-BBW-V3\/2626390?s=N4IgTCBcDaIHIAkAiBaADAFjGpBmAWinAMoDqKAQheQGq4gC6AvkA\">https:\/\/www.digikey.com\/en\/products\/detail\/newhaven-display-intl\/NHD-0420D3Z-NSW-BBW-V3\/2626390?s=N4IgTCBcDaIHIAkAiBaADAFjGpBmAWinAMoDqKAQheQGq4gC6AvkA<\/a>)<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Importing as an Existing Project<\/h3>\n\n\n\n<p>From STM32CubeIDE choose File&gt;Import\u2026<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"334\" height=\"536\" src=\"https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/import.png\" alt=\"\" class=\"wp-image-202\" srcset=\"https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/import.png 334w, https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/import-187x300.png 187w\" sizes=\"auto, (max-width: 334px) 100vw, 334px\" \/><\/figure>\n\n\n\n<p>Then choose General&gt;Existing Projects into Workspace then click \u2018Next &gt;\u2019<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"511\" height=\"543\" src=\"https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/existing_projects.png\" alt=\"\" class=\"wp-image-203\" srcset=\"https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/existing_projects.png 511w, https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/existing_projects-282x300.png 282w\" sizes=\"auto, (max-width: 511px) 100vw, 511px\" \/><\/figure>\n\n\n\n<p>Make sure you\u2019ve choosen your workspace in \u2018Select root directory:\u2019<\/p>\n\n\n\n<p>You should see the project \u201cstm32_bleuio_SHT85_example\u201d, check it and click \u2018Finish\u2019.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"463\" height=\"703\" src=\"https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/import_projects.png\" alt=\"\" class=\"wp-image-204\" srcset=\"https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/import_projects.png 463w, https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/import_projects-198x300.png 198w\" sizes=\"auto, (max-width: 463px) 100vw, 463px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Running the example<\/h3>\n\n\n\n<p>Upload the the code to STM32 and run the example. The USB dongle connect to STM32 will start advertising automatically.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"access-sensor-data-from-a-web-browser\">Send Messages to LCD screen from a web browser<\/h2>\n\n\n\n<p>Connect the BleuIO dongle to the computer. Run the web script to connect to the other BleuIO dongle on the STM32. Now you can send messages to the LCD screen.<\/p>\n\n\n\n<p>For this script to work, we need<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/www.bleuio.com\/\">BleuIO USB dongle<\/a>&nbsp;connected to the computer.<\/li><li><a href=\"https:\/\/www.npmjs.com\/package\/bleuio\">BleuIO javascript library<\/a><\/li><li>Chrome 78 or later, and you need to enable the&nbsp;<strong>#enable-experimental-web-platform-features<\/strong>&nbsp;flag in&nbsp;<a href=\"chrome:\/\/flags\/\">chrome:\/\/flags<\/a><\/li><li>A web bundler \u2013 (<a href=\"https:\/\/parceljs.org\/\">parcel js<\/a>)<\/li><\/ul>\n\n\n\n<p>Create a simple Html file called index.html which will serve as the frontend of the script. This Html file contains some buttons that help connect and read advertised data from the remote dongle, which is connected to stm32.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html lang=\"en\"&gt;\n  &lt;head&gt;\n    &lt;meta charset=\"UTF-8\" \/&gt;\n    &lt;meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" \/&gt;\n    &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" \/&gt;\n    &lt;link\n      href=\"https:\/\/cdn.jsdelivr.net\/npm\/bootstrap@5.1.3\/dist\/css\/bootstrap.min.css\"\n      rel=\"stylesheet\"\n      integrity=\"sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3\"\n      crossorigin=\"anonymous\"\n    \/&gt;\n    &lt;title&gt;Send message to STM32 LCD display using Bluetooth LE&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body class=\"mt-5\"&gt;\n    &lt;div class=\"container mt-5\"&gt;\n      &lt;h1 class=\"mb-5\"&gt;Send message to STM32 LCD display using Bluetooth LE&lt;\/h1&gt;\n      &lt;button class=\"btn btn-success\" id=\"connect\"&gt;Connect&lt;\/button&gt;\n      &lt;div class=\"row\"&gt;\n        &lt;div class=\"col-md-4\"&gt;\n          &lt;form method=\"post\" id=\"sendMsgForm\" name=\"sendMsgForm\"&gt;\n            &lt;div class=\"mb-3\"&gt;\n              &lt;label for=\"msgToSend\" class=\"form-label\"&gt;Your Message&lt;\/label&gt;\n              &lt;input\n                type=\"text\"\n                class=\"form-control\"\n                name=\"msgToSend\"\n                id=\"msgToSend\"\n                required\n                maxlength=\"60\"\n              \/&gt;\n            &lt;\/div&gt;\n\n            &lt;button type=\"submit\" class=\"btn btn-primary\"&gt;Submit&lt;\/button&gt;\n          &lt;\/form&gt;\n        &lt;\/div&gt;\n      &lt;\/div&gt;\n\n      &lt;br \/&gt;\n      &lt;button class=\"btn btn-danger\" id=\"clearScreen\" disabled&gt;\n        Clear screen\n      &lt;\/button&gt;\n    &lt;\/div&gt;\n\n    &lt;script src=\"script.js\"&gt;&lt;\/script&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<p>Create a js file called script.js and include it at the bottom of the Html file. This js file uses the BleuIO js library to write AT commands and communicate with the other dongle.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import * as my_dongle from 'bleuio'\nconst dongleToConnect='&#91;0]40:48:FD:E5:2F:17'\ndocument.getElementById('connect').addEventListener('click', function(){\n  my_dongle.at_connect()\n  document.getElementById(\"clearScreen\").disabled=false;\n  document.getElementById(\"connect\").disabled=true;\n  document.getElementById(\"sendMsgForm\").hidden=false;\n})\n\ndocument.getElementById(\"sendMsgForm\").addEventListener(\"submit\", function(event){\n    event.preventDefault()\n    console.log('here')\n\n    \n    my_dongle.ati().then((data)=&gt;{\n        \/\/make central if not\n        if(JSON.stringify(data).includes(\"Peripheral\")){\n            console.log('peripheral')\n            my_dongle.at_central().then((x)=&gt;{\n                console.log('central now')\n            })\n        }        \n    })\n    .then(()=&gt;{\n        \/\/ connect to dongle\n        my_dongle.at_getconn().then((y)=&gt;{\n            if(JSON.stringify(y).includes(dongleToConnect)){\n                console.log('already connected')\n            }else{\n                my_dongle.at_gapconnect(dongleToConnect).then(()=&gt;{\n                    console.log('connected successfully')\n                })\n            }\n        })\n        .then(()=&gt;{\n            var theVal = \"L=1 \" + document.getElementById('msgToSend').value;\n            console.log('Message Send 1 '+theVal)\n            \/\/ send command to show data\n            my_dongle.at_spssend(theVal).then(()=&gt;{\n                console.log('Message Send '+theVal)\n            })\n        })\n        \n    })\n  });\n\n\n\ndocument.getElementById('clearScreen').addEventListener('click', function(){\n    my_dongle.ati().then((data)=&gt;{\n        \/\/make central if not\n        if(JSON.stringify(data).includes(\"Peripheral\")){\n            console.log('peripheral')\n            my_dongle.at_central().then((x)=&gt;{\n                console.log('central now')\n            })\n        }\n    })\n    .then(()=&gt;{\n        \/\/ connect to dongle\n        my_dongle.at_getconn().then((y)=&gt;{\n            if(JSON.stringify(y).includes(dongleToConnect)){\n                console.log('already connected')\n            }else{\n                my_dongle.at_gapconnect(dongleToConnect).then(()=&gt;{\n                    console.log('connected successfully')\n                })\n            }\n        })\n        .then(()=&gt;{\n            \/\/ send command to clear the screen\n            my_dongle.at_spssend('L=0').then(()=&gt;{\n                console.log('Screen Cleared')\n            })\n        })\n        \n    })\n})<\/code><\/pre>\n\n\n\n<p>The script has a button to connect to COM port on the computer. There is a text field where you can write your message. Your messages will be displayed on LCD screen connected to STM32 board.<\/p>\n\n\n\n<p>To connect to the BleuIO dongle on the STM32, make sure the STM32 is powered up and a BleuIO dongle is connected to it.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Get the MAC address<\/h3>\n\n\n\n<p>Follow the steps to get the MAC address of the dongle that is connected to STM32<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>- Open this site https:\/\/bleuio.com\/web_terminal.html and click connect to dongle.\n- Select the appropriate port to connect.\n- Once it says connected, type ATI. This will show dongle information and current status.\n- If the dongle is on peripheral role, set it to central by typing AT+CENTRAL\n- Now do a gap scan by typing AT+GAPSCAN\n- Once you see your dongle on the list ,stop the scan by pressing control+c\n- Copy the ID and paste it into the script (script.js) line #2<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"450\" height=\"686\" src=\"https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/scan_deviceid.gif\" alt=\"\" class=\"wp-image-205\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Run the web script<\/h3>\n\n\n\n<p>You will need a web bundler. You can use&nbsp;<a href=\"https:\/\/parceljs.org\/\">parcel.js<\/a><\/p>\n\n\n\n<p>Once parcel js installed, go to the root directory of web script and type&nbsp;<strong>\u201cparcel index.html\u201d<\/strong>. This will start your development environment.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"607\" height=\"220\" src=\"https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/parcel_on.jpg\" alt=\"\" class=\"wp-image-206\" srcset=\"https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/parcel_on.jpg 607w, https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/parcel_on-300x109.jpg 300w\" sizes=\"auto, (max-width: 607px) 100vw, 607px\" \/><\/figure>\n\n\n\n<p>Open the script on a browser. For this example we opened http:\/\/localhost:1234<\/p>\n\n\n\n<p>You can easily connect to the dongle and send your message to the LCD screen. The response will show on browser console screen.<\/p>\n\n\n\n<p>The web script looks like this<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"610\" src=\"https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/image-1-1024x610-1.png\" alt=\"\" class=\"wp-image-207\" srcset=\"https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/image-1-1024x610-1.png 1024w, https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/image-1-1024x610-1-300x179.png 300w, https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/image-1-1024x610-1-768x458.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Output<\/h3>\n\n\n\n<p>The message will show on the LCD screen.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"764\" src=\"https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/image-2-1024x764-1.png\" alt=\"\" class=\"wp-image-208\" srcset=\"https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/image-2-1024x764-1.png 1024w, https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/image-2-1024x764-1-300x224.png 300w, https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/image-2-1024x764-1-768x573.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><strong>Video of working project<\/strong><\/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=\"A project with STM32 that sends message to LCD display from web browser via Bluetooth\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/v6r6aVYXUa0?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>The aim of this project is to send message via Bluetooth using a web browser or smartphone to a LCD display which is connected to STM32 board. 1. Introduction The project is based on&nbsp;STM32 Nucleo-144&nbsp;which controls&nbsp;LCD display&nbsp;using BleuIO. For this project, we will need two BleuIO USB dongles, one connected to the Nucleo board and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":209,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-196","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bleuio-tutorial"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Bluetooth LE based LCD messenger using STM32 and BleuIO - BleuIO - Create Bluetooth Low Energy application<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.bleuio.com\/blog\/bluetooth-le-based-lcd-messenger-using-stm32-and-bleuio\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Bluetooth LE based LCD messenger using STM32 and BleuIO - BleuIO - Create Bluetooth Low Energy application\" \/>\n<meta property=\"og:description\" content=\"The aim of this project is to send message via Bluetooth using a web browser or smartphone to a LCD display which is connected to STM32 board. 1. Introduction The project is based on&nbsp;STM32 Nucleo-144&nbsp;which controls&nbsp;LCD display&nbsp;using BleuIO. For this project, we will need two BleuIO USB dongles, one connected to the Nucleo board and [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.bleuio.com\/blog\/bluetooth-le-based-lcd-messenger-using-stm32-and-bleuio\/\" \/>\n<meta property=\"og:site_name\" content=\"BleuIO - Create Bluetooth Low Energy application\" \/>\n<meta property=\"article:published_time\" content=\"2022-03-03T10:36:44+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-07-01T10:25:47+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/ble-based-lcd-messenger-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"674\" \/>\n\t<meta property=\"og:image:height\" content=\"478\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"BleuIO\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.bleuio.com\\\/blog\\\/bluetooth-le-based-lcd-messenger-using-stm32-and-bleuio\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.bleuio.com\\\/blog\\\/bluetooth-le-based-lcd-messenger-using-stm32-and-bleuio\\\/\"},\"author\":{\"name\":\"BleuIO\",\"@id\":\"https:\\\/\\\/www.bleuio.com\\\/blog\\\/#\\\/schema\\\/person\\\/89bc581382d5964043f96efc54b75b80\"},\"headline\":\"Bluetooth LE based LCD messenger using STM32 and BleuIO\",\"datePublished\":\"2022-03-03T10:36:44+00:00\",\"dateModified\":\"2022-07-01T10:25:47+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.bleuio.com\\\/blog\\\/bluetooth-le-based-lcd-messenger-using-stm32-and-bleuio\\\/\"},\"wordCount\":891,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.bleuio.com\\\/blog\\\/bluetooth-le-based-lcd-messenger-using-stm32-and-bleuio\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.bleuio.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/03\\\/ble-based-lcd-messenger-1.jpg\",\"articleSection\":[\"BleuIO tutorial\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.bleuio.com\\\/blog\\\/bluetooth-le-based-lcd-messenger-using-stm32-and-bleuio\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.bleuio.com\\\/blog\\\/bluetooth-le-based-lcd-messenger-using-stm32-and-bleuio\\\/\",\"url\":\"https:\\\/\\\/www.bleuio.com\\\/blog\\\/bluetooth-le-based-lcd-messenger-using-stm32-and-bleuio\\\/\",\"name\":\"Bluetooth LE based LCD messenger using STM32 and BleuIO - BleuIO - Create Bluetooth Low Energy application\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.bleuio.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.bleuio.com\\\/blog\\\/bluetooth-le-based-lcd-messenger-using-stm32-and-bleuio\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.bleuio.com\\\/blog\\\/bluetooth-le-based-lcd-messenger-using-stm32-and-bleuio\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.bleuio.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/03\\\/ble-based-lcd-messenger-1.jpg\",\"datePublished\":\"2022-03-03T10:36:44+00:00\",\"dateModified\":\"2022-07-01T10:25:47+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.bleuio.com\\\/blog\\\/#\\\/schema\\\/person\\\/89bc581382d5964043f96efc54b75b80\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.bleuio.com\\\/blog\\\/bluetooth-le-based-lcd-messenger-using-stm32-and-bleuio\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.bleuio.com\\\/blog\\\/bluetooth-le-based-lcd-messenger-using-stm32-and-bleuio\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.bleuio.com\\\/blog\\\/bluetooth-le-based-lcd-messenger-using-stm32-and-bleuio\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.bleuio.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/03\\\/ble-based-lcd-messenger-1.jpg\",\"contentUrl\":\"https:\\\/\\\/www.bleuio.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/03\\\/ble-based-lcd-messenger-1.jpg\",\"width\":674,\"height\":478,\"caption\":\"ble based lcd messenger\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.bleuio.com\\\/blog\\\/bluetooth-le-based-lcd-messenger-using-stm32-and-bleuio\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.bleuio.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Bluetooth LE based LCD messenger using STM32 and BleuIO\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.bleuio.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.bleuio.com\\\/blog\\\/\",\"name\":\"BleuIO - Create Bluetooth Low Energy application\",\"description\":\"Learn Bluetooth Low Energy programming and build Bluetooth Low Energy Application\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.bleuio.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.bleuio.com\\\/blog\\\/#\\\/schema\\\/person\\\/89bc581382d5964043f96efc54b75b80\",\"name\":\"BleuIO\",\"sameAs\":[\"https:\\\/\\\/www.bleuio.com\\\/blog\"],\"url\":\"https:\\\/\\\/www.bleuio.com\\\/blog\\\/author\\\/biadmin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Bluetooth LE based LCD messenger using STM32 and BleuIO - BleuIO - Create Bluetooth Low Energy application","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.bleuio.com\/blog\/bluetooth-le-based-lcd-messenger-using-stm32-and-bleuio\/","og_locale":"en_US","og_type":"article","og_title":"Bluetooth LE based LCD messenger using STM32 and BleuIO - BleuIO - Create Bluetooth Low Energy application","og_description":"The aim of this project is to send message via Bluetooth using a web browser or smartphone to a LCD display which is connected to STM32 board. 1. Introduction The project is based on&nbsp;STM32 Nucleo-144&nbsp;which controls&nbsp;LCD display&nbsp;using BleuIO. For this project, we will need two BleuIO USB dongles, one connected to the Nucleo board and [&hellip;]","og_url":"https:\/\/www.bleuio.com\/blog\/bluetooth-le-based-lcd-messenger-using-stm32-and-bleuio\/","og_site_name":"BleuIO - Create Bluetooth Low Energy application","article_published_time":"2022-03-03T10:36:44+00:00","article_modified_time":"2022-07-01T10:25:47+00:00","og_image":[{"width":674,"height":478,"url":"https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/ble-based-lcd-messenger-1.jpg","type":"image\/jpeg"}],"author":"BleuIO","twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.bleuio.com\/blog\/bluetooth-le-based-lcd-messenger-using-stm32-and-bleuio\/#article","isPartOf":{"@id":"https:\/\/www.bleuio.com\/blog\/bluetooth-le-based-lcd-messenger-using-stm32-and-bleuio\/"},"author":{"name":"BleuIO","@id":"https:\/\/www.bleuio.com\/blog\/#\/schema\/person\/89bc581382d5964043f96efc54b75b80"},"headline":"Bluetooth LE based LCD messenger using STM32 and BleuIO","datePublished":"2022-03-03T10:36:44+00:00","dateModified":"2022-07-01T10:25:47+00:00","mainEntityOfPage":{"@id":"https:\/\/www.bleuio.com\/blog\/bluetooth-le-based-lcd-messenger-using-stm32-and-bleuio\/"},"wordCount":891,"commentCount":0,"image":{"@id":"https:\/\/www.bleuio.com\/blog\/bluetooth-le-based-lcd-messenger-using-stm32-and-bleuio\/#primaryimage"},"thumbnailUrl":"https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/ble-based-lcd-messenger-1.jpg","articleSection":["BleuIO tutorial"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.bleuio.com\/blog\/bluetooth-le-based-lcd-messenger-using-stm32-and-bleuio\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.bleuio.com\/blog\/bluetooth-le-based-lcd-messenger-using-stm32-and-bleuio\/","url":"https:\/\/www.bleuio.com\/blog\/bluetooth-le-based-lcd-messenger-using-stm32-and-bleuio\/","name":"Bluetooth LE based LCD messenger using STM32 and BleuIO - BleuIO - Create Bluetooth Low Energy application","isPartOf":{"@id":"https:\/\/www.bleuio.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.bleuio.com\/blog\/bluetooth-le-based-lcd-messenger-using-stm32-and-bleuio\/#primaryimage"},"image":{"@id":"https:\/\/www.bleuio.com\/blog\/bluetooth-le-based-lcd-messenger-using-stm32-and-bleuio\/#primaryimage"},"thumbnailUrl":"https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/ble-based-lcd-messenger-1.jpg","datePublished":"2022-03-03T10:36:44+00:00","dateModified":"2022-07-01T10:25:47+00:00","author":{"@id":"https:\/\/www.bleuio.com\/blog\/#\/schema\/person\/89bc581382d5964043f96efc54b75b80"},"breadcrumb":{"@id":"https:\/\/www.bleuio.com\/blog\/bluetooth-le-based-lcd-messenger-using-stm32-and-bleuio\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.bleuio.com\/blog\/bluetooth-le-based-lcd-messenger-using-stm32-and-bleuio\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.bleuio.com\/blog\/bluetooth-le-based-lcd-messenger-using-stm32-and-bleuio\/#primaryimage","url":"https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/ble-based-lcd-messenger-1.jpg","contentUrl":"https:\/\/www.bleuio.com\/blog\/wp-content\/uploads\/2022\/03\/ble-based-lcd-messenger-1.jpg","width":674,"height":478,"caption":"ble based lcd messenger"},{"@type":"BreadcrumbList","@id":"https:\/\/www.bleuio.com\/blog\/bluetooth-le-based-lcd-messenger-using-stm32-and-bleuio\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.bleuio.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Bluetooth LE based LCD messenger using STM32 and BleuIO"}]},{"@type":"WebSite","@id":"https:\/\/www.bleuio.com\/blog\/#website","url":"https:\/\/www.bleuio.com\/blog\/","name":"BleuIO - Create Bluetooth Low Energy application","description":"Learn Bluetooth Low Energy programming and build Bluetooth Low Energy Application","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.bleuio.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.bleuio.com\/blog\/#\/schema\/person\/89bc581382d5964043f96efc54b75b80","name":"BleuIO","sameAs":["https:\/\/www.bleuio.com\/blog"],"url":"https:\/\/www.bleuio.com\/blog\/author\/biadmin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.bleuio.com\/blog\/wp-json\/wp\/v2\/posts\/196","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bleuio.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bleuio.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bleuio.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bleuio.com\/blog\/wp-json\/wp\/v2\/comments?post=196"}],"version-history":[{"count":3,"href":"https:\/\/www.bleuio.com\/blog\/wp-json\/wp\/v2\/posts\/196\/revisions"}],"predecessor-version":[{"id":288,"href":"https:\/\/www.bleuio.com\/blog\/wp-json\/wp\/v2\/posts\/196\/revisions\/288"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bleuio.com\/blog\/wp-json\/wp\/v2\/media\/209"}],"wp:attachment":[{"href":"https:\/\/www.bleuio.com\/blog\/wp-json\/wp\/v2\/media?parent=196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bleuio.com\/blog\/wp-json\/wp\/v2\/categories?post=196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bleuio.com\/blog\/wp-json\/wp\/v2\/tags?post=196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}