{"id":85076,"date":"2019-05-10T11:16:10","date_gmt":"2019-05-10T11:16:10","guid":{"rendered":"https:\/\/randomnerdtutorials.com\/?p=85076"},"modified":"2019-05-10T11:30:29","modified_gmt":"2019-05-10T11:30:29","slug":"esp32-bluetooth-classic-arduino-ide","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/esp32-bluetooth-classic-arduino-ide\/","title":{"rendered":"ESP32 Bluetooth Classic with Arduino IDE &#8211; Getting Started"},"content":{"rendered":"\n<p>The ESP32 comes with Wi-Fi, Bluetooth Low Energy and Bluetooth Classic. In this tutorial, you&#8217;ll learn how to use ESP32 Bluetooth Classic with Arduino IDE to exchange data between an ESP32 and an Android smartphone.<br><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" width=\"1200\" height=\"675\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/ESP32-Bluetooth-Classic-Arduino-IDE-BT.jpg?resize=1200%2C675&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Bluetooth Classic and Android Smartphone BT\" class=\"wp-image-85219\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/ESP32-Bluetooth-Classic-Arduino-IDE-BT.jpg?w=1280&amp;quality=100&amp;strip=all&amp;ssl=1 1280w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/ESP32-Bluetooth-Classic-Arduino-IDE-BT.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/ESP32-Bluetooth-Classic-Arduino-IDE-BT.jpg?resize=768%2C432&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/ESP32-Bluetooth-Classic-Arduino-IDE-BT.jpg?resize=1024%2C576&amp;quality=100&amp;strip=all&amp;ssl=1 1024w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure><\/div>\n\n\n\n<p>We\u2019ll control an ESP32 output, and send sensor readings to an Android smartphone using Bluetooth Classic.<\/p>\n\n\n\n<p class=\"rntbox rntclblue\"><strong>Note: <\/strong> this project is <strong><u>only<\/u><\/strong> compatible with Android smartphones.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Watch the Video Tutorial<\/h2>\n\n\n\n<p>You can watch the video tutorial or keep reading this page for the written instructions.<br><\/p>\n\n\n<p style=\"text-align:center\"><iframe width=\"720\" height=\"405\" src=\"https:\/\/www.youtube.com\/embed\/RStncO3zb8g?rel=0\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Bluetooth Classic with ESP32<\/h2>\n\n\n\n<p>At the moment, using Bluetooth Classic is much more simpler than <a href=\"https:\/\/randomnerdtutorials.com\/esp32-bluetooth-low-energy-ble-arduino-ide\/\">Bluetooth Low Energy<\/a>. If you\u2019ve already programmed an Arduino with a <a href=\"https:\/\/makeradvisor.com\/tools\/bluetooth-module-hc-06\/\">Bluetooth module like the HC-06<\/a>, this is very similar. It uses the standard serial protocol and functions.<br><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"750\" height=\"414\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/arduino-hc-05.jpg?resize=750%2C414&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"hc-05 bluetooth module arduino ESP32\" class=\"wp-image-85081\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/arduino-hc-05.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/arduino-hc-05.jpg?resize=300%2C166&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n\n<p>In this tutorial, we\u2019ll start by using an example that comes with the Arduino IDE. Then, we\u2019ll build a simple project to exchange data between the ESP32 and your Android smartphone.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Parts Required<\/h2>\n\n\n\n<p>To follow this tutorial, you need the following parts:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a rel=\"noreferrer noopener\" href=\"https:\/\/makeradvisor.com\/tools\/esp32-dev-board-wi-fi-bluetooth\/\" target=\"_blank\">ESP32 DOIT DEVKIT V1 Board<\/a> (read <a href=\"https:\/\/makeradvisor.com\/esp32-development-boards-review-comparison\/\">Best ESP32 development boards<\/a>)<\/li><li>Android Smartphone with Bluetooth<\/li><li><a rel=\"noreferrer noopener\" href=\"https:\/\/makeradvisor.com\/tools\/3mm-5mm-leds-kit-storage-box\/\" target=\"_blank\">5mm LED<\/a><\/li><li><a rel=\"noreferrer noopener\" href=\"https:\/\/makeradvisor.com\/tools\/resistors-kits\/\" target=\"_blank\">330 Ohm resistor<\/a><\/li><li><a rel=\"noreferrer noopener\" href=\"https:\/\/makeradvisor.com\/tools\/ds18b20-digital-temperature-sensor\/\" target=\"_blank\">DS18B20 temperature sensor<\/a><\/li><li><a rel=\"noreferrer noopener\" href=\"https:\/\/makeradvisor.com\/tools\/resistors-kits\/\" target=\"_blank\">4.7k Ohm resistor<\/a><\/li><li><a rel=\"noreferrer noopener\" href=\"https:\/\/makeradvisor.com\/tools\/jumper-wires-kit-120-pieces\/\" target=\"_blank\">Jumper wires<\/a><\/li><li><a rel=\"noreferrer noopener\" href=\"https:\/\/makeradvisor.com\/tools\/mb-102-solderless-breadboard-830-points\/\" target=\"_blank\">Breadboard<\/a> <\/li><\/ul>\n\n\n<p>You can use the preceding links or go directly to <a href=\"https:\/\/makeradvisor.com\/tools\/?utm_source=rnt&utm_medium=post&utm_campaign=post\" target=\"_blank\">MakerAdvisor.com\/tools<\/a> to find all the parts for your projects at the best price!<\/p><p style=\"text-align:center;\"><a href=\"https:\/\/makeradvisor.com\/tools\/?utm_source=rnt&utm_medium=post&utm_campaign=post\" target=\"_blank\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/10\/header-200.png?w=1200&#038;quality=100&#038;strip=all&#038;ssl=1\"><\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Bluetooth Terminal Application<\/h2>\n\n\n\n<p>To proceed with this tutorial, you need a Bluetooth Terminal application installed in your smartphone.<\/p>\n\n\n\n<p>We recommend using the Android app \u201c<a href=\"https:\/\/play.google.com\/store\/apps\/details?id=de.kai_morich.serial_bluetooth_terminal&amp;hl=en\" target=\"_blank\" rel=\"noreferrer noopener\">Serial Bluetooth Terminal<\/a>\u201d available in the Play Store.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"500\" height=\"375\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/Bluetooth_Serial_app.png?resize=500%2C375&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"bluetooth serial application esp32\" class=\"wp-image-85082\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/Bluetooth_Serial_app.png?w=500&amp;quality=100&amp;strip=all&amp;ssl=1 500w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/Bluetooth_Serial_app.png?resize=300%2C225&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Serial to Serial Bluetooth<\/h2>\n\n\n\n<p>We\u2019ll program the ESP32 using Arduino IDE, so make sure you have the ESP32 add-on installed before proceeding:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong><a rel=\"noreferrer noopener\" href=\"https:\/\/randomnerdtutorials.com\/installing-the-esp32-board-in-arduino-ide-windows-instructions\/\" target=\"_blank\">Windows:<\/a><\/strong><a rel=\"noreferrer noopener\" href=\"https:\/\/randomnerdtutorials.com\/installing-the-esp32-board-in-arduino-ide-windows-instructions\/\" target=\"_blank\"> instructions \u2013 ESP32 Board in Arduino IDE<\/a><\/li><li><strong><a rel=\"noreferrer noopener\" href=\"https:\/\/randomnerdtutorials.com\/installing-the-esp32-board-in-arduino-ide-mac-and-linux-instructions\/\" target=\"_blank\">Mac and Linux: <\/a><\/strong><a rel=\"noreferrer noopener\" href=\"https:\/\/randomnerdtutorials.com\/installing-the-esp32-board-in-arduino-ide-mac-and-linux-instructions\/\" target=\"_blank\"> instructions \u2013 ESP32 Board in Arduino IDE<\/a><\/li><\/ul>\n\n\n\n<p>Open your Arduino IDE, and go to <strong>File <\/strong>&gt; <strong>Examples <\/strong>&gt; <strong>BluetoothSerial <\/strong>&gt; <strong>SerialtoSerialBT<\/strong>.<\/p>\n\n\n\n<p>The following code should load.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/\/This example code is in the Public Domain (or CC0 licensed, at your option.)\n\/\/By Evandro Copercini - 2018\n\/\/\n\/\/This example creates a bridge between Serial and Classical Bluetooth (SPP)\n\/\/and also demonstrate that SerialBT have the same functionalities of a normal Serial\n\n#include &quot;BluetoothSerial.h&quot;\n\n#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)\n#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it\n#endif\n\nBluetoothSerial SerialBT;\n\nvoid setup() {\n  Serial.begin(115200);\n  SerialBT.begin(&quot;ESP32test&quot;); \/\/Bluetooth device name\n  Serial.println(&quot;The device started, now you can pair it with bluetooth!&quot;);\n}\n\nvoid loop() {\n  if (Serial.available()) {\n    SerialBT.write(Serial.read());\n  }\n  if (SerialBT.available()) {\n    Serial.write(SerialBT.read());\n  }\n  delay(20);\n}\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/ESP32-Course\/raw\/master\/code\/Bluetooth_Classic_Example\/Bluetooth_Classic_Example.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How the Code Works<\/h3>\n\n\n\n<p>This code establishes a two-way serial Bluetooth communication between two devices.<\/p>\n\n\n\n<p>The code starts by including the <span class=\"rnthl rntliteral\">BluetoothSerial<\/span> library.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#include \"BluetoothSerial.h\"<\/code><\/pre>\n\n\n\n<p>The next three lines check if Bluetooth is properly enabled.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)\n#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it\n#endif<\/code><\/pre>\n\n\n\n<p>Then, create an instance of <span class=\"rnthl rntliteral\">BluetoothSerial<\/span> called <span class=\"rnthl rntliteral\">SerialBT<\/span>:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>BluetoothSerial SerialBT;<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">setup()<\/h4>\n\n\n\n<p>In the <span class=\"rnthl rntliteral\">setup()<\/span> initialize a serial communication at a baud rate of 115200.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>Serial.begin(115200);<\/code><\/pre>\n\n\n\n<p>Initialize the Bluetooth serial device and pass as an argument the Bluetooth Device name. By default it\u2019s called <strong><span class=\"rnthl rntliteral\">ESP32test<\/span><\/strong> but you can rename it and give it a unique name.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>SerialBT.begin(\"ESP32test\"); \/\/Bluetooth device name<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">loop()<\/h4>\n\n\n\n<p>In the <span class=\"rnthl rntliteral\">loop()<\/span>, send and receive data via Bluetooth Serial.<\/p>\n\n\n\n<p>In the first if statement, we check if there are bytes being received in the serial port. If there are, send that information via Bluetooth to the connected device.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>if (Serial.available()) {\n  SerialBT.write(Serial.read());\n}<\/code><\/pre>\n\n\n\n<p><span class=\"rnthl rntliteral\">SerialBT.write()<\/span> sends data using bluetooth serial.<\/p>\n\n\n\n<p><span class=\"rnthl rntliteral\">Serial.read()<\/span> returns the data received in the serial port.<\/p>\n\n\n\n<p>The next if statement, checks if there are bytes available to read in the Bluetooth Serial port. If there are, we\u2019ll write those bytes in the Serial Monitor.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>if (SerialBT.available()) {\n  Serial.write(SerialBT.read());\n}<\/code><\/pre>\n\n\n\n<p>It will be easier to understand exactly how this sketch works in the demonstration.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Testing the Code<\/h2>\n\n\n\n<p>Upload the previous code to the ESP32. Make sure you have the right board and COM port selected.<\/p>\n\n\n\n<p>After uploading the code, open the Serial Monitor at a baud rate of 115200. Press the ESP32 Enable button.<\/p>\n\n\n\n<p>After a few seconds, you should get a message saying: \u201c<em>The device started, now you can pair it with bluetooth!<\/em>\u201d.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"601\" height=\"333\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/device_started_bluetooth-esp32.png?resize=601%2C333&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Bluetooth Classic and Android Smartphone Demonstration\" class=\"wp-image-85083\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/device_started_bluetooth-esp32.png?w=601&amp;quality=100&amp;strip=all&amp;ssl=1 601w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/device_started_bluetooth-esp32.png?resize=300%2C166&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 601px) 100vw, 601px\" \/><\/figure><\/div>\n\n\n\n<p>Go to your smartphone and open the \u201c<strong>Serial Bluetooth Terminal<\/strong>\u201d app. Make sure you\u2019ve enable your smartphone\u2019s Bluetooth.<\/p>\n\n\n\n<p>To connect to the ESP32 for the first time, you need to pair a new device.<br>Go to&nbsp;<strong>Devices.<\/strong><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"500\" height=\"432\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/devices.png?resize=500%2C432&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Bluetooth Classic and Android Application Serial Bluetooth Terminal \" class=\"wp-image-85086\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/devices.png?w=500&amp;quality=100&amp;strip=all&amp;ssl=1 500w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/devices.png?resize=300%2C259&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/figure><\/div>\n\n\n\n<p>Click the settings icon, and select&nbsp;<strong>Pair new device<\/strong>. You should get a list with the available Bluetooth devices, including the <strong>ESP32test<\/strong>. Pair with the <strong>ESP32test<\/strong>.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"500\" height=\"367\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/pair-new-device-bluetooth-esp32.png?resize=500%2C367&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Bluetooth Classic and Android Application Serial Bluetooth Terminal Pair new device\" class=\"wp-image-85087\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/pair-new-device-bluetooth-esp32.png?w=500&amp;quality=100&amp;strip=all&amp;ssl=1 500w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/pair-new-device-bluetooth-esp32.png?resize=300%2C220&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/figure><\/div>\n\n\n\n<p>Then, go back to the Serial Bluetooth Terminal. Click the icon at the top to connect to the ESP32. You should get a \u201c<strong>Connected\u201d<\/strong> message.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"500\" height=\"529\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/connected-to-esp32.png?resize=500%2C529&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Bluetooth Classic and Android Application Serial Bluetooth Terminal connected\" class=\"wp-image-85090\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/connected-to-esp32.png?w=500&amp;quality=100&amp;strip=all&amp;ssl=1 500w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/connected-to-esp32.png?resize=284%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 284w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/figure><\/div>\n\n\n\n<p>After that, type something in the Serial Bluetooth Terminal app. For example, \u201c<strong>Hello<\/strong>\u201d.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"500\" height=\"331\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/send-hello-bluetooth-esp32.png?resize=500%2C331&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Bluetooth Classic and Android Application Serial Bluetooth Terminal Demonstration\" class=\"wp-image-85091\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/send-hello-bluetooth-esp32.png?w=500&amp;quality=100&amp;strip=all&amp;ssl=1 500w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/send-hello-bluetooth-esp32.png?resize=300%2C199&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/figure><\/div>\n\n\n\n<p>You should instantly receive that message in the Arduino IDE Serial Monitor.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"601\" height=\"333\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/hello-message-received-bluetooth.png?resize=601%2C333&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Bluetooth Classic demonstration serial monitor Arduino IDE\" class=\"wp-image-85092\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/hello-message-received-bluetooth.png?w=601&amp;quality=100&amp;strip=all&amp;ssl=1 601w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/hello-message-received-bluetooth.png?resize=300%2C166&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 601px) 100vw, 601px\" \/><\/figure><\/div>\n\n\n\n<p>You can also exchange data between your Serial Monitor and your smartphone. Type something in the Serial Monitor top bar and press the \u201c<strong>Send<\/strong>\u201d button.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"601\" height=\"333\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/send-message-via-bluetooth-1.png?resize=601%2C333&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Bluetooth Classic demonstration serial monitor Arduino IDE\" class=\"wp-image-85093\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/send-message-via-bluetooth-1.png?w=601&amp;quality=100&amp;strip=all&amp;ssl=1 601w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/send-message-via-bluetooth-1.png?resize=300%2C166&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 601px) 100vw, 601px\" \/><\/figure><\/div>\n\n\n\n<p>You should instantly receive that message in the Serial Bluetooth Terminal App.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"500\" height=\"353\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/receive-message-bluetooth-application-esp32.png?resize=500%2C353&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Bluetooth Classic and Android Application Serial Bluetooth Terminal Demonstration\" class=\"wp-image-85094\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/receive-message-bluetooth-application-esp32.png?w=500&amp;quality=100&amp;strip=all&amp;ssl=1 500w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/receive-message-bluetooth-application-esp32.png?resize=300%2C212&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Exchange Data using Bluetooth Serial<\/h2>\n\n\n\n<p>Now that you know how to exchange data using Bluetooth Serial, you can modify the previous sketch to make something useful. For example, control the ESP32 outputs when you receive a certain message, or send data to your smartphone like sensor readings.<\/p>\n\n\n\n<p>The project we\u2019ll build sends temperature readings every 10 seconds to your smartphone. We\u2019ll be using the <a href=\"https:\/\/randomnerdtutorials.com\/esp32-with-multiple-ds18b20-temperature-sensors\/\">DS18B20 temperature sensor<\/a>.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"431\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/dallas_temperature_sensor.jpg?resize=750%2C431&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ds18b20 temperature sensor\" class=\"wp-image-85095\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/dallas_temperature_sensor.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/dallas_temperature_sensor.jpg?resize=300%2C172&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n\n<p>Through the Android app, we\u2019ll send messages to control an ESP32 output. When the ESP32 receives the <span class=\"rnthl rntliteral\"><strong>led_on<\/strong><\/span> message, we\u2019ll turn the GPIO on, when it receives the <span class=\"rnthl rntliteral\"><strong>led_off<\/strong><\/span> message, we\u2019ll turn the GPIO off.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Schematic<\/h3>\n\n\n\n<p>Before proceeding with this project, assemble the circuit by following the next schematic diagram.<\/p>\n\n\n\n<p>Connect an LED to <span class=\"rnthl rntcblue\">GPIO25<\/span>, and connect the DS18B20 data pin to <span class=\"rnthl rntcyellow\">GPIO32<\/span>.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"760\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/bluetooth_classic_project_example-Copy.jpg?resize=750%2C760&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Bluetooth Classic ESP32 communication\" class=\"wp-image-85096\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/bluetooth_classic_project_example-Copy.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/bluetooth_classic_project_example-Copy.jpg?resize=296%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 296w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n\n<p><strong>Recommended reading:<\/strong><a href=\"https:\/\/randomnerdtutorials.com\/esp32-pinout-reference-gpios\/\"> ESP32 Pinout Reference: Which GPIO pins should you use?<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Code<\/h3>\n\n\n\n<p>To work with the DS18B20 temperature sensor, you need to install the\u00a0<a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/github.com\/PaulStoffregen\/OneWire\" target=\"_blank\">One Wire library by Paul Stoffregen<\/a> and the <a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/github.com\/milesburton\/Arduino-Temperature-Control-Library\" target=\"_blank\">Dallas Temperature library<\/a>. Follow the next instructions to install these libraries, if you haven\u2019t already.<\/p>\n\n\n\n<p><strong>One Wire library<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\"><li><a href=\"https:\/\/github.com\/PaulStoffregen\/OneWire\/archive\/master.zip\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">Click here to download the One Wire\u00a0library<\/a>. You should have a .zip folder in your Downloads<\/li><li>Unzip the\u00a0<em>.zip<\/em>\u00a0folder and you should get\u00a0<strong>OneWire-master\u00a0<\/strong>folder<\/li><li>Rename your folder from\u00a0<del><strong>OneWire-master<\/strong><\/del>\u00a0to<strong>\u00a0OneWire<\/strong><\/li><li>Move the\u00a0<strong>OneWire\u00a0<\/strong>folder to your Arduino IDE installation\u00a0<strong>libraries\u00a0<\/strong>folder<\/li><li>Finally, re-open your Arduino IDE<\/li><\/ol>\n\n\n\n<p><strong>Dallas Temperature library<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\"><li><a href=\"https:\/\/github.com\/milesburton\/Arduino-Temperature-Control-Library\/archive\/master.zip\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">Click here to download the Dallas Temperature\u00a0library<\/a>. You should have a .zip folder in your Downloads<\/li><li>Unzip the\u00a0<em>.zip<\/em>\u00a0folder and you should get\u00a0<strong>Arduino-Temperature-Control-Library-master\u00a0<\/strong>folder<\/li><li>Rename your folder from\u00a0<del><strong>Arduino-Temperature-Control-Library-master<\/strong><\/del>\u00a0to\u00a0<strong>DallasTemperature<\/strong><\/li><li>Move the\u00a0<strong>DallasTemperature<\/strong>folder to your Arduino IDE installation\u00a0<strong>libraries\u00a0<\/strong>folder<\/li><li>Finally, re-open your Arduino IDE<\/li><\/ol>\n\n\n\n<p>After assembling the circuit and installing the necessary libraries, copy the following sketch to your Arduino IDE.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/*********\n  Rui Santos\n  Complete project details at http:\/\/randomnerdtutorials.com\n*********\/\n\n\/\/ Load libraries\n#include &quot;BluetoothSerial.h&quot;\n#include &lt;OneWire.h&gt;\n#include &lt;DallasTemperature.h&gt;\n\n\/\/ Check if Bluetooth configs are enabled\n#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)\n#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it\n#endif\n\n\/\/ Bluetooth Serial object\nBluetoothSerial SerialBT;\n\n\/\/ GPIO where LED is connected to\nconst int ledPin =  25;\n\n\/\/ GPIO where the DS18B20 is connected to\nconst int oneWireBus = 32;          \n\/\/ Setup a oneWire instance to communicate with any OneWire devices\nOneWire oneWire(oneWireBus);\n\/\/ Pass our oneWire reference to Dallas Temperature sensor \nDallasTemperature sensors(&amp;oneWire);\n\n\/\/ Handle received and sent messages\nString message = &quot;&quot;;\nchar incomingChar;\nString temperatureString = &quot;&quot;;\n\n\/\/ Timer: auxiliar variables\nunsigned long previousMillis = 0;    \/\/ Stores last time temperature was published\nconst long interval = 10000;         \/\/ interval at which to publish sensor readings\n\nvoid setup() {\n  pinMode(ledPin, OUTPUT);\n  Serial.begin(115200);\n  \/\/ Bluetooth device name\n  SerialBT.begin(&quot;ESP32&quot;);\n  Serial.println(&quot;The device started, now you can pair it with bluetooth!&quot;);\n}\n\nvoid loop() {\n  unsigned long currentMillis = millis();\n  \/\/ Send temperature readings\n  if (currentMillis - previousMillis &gt;= interval){\n    previousMillis = currentMillis;\n    sensors.requestTemperatures(); \n    temperatureString = String(sensors.getTempCByIndex(0)) + &quot;C  &quot; +  String(sensors.getTempFByIndex(0)) + &quot;F&quot;;\n    SerialBT.println(temperatureString); \n  }\n  \/\/ Read received messages (LED control command)\n  if (SerialBT.available()){\n    char incomingChar = SerialBT.read();\n    if (incomingChar != '\\n'){\n      message += String(incomingChar);\n    }\n    else{\n      message = &quot;&quot;;\n    }\n    Serial.write(incomingChar);  \n  }\n  \/\/ Check received message and control output accordingly\n  if (message ==&quot;led_on&quot;){\n    digitalWrite(ledPin, HIGH);\n  }\n  else if (message ==&quot;led_off&quot;){\n    digitalWrite(ledPin, LOW);\n  }\n  delay(20);\n}\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/ESP32-Course\/raw\/master\/code\/Bluetooth_Classic_Project\/Bluetooth_Classic_Project.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How the Code Works<\/h3>\n\n\n\n<p>Let\u2019s take a quick look at the code and see how it works.<\/p>\n\n\n\n<p>Start by including the necessary libraries. The <span class=\"rnthl rntliteral\">BluetoothSerial<\/span> library for Bluetooth, and the <span class=\"rnthl rntliteral\">OneWire<\/span> and <span class=\"rnthl rntliteral\">DallasTemperature<\/span> for the DS18B20 temperature sensor.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#include \"BluetoothSerial.h\"\n#include &lt;OneWire.h>\n#include &lt;DallasTemperature.h><\/code><\/pre>\n\n\n\n<p>Create a <span class=\"rnthl rntliteral\">BluetoothSerial<\/span> instance called <span class=\"rnthl rntliteral\">SerialBT<\/span>.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>BluetoothSerial SerialBT;<\/code><\/pre>\n\n\n\n<p>Create a variable called <span class=\"rnthl rntliteral\">ledPin<\/span> to hold the GPIO you want to control. In this case, <span class=\"rnthl rntcblue\">GPIO25<\/span> has an LED connected.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>const int ledPin =  25;<\/code><\/pre>\n\n\n\n<p>Define the DS18B20 sensor pin and create objects to make it work. The temperature sensor is connected to <span class=\"rnthl rntcyellow\">GPIO32<\/span>.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>\/\/ GPIO where the DS18B20 is connected to\nconst int oneWireBus = 32;          \n\/\/ Setup a oneWire instance to communicate with any OneWire devices\nOneWire oneWire(oneWireBus);\n\/\/ Pass our oneWire reference to Dallas Temperature sensor \nDallasTemperature sensors(&amp;oneWire);<\/code><\/pre>\n\n\n\n<p>Create an empty string called <span class=\"rnthl rntliteral\">message<\/span> to store the received messages.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>String message = \"\";<\/code><\/pre>\n\n\n\n<p>Create a char variable called <span class=\"rnthl rntliteral\">incomingChar<\/span> to save the characters coming via Bluetooth Serial.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>char incomingChar;<\/code><\/pre>\n\n\n\n<p>The <span class=\"rnthl rntliteral\">temperatureString<\/span> variable holds the temperature readings to be sent via Bluetooth.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>String temperatureString = \"\";<\/code><\/pre>\n\n\n\n<p>Create auxiliar timer variables to send readings every 10 seconds.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>unsigned long previousMillis = 0;   \/\/ Stores last time temperature was published\nconst long interval = 10000;        \/\/ interval at which to publish sensor readings<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">setup()<\/h4>\n\n\n\n<p>In the <span class=\"rnthl rntliteral\">setup()<\/span>, set the <span class=\"rnthl rntliteral\">ledPin<\/span> as an output.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>pinMode(ledPin, OUTPUT);<\/code><\/pre>\n\n\n\n<p>Initialize the ESP32 as a bluetooth device with the \u201cESP32\u201d name.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>SerialBT.begin(\"ESP32\"); \/\/Bluetooth device name <\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">loop()<\/h4>\n\n\n\n<p>In the&nbsp;<span class=\"rnthl rntliteral\">loop()<\/span>, send the temperature readings, read the received messages and execute actions accordingly.<\/p>\n\n\n\n<p>The following snippet of code, checks if 10 seconds have passed since the last reading. If it\u2019s time to send a new reading, we get the latest temperature and save it in Celsius and Fahrenheit in the <span class=\"rnthl rntliteral\">temperatureString<\/span> variable.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>unsigned long currentMillis = millis();\nif (currentMillis - previousMillis >= interval) {\n    previousMillis = currentMillis;\n    sensors.requestTemperatures(); \n    temperatureString = \" \" + String(sensors.getTempCByIndex(0)) + \"C  \" +  String(sensors.getTempFByIndex(0)) + \"F\";<\/code><\/pre>\n\n\n\n<p>Then, to send the <span class=\"rnthl rntliteral\">temperatureString<\/span> via bluetooth, use <span class=\"rnthl rntliteral\">SerialBT.println()<\/span>.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>SerialBT.println(temperatureString);  <\/code><\/pre>\n\n\n\n<p>The next if statement reads incoming messages. When you receive messages via serial, you receive a character at a time. You know that the message ended, when you receive <span class=\"rnthl rntliteral\"><strong>\\n<\/strong><\/span>.<\/p>\n\n\n\n<p>So, we check if there\u2019s data available in the Bluetooth serial port.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>if (SerialBT.available()) {<\/code><\/pre>\n\n\n\n<p>If there is, we\u2019ll save the characters in the <span class=\"rnthl rntliteral\">incomingChar<\/span> variable.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>char incomingChar = SerialBT.read();<\/code><\/pre>\n\n\n\n<p>If the <span class=\"rnthl rntliteral\">incomingChar<\/span> is different than <span class=\"rnthl rntliteral\">\\n<\/span>, we\u2019ll concatenate that char character to our message.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>if (incomingChar!= '\\n'){\n  message += String(incomingChar);\n}<\/code><\/pre>\n\n\n\n<p>When we\u2019re finished reading the characters, we clear the <span class=\"rnthl rntliteral\">message<\/span> variable. Otherwise all received messages would be appended to each other.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>message = \"\";<\/code><\/pre>\n\n\n\n<p>After that, we have two if statements to check the content of the message. If the message is <span class=\"rnthl rntliteral\"><strong>led_on<\/strong><\/span>, the LED turns on.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>if (message ==\"led_on\"){\n   digitalWrite(ledPin, HIGH);\n}<\/code><\/pre>\n\n\n\n<p>If the message is <span class=\"rnthl rntliteral\"><strong>led_off<\/strong><\/span>, the LED turns off.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>else if (message ==\"led_off\"){\n  digitalWrite(ledPin, LOW);\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Testing the Project<\/h2>\n\n\n\n<p>Upload the previous sketch to your ESP32 board. Then, open the Serial Monitor, and press the ESP32 Enable button. When you receive the following message, you can go to your smartphone and connect with the ESP32.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"601\" height=\"333\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/device_started_bluetooth-esp32-1.png?resize=601%2C333&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Testing ESP32 Bluetooth Classic Project Code Example\" class=\"wp-image-85097\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/device_started_bluetooth-esp32-1.png?w=601&amp;quality=100&amp;strip=all&amp;ssl=1 601w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/device_started_bluetooth-esp32-1.png?resize=300%2C166&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 601px) 100vw, 601px\" \/><\/figure><\/div>\n\n\n\n<p>Then, you can write the<strong>\u201cled_on\u201d<\/strong>&nbsp;and&nbsp;<strong>\u201cled_off\u201d&nbsp;<\/strong>messages to control the LED.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"421\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/control-led-on.jpg?resize=750%2C421&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Testing ESP32 Bluetooth Classic Project Code Example\" class=\"wp-image-85098\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/control-led-on.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/control-led-on.jpg?resize=300%2C168&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n\n<p>The application has several buttons in which you can save default messages. For example, you can associate&nbsp;<strong>M1&nbsp;<\/strong>with the \u201c<strong>led_on<\/strong>\u201d message, and&nbsp;<strong>M2&nbsp;<\/strong>with the \u201c<strong>led_off<\/strong>\u201d message.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"500\" height=\"567\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/default-messages.png?resize=500%2C567&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-85099\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/default-messages.png?w=500&amp;quality=100&amp;strip=all&amp;ssl=1 500w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/default-messages.png?resize=265%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 265w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/figure><\/div>\n\n\n\n<p>Now, you are able to control the ESP32 GPIOs.<\/p>\n\n\n\n<p>At the same time, you should be receiving the temperature readings every 10 seconds.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"421\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/bluetooth-receive-sensor-readings-esp32.jpg?resize=750%2C421&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-85100\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/bluetooth-receive-sensor-readings-esp32.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/bluetooth-receive-sensor-readings-esp32.jpg?resize=300%2C168&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Wrapping Up<\/h2>\n\n\n\n<p>In summary, the ESP32 supports BLE and Bluetooth Classic. Using Bluetooth Classic is as simple as using serial communication and its functions.<\/p>\n\n\n\n<p>If you want to learn how to use BLE with the ESP32, you can read our guide:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-bluetooth-low-energy-ble-arduino-ide\/\">Getting Started with ESP32 Bluetooth Low Energy (BLE) on Arduino IDE<\/a><\/li><\/ul>\n\n\n\n<p>We hope you\u2019ve found this tutorial useful. For more projects with the ESP32 you can check our project\u2019s compilation: <a href=\"https:\/\/randomnerdtutorials.com\/projects-esp32\/\">20+ ESP32 Projects and Tutorials<\/a>. <\/p>\n\n\n\n<p class=\"rntbox rntclgray\">This tutorial is a preview of the \u201c<a href=\"https:\/\/randomnerdtutorials.com\/learn-esp32-with-arduino-ide\/\">Learn ESP32 with Arduino IDE<\/a>\u201d course. If you like this project, make sure you take a look at the&nbsp;<a href=\"https:\/\/randomnerdtutorials.com\/learn-esp32-with-arduino-ide\/\">ESP32 course page<\/a>&nbsp;where we cover this and a lot more topics with the ESP32. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>The ESP32 comes with Wi-Fi, Bluetooth Low Energy and Bluetooth Classic. In this tutorial, you&#8217;ll learn how to use ESP32 Bluetooth Classic with Arduino IDE to exchange data between an &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"ESP32 Bluetooth Classic with Arduino IDE &#8211; Getting Started\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/esp32-bluetooth-classic-arduino-ide\/#more-85076\" aria-label=\"Read more about ESP32 Bluetooth Classic with Arduino IDE &#8211; Getting Started\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":5,"featured_media":85219,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[281,299,264],"tags":[],"class_list":["post-85076","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-esp32-project","category-0-esp32","category-project"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/05\/ESP32-Bluetooth-Classic-Arduino-IDE-BT.jpg?fit=1280%2C720&quality=100&strip=all&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/85076","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/comments?post=85076"}],"version-history":[{"count":0,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/85076\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/85219"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=85076"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=85076"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=85076"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}