The ESP32 processor allows the integration of Wi-Fi, Bluetooth, and Bluetooth LE (BLE) for a wide range of IoT (Internet of Things) applications. Using Wi-Fi ensures connectivity within a large radius. At the same time, Bluetooth allows the user to easily detect (with low-energy beacons) a module and connect it to an Android/iOS smartphone or tablet. The board adds priceless functionality and versatility to your applications.
In this post, we will explore the development of a Bluetooth to USB gateway. However, the word "development" seems ridiculous when you look at that amazingly concise Arduino sketch below. Nevertheless, it proves the great potential of using the ESP32 in combination with the Arduino IDE, i.e., simple code with incredible functionality.
For the test hardware I used the ESP32-WROOM-32 development board. The same program also runs on our ESP32-CAN Bus Development board. As a matter of fact, we are using a more sophisticated form of that sketch in our CAN to Bluetooth gateway.
Unless you have already done so, before working with the ESP32 using the Arduino IDE, you need to install a few components. For more information, see:
Before I started getting my feet wet using Bluetooth, I did my research by working through numerous online resources. All these posts described working solutions, but I was glad I chose a book, Electronics Projects with the ESP8266 and ESP32, as described below.
I like that all projects are more or less isolated, so that developers can focus on their specific needs. Developing my Bluetooth and BLE (Bluetooth Low Energy) applications went fast and without headaches. The Author explains the hardware aspects in detail without being overwhelming. Also helpful are the numerous references to testing tools.
Electronics Projects with the ESP8266 and ESP32: Building Web Pages, Applications, and WiFi Enabled Devices
Copperhill Technologies highly recommends using this book for your wireless application projects. Yes, many good books and free online resources are available these days, but this is the book we are using. It made our approach to Bluetooth, BLE, and WIFI a breeze. Programming wireless applications without hassles was fun, and we will share them on this web page.
Projects throughout the book utilize the wireless functionality and processing power of the ESP microcontrollers. Projects are built in the Arduino IDE, so you don't need to download other programming software. In addition, mobile apps are now ubiquitous, making the app build projects of the book very relevant, as are the web page design projects.
In Electronics Projects with the ESP8266 and ESP32, you'll see how easy and practical it is to access information over the internet, develop web pages, build mobile apps to remotely control devices with speech recognition, or incorporate Google Maps in a GPS route tracking app. More Information...
The original code for the Bluetooth to USB gateway application is available at:
I took, however, the liberty of optimizing the code and thus increasing the performance (i.e., transmission time between the two ports).
The image below shows the optimized sketch. It is so short that I didn't even bother putting it up for download.
In short, the program reads the serial data from one port and passes it to the other. Before I continue, let me add some references on how to connect to Bluetooth:
Connecting Bluetooth to a Windows PC
Connecting Bluetooth to an Android Device
Testing under Windows
First of all, after pairing the ESP32 with Windows, you need to determine the associated port number. The following screen shot shows my Windows 10 machine's Bluetooth section:
The paired ESP32 Bluetooth connection is marked in red. In order to determine the COM port number, click on "More Bluetooth options (marked in green.
Under the COM Ports section, you will find some entries similar to my setup. Have a look at the Outgoing port associated with the ESP32 Bluetooth device ID. In the above example, the COM port number is 22.
In the following, we 'll use the Arduino IDE Serial Monitor to display the information received by the ESP32 board. On the Windows PC side, I am using RealTerm, a free terminal software. In the RealTerm software, I set the port number to 22. Under the Send tab, I entered a sample ASCII string and clicked on "Send ASCII":
The Arduino Serial Monitor displays the data as received:
In the Serial Monitor, I entered another ASCII string and hit "Send":
This sequence successfully tests the connection, and now you can go ahead and add more code.
In the meantime, I will follow up with a similar application based on BLE.
Due to the global shortage of electronic components, we at Copperhill Technologies began rethinking our strategy regarding new developments. Luckily, that change turned out to be a blessing in disguise because the transition from NXP LPC to the ESP32 processor opened the door to more industrial and automotive applications, especially those involving wireless transmissions for [...]
Kontron announced the release of their Pi-Tron CM4 computer with Linux OS, which utilizes the fourth-generation Raspberry Pi compute module with the 1,5-GHz, 64-bit Broadcom BCM2711 chip and four Arm Cortex-A72 processors. The computer’s steel housing allows for universal use, e.g., for automation and IoT (Internet of Things) applications. Depending on the variant, it provides a 1-GiB, 2-GB, [...]
The integration of Wi-Fi, Bluetooth, and Bluetooth LE allow a wide range of applications with ESP32 modules. Using Wi-Fi ensures connectivity within a large radius, while using Bluetooth allows the user to easily detect (with low-energy beacons) a module and connect it to a smartphone. The chips add priceless functionality and versatility to your applications [...]
Arduino Portenta H7 - Dual-Core STM32 Processor Board with Two CAN FD Ports and Support for Arduino IoT Cloud
The Portenta H7's central processor is represented by the dual-core STM32H747, including a Cortex M7 at 480 MHz and a Cortex M4 at 240 MHz. The two cores intercommunicate through a Remote Procedure Call mechanism that seamlessly enables calling functions on the other processor. Both processors share on-chip peripherals and can run Arduino Sketches on the Arm [...]
This post will demonstrate how to add a CAN Bus port to the ESP32-WROOM32 development board, i.e., regarding hardware and software. Download this post as PDF... As a matter of fact, we already offer a hardware utilizing the ESP32 processor and an onboard CAN Bus transceiver as shown in the image to the left. The ESP32 WiFi, Bluetooth [...]
The ESP32 represents a low-cost, low-power System-on-Chip (SoC) microcontroller with integrated Wi-Fi and dual-mode Bluetooth. The ESP32 series utilizes either a Tensilica Xtensa LX6 microprocessor in dual-core and single-core variations, Xtensa LX7 dual-core microprocessor, or a single-core RISC-V microprocessor and includes built-in antenna switches, RF balun, power amplifier, low-noise receive amplifier, filters, and power management [...]
It was just a few weeks ago that I received some bad news. Due to the worldwide shortage of electronic components, the NXP LPC1754 processor we use for our SAE J1939 ECU Simulator with USB Port will not be available for several months, maybe even well into 2022. Consequently, it was time to rethink the design, and [...]
Phytools announced adding a new suite of products to their portfolio of industrial networking solutions. The Teltonika Networks product line incorporates dependable, secure, and easy-to-use cellular 4G LTE mobile routers, gateways, and switches for industrial, enterprise, IoT, and M2M applications. The RUT240 is one of the most popular industrial 4G LTE WiFi routers for professional M2M and [...]
The ESP32 Series of modules by Espressif supports the integration of WiFi, Bluetooth, and Bluetooth LE for a wide range of applications, most prominently for IoT (Internet of Things). For instance, using WiFi ensures connectivity within a large radius. Using Bluetooth allows the user to easily detect (with low-energy beacons) a module and connect it to [...]