Skip to content

Introduction

The SparkFun BlueSMiRF v2 is a wireless Bluetooth® serial link. This version of the popular BlueSMiRF uses the ESP32. These boards work as a wireless serial UART pipe and are a great wireless replacement for serial cables. Simply pair, connect, and transmit serial data between your TX/RX lines! Any serial stream from 2400 to 921600 baud can be passed seamlessly between two devices.

In this tutorial, we'll go over the hardware and how to hookup the breakout board. We will also go over how to connect to a smartphone and a basic Arduino example to get started!

Required Materials

To follow along with this tutorial, you will need the following materials. You may not need everything though depending on what you have. Add it to your cart, read through the guide, and adjust the cart as necessary. We recommend the board with headers to minimize the amount of soldering to your application.

Tools  (Optional)

You will need a soldering iron, solder, and general soldering accessories for a secure connection when using the plated through holes. You may also need to solder headers or wires to any devices that the BlueSMiRF v2 is connecting to.

Prototyping Accessories  (Optional)

For those using the PTH version, you will need to connect to the PTHs. You could use IC hooks and a breadboard for a temporary connection depending on your setup and what you have available. Of course, you will want to the solder header pins for a secure connection. We'll assume that you will want to solder a female header since there is already a BlueSMiRF v2 with the male headers available. Then again, you can still solder wire or even your own male headers if you prefer. Below are a few prototyping accessories that you may want to consider.

You Will Also Need

Depending on your setup or what you are doing, you may need the following as well.

  • 2.4GHz WiFi Network for firmware updates
  • Smartphone with an Internet Service

Suggested Reading

If you aren’t familiar with the following concepts, we also recommend checking out a few of these tutorials before continuing.

Old School to New School

Before we go over the hardware though, let's compare previous SparkFun BlueSMiRF versions with the BlueSMiRF v2!

Back in April 2005, we originally released the BlueSMiRF v1 (short for Bluetooth Serial Miniature RF Link version 1) with BlueRadio's WML-C40AH. They came in two flavors: one with 4-pins for the basic BlueSMiRF consisting of PWR/GND/TX-O/RX-I, and the other with 6-pins for the extended BlueSMiRF consisting of RTS/RX-I/TX-O/GND/PWR/CTS. Over the years, the extended 1x6 pin became the "standard" for the BlueSMiRF.

Basic BlueSMiRF Extended BlueSMiRF
Basic BlueSMiRF Extended BlueSMiRF

We even saw changes in the Bluetooth modems! The BlueRadio's WML-C40AH modems eventually switched over to Roving Network's RN-41 and RN-42. Each version had different ranges and transmit power.

BlueSMiRF Gold (RN-42) BlueSMiRF Silver (RN-41)
BlueSMiRF Gold (RN-42) BlueSMiRF Silver (RN-41)

The 1x6 pins also were rearranged for the SparkFun Bluetooth Mates similar to the USB-to-Serial Converters.

Header BlueSMiRF & Bluetooth Mate
Back of Bluetooth Mate and BlueSMiRF

Fast forward to January 2024 (my how time flies!), the BlueSMiRFs v2 is brought back to life! So what's different from the previous versions? Well, the differences to note with the BlueSMiRF v2 include:

  • ESP32-PICO-MINI-02 module
  • firmware can be easily updated Over-the-Air or through a command line interface
  • the pinout matches the previous Bluetooth Mates and standard USB-to-serial converters: RTS/RXI/TXO/VCC/CTS/GND
  • labels included on both sides of the board instead of just the bottom
  • multi-use button for setting the board in bootloader mode, pairing, and factory reset instead of a PTH PIO4 for factory reset
  • jumper to disable the button
  • CTS/RTS jumper was removed
  • APA2112K 3.3V, 600mA voltage regulator instead of the MIC5205 3.3V, 150mA
  • a bypass jumper for the voltage regulator was added
  • size is slightly smaller measuring 38.1mm x 15.2mm

Hardware Overview

In this section, we will highlight the hardware and pins that are broken out on the SparkFun BlueSMiRF v2. For the scope of the tutorial, we will be referring to the version with the headers.

SMD with Headers, Top View SMD with Headers, Bottom View
SMD with Headers, Top View SMD with Headers, Bottom View

There is also a version with PTHs out in the wild and it is essentially the same. The only differences are that the pins are broken out to PTHs instead of a SMD right angle male header and the silkscreen labels.

PTH Version, Top View PTH Version, Bottom View
PTH Version, Top View PTH Version, Bottom View

For more information, check out our Resources and Going Further for the board designs and the ESP32.

ESP32-PICO-MINI-02

The board includes the smaller ESP32-PICO-MINI-02 module from Espressif. The SparkFun BlueSMiRF v2 is perfect for short range applications that require point-to-point communication. We've written some firmware to allow serial UART data to be sent between two Bluetooth devices. The supported protocols include SPP and BLE. Testing a pair of BlueSMiRF v2s and we got about ~110 feet (~33m) in the SparkFun building. The TX (10k) and RX (50k) buffers are also very large to allow for radio delays. The included firmware also includes a set of AT commands to configure the ESP32. This includes the baud rate, flow control, LED mode, and Over-The-Air (OTA) updates over a 2.4GHz WiFi network to name a few. You can also manually reprogram the ESP32 module using the command line interface as well! Just make sure to connect Tx and Rx between the BlueSMiRF and a USB-to-serial converter.

ESP32-PICO-MINI-02 Module Highlighted

Power

Power is broken out on the 1x6 header through the VCC and GND pins. The recommended input voltage can be between 3.3V to 5V. Logic level shifting circuitry is included on the TX and RX pins so that they are 3.3V to 5V tolerant.

  • VCC / 3V3-5V — On the top of the board, the input voltage is labeled as VCC. On the back of the board, this is labeled as 3V3-5V. Voltage is regulated down with the AP2112K 3.3V/600mA voltage regulator from this pin. Typically, one would apply either 3.3V or 5V to this pin. Make sure that power you provide to this pin does not exceed 6 volts. For advanced users, you can bypass this voltage regulator by adding a solder blob on the jumper labeled as JP2. Be careful as the input voltage range is smaller and you may run the risk of damaging the ESP32.
  • GND — Of course, is the common, ground voltage (0V reference) for the system.
Power Highlighted, Top View Power Highlighted, Bottom View
Power, Top View Power, Bottom View

The current and power consumption depends on what it's doing at the time. Here are some of our results after measuring the current and power consumption at 3.3V. The module can get toasty when pushing serial traffic through but not scary-burn-you-hot.

  • Idle: 72mA / 238mW
  • Connected with no Serial Traffic: 75mA / 248mW
  • Constant Duplex Serial Traffic: 140mA / 462mW

Note

There are also test points on the back of the board that are not labeled for VCC and GND. These are not labeled and are used by SparkFun's production for testing & programming the board using test beds.

Reset

The reset PTH labeled as RST will restart the ESP32 whenever the pin is grounded.

Reset Highlighted, Top View Reset Highlighted, Bottom View
Reset, Top View Reset, Bottom View

Serial UART Port

Note

As stated in the previous section, the pinout of the BlueSMiRF v2 is different from previous BlueSMiRFs, hence the version 2. Besides the ESP32 module, the pinout has the same pinout as previous Bluetooth Mates and USB-to-serial converters (i.e. FTDI, CH340, etc.). The board is meant to connect directly with an Arduino Pro, Pro Mini, RTCM Correction Ports on high precision GNSS breakout boards, or any board with a standard serial-to-USB port. Below is the back of the Bluetooth Mate, BlueSMiRF, and BlueSMiRF v2 boards.

Back of Bluetooth Mate, BlueSMiRF, and BlueSMiRF v2
Back of Bluetooth Mate, BlueSMiRF, and BlueSMiRF v2

Both boards include a standard serial UART header seen on many USB-to-serial converters: RTS/RXI/TXO/VCC/CTS/GND. Depending on the version that you purchase, one will be PTH while the other includes right angle male headers. Due to spacing, the PTH version will also have slightly different silkscreen labels.

  • RTS / RT — The Ready to Send is an output and is used for hardware flow control in some serial interfaces. This output is not critical for simple serial communication. If flow control is enabled, BlueSMiRF will drive its RTS low if its serial buffer is full (the radio is telling the host system to hold its horses).
  • RXI / RI — The serial receive is an input. This input pin receives serial data from another serial device. Logic level circuitry is included on this pin. It should be connected to the TX of the other device.
  • TXO / TO — The serial transmit is an output. This output pin sends serial data to another device. Logic level circuitry is included on this pin. It should be connected to the RX of the other device.
  • VCC/ V / 3V3-5V — This input voltage supply signal is routed through a AP2112K voltage regulator and brought down 3.3V for the ESP32. We will assume that it is attached to another device's standard serial port and it is providing power to the BlueSMiRF v2. As stated earlier, the recommended input voltage is between 3.3V to 5V.
  • CTS / CT — The Clear to Send is an input. CTS is another serial flow control signal. Like RTS, it's not required for most, simple serial interfaces. If flow control is enabled, BlueSMiRF will send data when its CTS pin is driven low (the host system is telling the radio that it's ready for more serial data).
  • GND / G — The 0V reference voltage, common to any other device connected to the Bluetooth modem.
Serial Header Highlighted, Top View Serial Header Highlighted, Bottom View
Serial Header, Top View Serial Header, Bottom View
PTH Serial Header Highlighted, Top View PTH Serial Header Highlighted, Bottom View
PTH Serial Header, Top View PTH Serial Header, Bottom View

Tip

For those that are connecting to the old school RS232 serial port, you will need a RS232 to TTL converter for higher voltages. The RS232 to TTL converter can handle larger voltages designed for RS232.

Button

The PAIR button is more than meets the eye. This button has more than one function depending on how long it is pushed down.

  • Short Push — Press and hold the button down between 4 to 8 seconds will initiate pairing with another Bluetooth device. During that period of time, the Status and Connect LEDs will slowly blink back and forth. When the BlueSMiRF v2 fails to discover any compatible devices, it will enter Discoverable mode.
  • Long Push — Press and hold the down for more than 8 seconds to set the ESP32 back to its factory default settings.
Pair Button Highlighted

Note

Users can also set the BlueSMiRF v2 in bootloader mode. In this mode, you can update the firmware manually through serial using a command line interface. Users will need to hold down the PAIR button when the BlueSMiRF v2 is not powered. Applying power will put the microcontroller into bootloader mode.

For more information about using the button for each mode, check out the section about the button control.

LEDs

The board includes the following status LEDs as indicated in the image below.

  • CONNECT — The connect LED indicates when the ESP32 is connected to another Bluetooth device. The behavior of the LED will depend on the mode:
    • 0 — By default, the CONNECT LED will blink until it is connect to another Bluetooth device. Once connected, this LED will remain solid.
    • 1 — When set to a 1, the CONNECT LED will blink until it is connected to another Bluetooth device. Once connected, this LED will blink with TX traffic.
  • STATUS — The status LED indicates when there is UART traffic. The behavior of the LED will depend on the mode.
    • 0 — By default, the STATUS LED blinks with any TX/RX traffic.
    • 1 — When set to a 1, the STATUS LED blinks with only the RX traffic.
LEDs Highlighted

The LEDs can also blink at different rates, fade, or become dim when the PAIR button is held down. This is used as an indicator to tell when we are entering pairing, factory reset, or bootloader mode. For more information, check out the section about the button control.

Jumpers

Note

If this is your first time working with jumpers, check out the How to Work with Jumper Pads and PCB Traces tutorial for more information.

The board includes the following jumpers on the top and bottom of the board.

  • JP2 — Jumper pad 2 is open by default. This jumper is used to bypass the 3.3V voltage regulator. Add a solder blob to close the jumper to connect VCC to 3.3V.
  • BTN — The button jumper are closed by default. This connects the pair button to GPIO pin 0. Cut this jumper to disable the button.
Jumpers Highlighted, Top View Jumpers Highlighted, Bottom View
Jumpers, Top View Jumpers, Bottom View

3D Model

A 3D model of the SparkFun BlueSMiRF v2 SMD and components was exported to STEP file using KiCad.


A 3D model of the SparkFun BlueSMiRF v2 PTH and components was also exported to STEP file using KiCad.


Board Dimensions

Each version of the board is 38.1mm x 15.2mm. Note that the version with the headers makes the board slightly longer by making the overall length 44.2mm. Adding a row of female 1x6 headers or jumper wires will increase the length slightly as well. There are no mounting holes for standoffs on the boards.

Board Dimensions for PTH, without headers Board Dimensions for SMD with Headers
Board Dimensions for PTH, without Headers Board Dimensions for SMD with Headers

Hardware Hookup

In this section, we'll go over how to connect to the BlueSMiRF v2.

Connecting via BlueSMiRF v2 PTH

For a temporary connection to the PTH BlueSMiRF v2, you could use IC hooks to test out the pins. However, you'll need to solder headers or wires of your choice to the board for a secure connection. You can choose between a combination of header pins and jumper wires, or stripping wire and soldering the wire directly to the board.

Basic Serial UART Connection

At a minimum, you will need to connect serial TX, serial RX, power, and ground for a basic serial UART connection. This connection is needed to send serial data between the two UART devices, configure settings, or even manually upload binaries to the ESP32. Between each serial device, always make sure to cross the RX and TX lines between serial devices (i.e. RX-to-TX and TX-to-RX). The table indicates below shows color cells being the same for the TXO-to-RXI and RXI-to-TXO. Note that the order of the pins may be different depending on the design, so you may not be able to make a direct connection with the BlueSMiRF v2's 1x6 header.

Serial Device
Pinout
BlueSMiRF v2
Pinout
TXO RXI
RXI TXO
3V3 VCC
GND GND

Note

In some cases, you may only need to just wire one serial wire from your serial device to the BlueSMiRF.

USB-to-Serial Converter to BlueSMiRF v2

Depending on the USB-to-serial converter that you choose, you may need to install drivers. If you've never connected an FTDI or CH340 to your computer before, you may need to install drivers for the USB-to-serial converter. Check out our How to Install FTDI Drivers or How to Install CH340 Drivers tutorial for help with the installation.

To make a connection to a USB-to-serial converter, you will need a basic serial connection. There are several converters available such as the FT232 or CH340. Each of these boards include a different USB connector. You will need to manually wire them up using jumper wires as shown in the table and image below.

USB-to-Serial Converter
Pinout
Intermediate Wire Connection BlueSMiRF v2
Pinout
DTR RTS
RXI RXI
TXO TXO
3V3 VCC
CTS CTS
GND GND

Note

The connection also includes two additional connection for flow control: RTS and CTS. These two connections are not needed for a basic serial UART connection. However, using all six wires can help make a tighter connection on the 1x6 header. The wire colors also connect TXO-to-RXI and RXI-to-TXO to indicate that it is not a direct connection between the two boards and the 1x6 header.

Below is one example between the serial basic breakout (CH340, USB-C) and the BlueSMiRF v2 Header. Male to female jumper wires were connected between the boards.

USB-to-Serial Converter (CH340) to BlueSMiRF v2 Header with TX-to-RX and RX-to-TX
USB-to-Serial Converter (CH340) to BlueSMiRF v2 Header with TX-to-RX and RX-to-TX

Adding a simple 1x6 stackable header between the jumper wires will make a quick adapter with the M/F jumper wires and USB-to-serial converter. You'll just need to match the DTR and GND pins. This is useful for those that need to constantly configure the BlueSMiRF v2's settings and re-reconnect to a USB-to-serial converter.

USB-to-Serial Converter (CH340) to BlueSMiRF v2 Header with an Additional Stackable Header
USB-to-Serial Converter (CH340) to BlueSMiRF v2 Header with an Additional Stackable Header

Tip

To make it easier to connect visually, try adding a polarity marker with whiteout, Sharpie, or paint. You can even try rotating one of the jumper wires so that the metal tabs is not facing the same direction on one or both ends.

Remember, for those that are using the PTH version, you will need to solder either male headers, female headers, or wires. The type of header or wire will depend on your personal preference and project needs. In this case, we used a 1x6 female header to the board. At the time of writing, there were only female to male jumper wires available so extra long headers were placed between the female header pins. The male header was connected to another serial basic (CH340).

USB-to-Serial Converter (CH340) to BlueSMiRF v2 PTH
USB-to-Serial Converter (CH340) to BlueSMiRF v2 PTH

BlueSMiRF v2 to Standard Serial UART Port

For boards that already include the footprint for a standard serial UART port, you can connect directly to the pins. You will find these on a few Arduino development boards. The Arduino Pro, Arduino Pro Mini, and LilyPad Arduino 328 Main Board are just a few boards that have the standard port. You will also notice certain boards will have the standard serial UART port labeled as the RTCM Correction Port on SparkFun high precision GNSS breakout boards. For certain boards that have a male header soldered, you may need to consider soldering a 1x6 female header on the BlueSMiRF v2 PTH.

BlueSMiRF v2 Replacing Serial Connection on the Arduino Pro Mini 3.3V Serial Header Port RedBoard IoT Development Board ESP32 Connected to the ZED-F9P with the BlueSMiRF v2 Connected to the ZED-F9P's RTCM Correction Port High Precision GNSS UM980 with the BlueSMiRF v2 Connected to the UM980's RTCM Correction Port
BlueSMiRF v2 Replacing Serial Connection on the Arduino Pro Mini 3.3V Serial Header Port BlueSMiRF v2 Connected to the ZED-F9P's RTCM Correction Port UM980 with the BlueSMiRF v2 Connected to the UM980's RTCM Correction Port

Note

There are older boards that may have a serial port labeled as BlueSMiRF. You will need to wire the connection manually with jumper wires. One example is the SparkFun Arduino ProtoShield where the board uses the older BlueSMiRF pinout. There are jumpers that you can cut on the board and additional PTHs to rewire the pins if you decide to connect directly to the 1x6 header.

SparkFun Arduino ProtoShield Serial Port Highlighted
SparkFun Arduino ProtoShield Serial Port Highlighted

AT Command Reference

Each BlueSMiRF v2 firmware comes with a set of AT commands to read or change the configuration. The following set of AT commands are similar to previous BlueSMiRF AT commands. Let's go over some of these commands!

AT Commands

Note

Command mode cannot be entered 60 seconds after power-on or resetting. This setting can be configured with the command AT-MaxCommandTimeMs.

BlueSMiRF radios are very flexible. By default, the radio is looking for serial communication at 115200 bps. Open the terminal of your choice. Then enter $$$ and wait for an OK. Both the CONNECT and STATUS LEDs will fade in and fade out whenever the board is in Command Mode. At this point, the radio is now ready for an AT command.

BlueSMiRF v2 Connected to Serial Terminal and in Command Mode
BlueSMiRF v2 Connected to Serial Terminal and in Command Mode

Note

Depending on your serial terminal's settings, you may not see the characters that are being sent. You can try turning on the local echo to view the characters. However, keep in mind that any characters sent when the BlueSMiRF v2 is in command mode will already be echoed back.

Note

The device can also be configured by connecting over Bluetooth and entering $$$.

Below is a brief list of commands. The BlueSMiRF will recognize commands with capital and lower case letters since the commands are not case sensitive.

AT Command Command Description
$$$ Enter Command Mode
AT Reports OK
AT? Display this help text
ATA Display all settings
ATB Display Bluetooth settings
ATC Check for new firmware
ATD Display the debug settings
ATF Restore factory settings
ATM Display MAC address
ATP Start pairing process
ATS Display serial settings
ATU Update Firmware
ATV Display firmware version
ATW Save current settings to NVM
ATX Exit command mode
ATY Display system settings
ATZ Reboot the system
AT-Param=xxx Set parameter's value to xxx by name (Param)
AT-Param? Print parameter's current value by name (Param)
AT-? Display the setting values
AT Commands

A parameter is set using the AT- prefix, followed by the name of the command with an equals sign and the value to set. For example, sending AT-SerialSpeed=115200 followed by the ENTER key (or a carriage return) will change the serial interface speed to 115200bps. This setting can be stored in NVM (non-volatile memory) by sending the ATW command.

To query a setting, send the AT command without a value and the device will respond with the current value. For example, sending AT-SerialSpeed followed by the ENTER key will generate the response 115200 followed by OK.

The commands are best discussed in groups:

Bluetooth Commands

Below is a table for Bluetooth commands, a short description of the command, and its factory default value (if applicable). Right after the table, there is also a list which provides a detailed explanation of each parameter as well.

AT Command Command Description Factory Default Value
AT-BluetoothConnectRetries Number of retries of a paired connection 5
AT-BluetoothConnectTimeoutMs Milliseconds before a paired connection attempt times out 3000
AT-BluetoothEscapeCharacter The character received from the remote system, sought to enter command mode +
AT-BluetoothNickname User configurable name to broadcast over Bluetooth during discovery "BlueSMiRF-ABCD", where ABCD is the last four hex digits of the Bluetooth MAC
AT-BluetoothPairedMac MAC address of the unit that the user wants to connect to at startup
AT-BluetoothPairedName Name of the unit that the user wants to connect to at startup
AT-BluetoothPin Pin to enter during pairing - only required for older Bluetooth devices 1234
AT-BluetoothRxSize Bluetooth receive buffer size 2048
AT-BluetoothTxSize Bluetooth write buffer size 1024
AT-BluetoothType Bluetooth protocol used for communication 0
Bluetooth Commands
  • BluetoothConnectRetries — If this device has a paired MAC or name, at power up it will attempt to connect to this paired device. A connection is not guaranteed, and the connection will be re-tried this number of times before going into passive, discoverable mode.

  • BluetoothConnectTimeoutMs — When this device is connecting to a paired device, if this number of milliseconds expires before a connection is made, the device will attempt to reconnect to the paired device.

  • BluetoothEscapeCharacter — This is the character that must be transmitted by a remote device to enter command mode remotely over the Bluetooth connection.

    Note

    Escape characters are ignored after MaxCommandTimeMs number of milliseconds and within MinEscapeTimeMs of other incoming characters.

  • BluetoothNickname — The name that is broadcast when other devices are scanning for devices to pair to.

  • BluetoothPairedMac — The MAC address of the BlueSMiRF that this device should pair to at power-on. Use the ATM command on the remote device to display its MAC address. This command is not normally used; use the button pairing method for an easier way to pair two devices.

  • BluetoothPairedName — The name of the BlueSMiRF that this device should pair to at power-on. Use the BluetoothNickname command on the remote device to change its paired name. This command is not normally used; use the button pairing method for an easier way to pair two devices.

  • BluetoothPin — The pin that is needed during pairing. Only needed on very old Bluetooth USB dongles.

  • BluetoothRxSize — The size of the Bluetooth receive buffer. Increase if a large amount of data is coming into the BlueSMiRF over Bluetooth, before the speed of the serial interface can output it.

  • BluetoothTxSize — The size of the Bluetooth transmit buffer. Increase if a large amount of data needs to be transmitted over Bluetooth but the connection between devices is poor and multiple retransmissions occur.

  • BluetoothType — Controls the Bluetooth protocol. This parameter accepts a 0, 1, and 2 for the Bluetooth Protocol as listed below. Note that only the SPP protocol supports pairing.

    • Protocol 0 = Serial Port Profile (SPP)
    • Protocol 1 = Bluetooth Low-Energy (BLE)
    • Protocol 2 = Radio off

Serial Commands

Below is a table for serial commands, a short description of the command, and its factory default value (if applicable). Right after the table, there is also a list which provides a detailed explanation of each parameter as well.

AT Command Command Description Factory Default Value
AT-FlowControl Enable the use of CTS/RTS flow control signals 0
AT-InvertCts Invert the input of CTS 0
AT-InvertRts Invert the output of RTS 0
AT-PartialFrameTimeoutMs Send partial buffer if time expires 50
AT-RtsStartSendingPercent Percent of serialReceiveBuffer that is free when RTS is asserted 25
AT-RtsStopSendingPercent Percent of serialReceiveBuffer that is free when RTS is deasserted 5
AT-SerialReceiveBufferSize Serial receive buffer size 51200
AT-SerialSpeed The baud rate that the BlueSmiRF operates at. 115200
AT-SerialTransmitBufferSize Buffer size to receive bytes from Bluetooth 10240
Serial Commands
  • FlowControl - If flow control is enabled, the BlueSMiRF v2 will send data when its CTS pin is driven low (the host system is telling the radio to transmit). If flow control is enabled, BlueSMiRF v2 will drive its RTS low if its serial buffer is full (the radio is telling the host system to hold its horses). By default, flow control is turned off.

  • InvertCts - By default, InvertCts is false and CTS is high when data is allowed to flow. Enable InvertCts to do the opposite.

  • InvertRts - By default, InvertRts is false and RTS is high when data is allowed to flow. Enable InvertRts to do the opposite.

  • PartialFrameTimeoutMs - The number of milliseconds of timeout before a partial packet is sent. For example, if a partial frame of 12 bytes is received, the radio will wait this amount for more bytes before initiating a transmission.

  • RtsStartSendingPercent - Percent of serialReceiveBuffer that is free when RTS is asserted. Default of 25% of serialReceiveBuffer.

  • RtsStopSendingPercent - Percent of serialReceiveBuffer that is free when RTS is deasserted. Default of 5% of serialReceiveBuffer.

  • SerialReceiveBufferSize - Buffer size to receive serial data from the serial port, to be sent over Bluetooth. The default is 51200.

  • SerialSpeed - The baud rate that the BlueSMiRF operates at. Discrete values 2400, 4800, 9600, 14400, 19200, 38400, 57600, 115200 (default), 230400, 460800, and 921600bps are allowed.

  • SerialTransmitBufferSize - Buffer size to receive bytes from Bluetooth, waiting to be printed out the UART. The default is 10240.

System Commands

Below is a table for system commands, a short description of the command, and its factory default value (if applicable). Right after the table, there is also a list which provides a detailed explanation of each parameter as well.

AT Command Command Description Factory Default Value
AT-EscapeCharacter The character sought to enter command mode $
AT-EscapeCharacterCount The number of escape characters required to enter command mode 3
AT-LedStyle Controls the behavior of the Status and Connect LEDs 0
AT-MaxCommandTimeMs After this time in milliseconds, command mode cannot be entered 60000
AT-MinEscapeTimeMs Serial traffic must stop this amount of milliseconds before an escape character is recognized 2000
AT-WiFiPassword Password for the SSID, used for over-the-air-updates
AT-WiFiSSID SSID used for over-the-air-updates
System Commands
  • EscapeCharacter — The character that must be entered a number of times (EscapeCharacterCount) to enter configuration mode. An escape character must be entered before the max time of MaxCommandTimeMs and after MinEscapeTimeMs.

  • EscapeCharacterCount — The number of escape characters needed before command mode is entered. Set to 0 to disable.

  • LedStyle - Controls how the LEDs behave: CLASSIC = 0, SERIAL_TRAFFIC = 1, OFF = 2.

    • CLASSIC mode (default) = 0 — The STATUS LED blinks with TX/RX traffic.

    • SERIAL_TRAFFIC mode = 1 — The CONNECT LED blinks with TX traffic and the STATUS LED blinks with RX traffic.

    • OFF mode = 2 — The CONNECT and STATUS LEDs are turned off.

  • MaxCommandTimeMs — Once this number of milliseconds has passed, command mode cannot be entered. This is used as a method to prevent a remote system from accidentally entering command mode.

  • MinEscapeTimeMs — This number of milliseconds must pass between the last serial character received and an escape character. This is used as a method to prevent a remote system from accidentally entering command mode.

  • WiFiPassword — The password for the local WiFi used for firmware updates.

  • WiFiSSID — The SSID for the local WiFi used for firmware updates.

Button Control

Button Control

The PAIR button on the BlueSMiRF v2 allows the device to enter a few different states.

Pairing Mode

Pairing mode is used to connect two BlueSMiRF v2 devices for direct communication. This mode is not needed for general discovery; a phone or a laptop can simply discover the BlueSMiRF v2 in its default state.

Holding the Pair button between 4 to 8 seconds will cause the Status and Connect LEDs to slowly blink back and forth. If the Pair button is released at this time, the device will enter Pairing mode.

GIF Setting BlueSMiRF v2 in  Pairing Mode
GIF Setting BlueSMiRF v2 in Pairing Mode

Generally speaking, to create a serial bridge between two BlueSMiRFs, one device needs to be in discoverable mode and the other device needs to discover it. This means, one device needs to have its Pair button held for 4 to 8 seconds then released. It will then fail to discover any compatible devices then enter Discoverable mode. Once this is done, the second device needs to have its Pair button held for 4 to 8 seconds, then released. The second device will then scan and discover the first device and pair with it. From this point on, the second device will always try to connect to the first device at power on.

Once a BlueSMiRF has entered Pairing Mode, it will scan for other compatible BlueSMiRF devices. If no other compatible device is found after a few seconds, the BlueSMiRF will enter Discoverable mode. The device will broadcast the name 'BlueSMiRF-Pairing' and wait for an incoming connection.

If a second device enters Pairing Mode, it will scan for other compatible BlueSMiRF devices broadcasting the name (you guessed it) 'BlueSMiRF-Pairing'. If a device is detected, the second device will connect to the first device, store the MAC address of the first device, and attempt to connect to it at every future power on. The first device will not be aware of or connect to the first device at power on.

Factory Reset Mode

Holding the Pair button for more than 8 seconds will cause the Status and Connect LEDs to quickly blink back and forth. If the Pair button is released at this time, the device will enter Factory Reset mode.

GIF Factory Reset
GIF Factory Reset

After a Factory Reset, all settings are reset to default and/or erased in the following way:

  • The baud rate is set to 115200 bps.
  • The escape character is set to '$' and a count of 3.
  • The WiFi SSID and password are erased.
  • Flow control is disabled.
  • All the other system settings are returned to default.

Bootloader Mode

Hold down the PAIR button when the BlueSMiRF v2 is not powered. Applying power will set the microcontroller to bootloader mode. The STATUS LED will be dim indicating that we are in Bootloader Mode. After uploading the firmware binaries to the ESP32, you will need to cycle power to the device as this does not automatically exit the bootloader mode.

GIF Setting the BlueSMiRF in Bootloader Mode
GIF Setting the BlueSMiRF in Bootloader Mode

Note

As stated in the hardware hookup when connecting a USB-to-serial converter, you will need to manually wire the TX-to-RX and RX-to-TX to a USB-to-serial converter with jumper wires.

Example 1 - BlueSMiRF to BlueSMiRF

In this example, we will connect two BlueSMiRF v2 boards to two separate serial ports. We will then send characters from one serial terminal to a second serial terminal.

The image below on the left shows the Serial Basic (CH340, USB-C) connected to the BlueSMiRF v2 Header using M/F jumper wires. Headers were used to easily remove and reconnect the BlueSMiRF v2 with headers. The image to the right shows the Serial Basic (CH340, micro-B) connected to the BlueSMiRF v2 PTH using M/F jumper wires. A row of female headers were soldered on the board. Extra long headers were placed between the female headers to easily remove and reconnect the BlueSMiRF v2 PTH as well.

USB-to-Serial Converter (CH340) to BlueSMiRF v2 Header with an Additional Stackable Header USB-to-Serial Converter (CH340) to BlueSMiRF v2 PTH
USB-to-Serial Converter (CH340) to BlueSMiRF v2 Header with an Additional Stackable Header USB-to-Serial Converter (CH340) to BlueSMiRF v2 PTH

Note

To distinguish between the two BlueSMiRFs, try labeling the two board. In this case, we chose had the one with male headers and the other one with female headers.

Connect the first BlueSMiRF v2 to your computer's COM port. In this case, it was COM13. Press and hold the PAIR button between 4 to 8 seconds. The Status and Connect LEDs will slowly blink back and forth. The Connect LED will begin to fade in and out after a few seconds. Open a serial terminal and connect to the first BlueSMiRF at 115200 baud.

First Serial Terminal
First Serial Terminal

At this point, connect the second BlueSMiRF v2 to your computer's COM port. In this case, it was COM18. Press and hold the second BlueSMiRF's PAIR button between 4 to 8 seconds. The second BlueSMiRF will scan the area for another BlueSMiRF and connect. Once connected, the Connect LEDs on both boards will remain solid. Open a second serial terminal, and connect to the second BlueSMiRF at 115200 baud. Move both serial terminals side by side.

Second Serial Terminal
Second Serial Terminal

Start typing characters in the first serial terminal. You should see them in the second serial terminal!

Sending Characters through First Terminal Receiving Characters through Second Terminal
Sending Characters through First Terminal Receiving Characters through Second Terminal

Type a message in the second terminal window. You should see them in the first serial terminal!

Sending Characters through Second Terminal
Receiving Characters through First Serial Terminal Sending Characters through Second Terminal

Example 2 - BlueSMiRF to Smartphone

Note

Bluetooth classic (Serial Port Profile or SPP) is primarily supported. This Bluetooth protocol is supported on Android phones, most desktops, and laptops. The BlueSMiRF v2 also supports the BLE protocol, available on all Apple phones.

In this example, we will connect a BlueSMiRF v2 to a smartphone and send serial data using the Bluetooth classic protocol (also known as Serial Port Profile or SPP).

The image below shows the Serial Basic (CH340, USB-C) connected to the BlueSMiRF v2 Header using M/F jumper wires. Headers were used to easily remove and reconnect the BlueSMiRF v2 with headers.

BlueSMiRF v2 to SmartPhone Bluetooth Classic Serial Terminal
BlueSMiRF v2 to SmartPhone Bluetooth Classic Serial Terminal

Download the Serial Bluetooth Terminal App

Head to your smartphone's app store. In this case, we were on an Android smartphone and used Google Play Store to download the Serial Bluetooth Terminal app. This app is great for development, debugging, and general use when using the BlueSMiRF's SPP and BLE protocols.

Note

If you have a different phone OS, there are many apps like the Serial Bluetooth Terminal available for different smartphones. Just do a search in your app store.

Pair the BlueSMiRF v2 with your Smartphone

Once downloaded, turn on your Bluetooth and open your Bluetooth settings. Scroll down until you see the available devices. With BlueSMiRF powered up and in range, you should be able to see the device in discoverable mode listed as BlueSMiRF-ABCD, where ABCD is the last four hex digits of the Bluetooth MAC. In this case, it was BlueSMiRF-5A66.

BlueSMiRF Discovered on Android Smartphone

Click on the device to begin pairing. A message will pop up asking if you want to pair with the device. At this point, select "Pair."

BlueSMiRF Discovered on Android Smartphone

Scroll up to your Paired devices and look for the BlueSMiRF to verify that it has paired with your phone.

BlueSMiRF-5A66 Showing Up as a Paired Bluetooth Device
BlueSMiRF-5A66 Showing Up as a Paired Bluetooth Device

Sending Characters Between a BlueSMiRF and Smartphone

Open the Serial Bluetooth Terminal app.

Serial Bluetooth Terminal Opened
Serial Bluetooth Terminal Opened

Click on the connect icon to the left of the trash can icon. If all is well, you will get a message indicating that the BlueSMiRF is connected.

Connected to BlueSMiRF-5A66
Connected to BlueSMiRF-5A66

Open a serial terminal, and connect to the BlueSMiRF at 115200 baud. In this case, it was connected to COM13. Start typing characters in the serial terminal. You should see them in the Serial Bluetooth Terminal app!

First Serial Terminal
Serial Terminal Connected to BlueSMiRF v2 Receiving Characters through the Serial Bluetooth Terminal

Type a message and send them using the Serial Bluetooth Terminal app. You should see the message in the serial terminal!

Receiving Characters through First Serial Terminal Sending Characters through Serial Bluetooth Terminal

Sending serial data between the BlueSMiRF and smartphone using the Serial Bluetooth Terminal app is only the start! For example, you can use BlueSMiRF v2 and a smartphone to send/receive correction data to/from a high precision GNSS module. Try looking at the following methods to send data between the BlueSMiRF v2 and a smartphone. Just make sure to adjust the baud rate of the BlueSMiRF to match the high precision GNSS module's baud rate (for the u-blox modules, the correction port's default is typically set to 38400 baud). These are only a few ways to connect a high precision GNSS module to your smartphone's GNSS app to achieve an RTK Fixed Mode.

Example 3 - Wireless Serial LCD

In this example, we will be using the basic serial UART example from the SerLCD tutorial. However, the wires between the SparkFun RedBoard will be replaced with a pair of BlueSMiRF v2s.

Changing the Baud Rate

Before using the BlueSMiRFs with the SerLCD, we need to make sure that the baud rates match. You can either change the baud rate on both BlueSMiRFs or the baud rate of the SerLCD. To keep the original Arduino code the same, let's change the baud rate on both of the BlueSMiRFs. This will also be a good exercise to change the baud rate using the AT Commands.

Connect a USB-to-Serial converter to the BlueSMiRF. Depending on the BlueSMiRF that you have, you may need to solder headers. Then connect the USB cable between the converter and your computer.

USB-to-Serial Converter (CH340) to BlueSMiRF v2 Header with an Additional Stackable Header
USB-to-Serial Converter (CH340) to BlueSMiRF v2 Header with an Additional Stackable Header

Open a serial terminal and connect to the COM port at 115200 baud. Type $$$ within 60 seconds of powering the BlueSMiRF to enter command mode.

BlueSMiRF v2 Connected to Serial Terminal and in Command Mode
BlueSMiRF v2 Connected to Serial Terminal and in Command Mode

Type AT-SerialSpeed=9600 to change the baud rate to match the SerLCD's baud rate (which is set to 9600 baud by default). Enter ATW to save the settings.

Configuring the Baud Rate of the BlueSMiRF v2
Configuring the Baud Rate of the BlueSMiRF v2

Now that the first BlueSMiRF v2 is configured, repeat the same steps explained above to change the baud rate of the second BlueSMiRF v2.

Hardware Hookup

Replacing the connection with the BlueSMiRFs is similar to the basic serial UART connection listed earlier in this tutorial. We'll be using it as a guide to wire everything up. Since the SerLCD is only receiving data to display, we only need to use its RX pin.

From the microcontroller, you will need to wire the following pins. Since the BlueSMiRF v2 includes logic level circuitry on the TX and RX pins, we can wire the SparkFun RedBoard Plus directly to the pin when the switch for the microcontroller's logic level is set to 5V. Notice that we are only wiring software serial TX pin since we are just sending characters from the microcontroller to the SerLCD. Users that want to also connect software serial RX pin can also wire the connection to the BlueSMiRF v2's TXO but it is not necessary. We will assume that we are using power supplied from a USB port or USB power supply.

SparkFun RedBoard Plus
(ATmega328P) Pinout
Transmitting BlueSMiRF v2
Pinout
7 RXI
5V VCC
GND GND

On the SerLCD side, we can simply insert the BlueSMiRF v2 in the SerLCD's USB-to-serial 1x6 header. For users that are using the BlueSMiRF v2 with headers and soldered male header pins on the SerLCD, you can place them in a breadboard. A 9V power supply and barrel jack adapter was used to power both boards. The + pin from the adapter was connected to the SerLCD's RAW pin which is regulated down to 3.3V. Of course, the - pin from the adapter was also connected for reference ground.

Receiving BlueSMiRF v2
Pinout
SparkFun 16x2 SerLCD
RGB Backlight (Qwiic) Pinout
Power Supply (5V TO 9V)
with Barrel Jack Adapter
TXO RX
VCC +
RAW +, Center Positive Pin
GND GND -, Sleeve

If you have not already, make sure to upload the Arduino example code from the basic serial UART example. For your convenience, the code shown below was pulled from the OpenLCD's Serial Examples folder. Select the board (in this case, the Tools > Board > Arduino AVR Boards (arduino) > Arduino Uno) and COM port that the board enumerated to. Then hit the upload button.

/*
 OpenLCD is an LCD with serial/I2C/SPI interfaces.
 By: Nathan Seidle
 SparkFun Electronics
 Date: April 19th, 2015
 License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).

 This example shows how to display a counter on the display over serial. We use software serial because if 
 OpenLCD is attached to an Arduino's hardware serial port during bootloading  it can cause problems for both devices.

 To get this code to work, attached an OpenLCD to an Arduino Uno using the following pins:
 RX (OpenLCD) to Pin 7 (Arduino)
 VIN to 5V
 GND to GND

*/

#include <SoftwareSerial.h>

SoftwareSerial OpenLCD(6, 7); //RX, TX

byte counter = 0;

void setup()
{
  Serial.begin(9600); //Start serial communication at 9600 for debug statements
  Serial.println("OpenLCD Example Code");

  OpenLCD.begin(9600); //Start communication with OpenLCD
}

void loop()
{
  //Send the clear command to the display - this returns the cursor to the beginning of the display
  OpenLCD.write('|'); //Setting character
  OpenLCD.write('-'); //Clear display

  OpenLCD.print("Hello World!    Counter: "); //For 16x2 LCD
  //OpenLCD.print("Hello World!        Counter: "); //For 20x4 LCD
  OpenLCD.print(counter++);

  delay(250); //Hang out for a bit
}

With both boards powered, follow the steps to pair and connect the two BlueSMiRFs together. If all is well, you should see the RedBoard Plus transmitting the same message to the SerLCD. Instead of a wired connection, a pair of BlueSMiRF's were used!

Wireless Serial LCD
Wireless Serial LCD with the RedBoard Plus

Try adding a Qwiic-enabled device like the Human Presence and Motion Sensor - (STHS34PF80) to the RedBoard Plus and writing code to display a message notifying you when someone has passed by a door. Then place the SerLCD by your desk so that you can monitor the traffic.

Firmware Update

From time to time, SparkFun will release new firmware for the BlueSMiRF v2 product line to add and improve functionality. For most users, firmware can be upgraded over a 2.4GHz WiFi network using the OTA method. Users can also update the firmware manually using a Command Line Interface (CLI)

Updating Firmware Over-The-Air (OTA)

Once the AT-WiFiSSID and AT-WiFiPassword settings have been entered for your local WiFi network, the ATC command can be issued to check for new firmware. If new firmware is available, send the ATU command to begin an update.

Manually Updating Firmware Over Serial

Because it's much easier to use, we recommend the OTA firmware update process. If that fails for some reason, the following CLI method can be used.

Entering Bootloader Mode

Hold the PAIR button while powering the BlueSMiRF v2. This will cause the ESP32 to enter bootloader mode. Once the BlueSMiRF v2 is in bootloader mode, the STATUS LED will be dimly lit and the CONNECT LED will be off.

We recommend using a breadboard or jumper wires to connect the BlueSMiRF to a USB-to-Serial connection. At a minimum, you will need to connect the UART pins, power, and ground as stated in the hardware hookup. Remember, the TX and RX connections must be crossed over.

USB-to-Serial Converter
Pinout
Intermediate Wire Connection BlueSMiRF v2
Pinout
DTR RTS
RXI RXI
TXO TXO
3V3 VCC
CTS CTS
GND GND

Note

The connection also includes two additional connections for flow control: RTS and CTS. These two connections are not needed for a basic serial UART connection. However, using all six wires can help make a tighter connection on the 1x6 header. The wire colors also connect TXO-to-RXI and RXI-to-RXO to indicate that it is not a direct connection between the two boards and the 1x6 header.

USB-to-Serial Converter (CH340) to BlueSMiRF v2 Header with an Additional Stackable Header
USB-to-Serial Converter (CH340) to BlueSMiRF v2 Header with an Additional Stackable Header

Windows

Identify the COM port the USB-to-Serial device enumerated at. The easiest way to do this is to open the Device Manager under the Ports (COM & LPT) tree:

CH340 is on COM10 as shown in Device Manager
CH340 is on COM10 as shown in Device Manager

If the COM port is not showing, be sure the unit is turned On. If an unknown device is appearing, you’ll need to install drivers for your USB-to-serial device (we'll assume that you are using the CH340).

Once the correct COM port is identified, head to the GitHub repo for the BlueSMiRF v2 binaries and download all the contents. Unzip the contents in a known directory and copy the path.

Open a command prompt (Windows button + r then type ‘ cmd ’). Head to the directory where you unzipped the folder. You'll need to use the cd commmand, paste the path where you unzipped the folder, and hit the enter key.

Change Path to BlueSmiRF Binaries Folder
Change Path to BlueSmiRF Binaries Folder

You'll then need to run the 'batch_program.bat' along with the binary file name and COM port. Enter the following command below, where COM4 should be replaced by the COM port you identified earlier and BlueSMiRF_Firmware_v1_0.bin is the firmware that you are updating to. Make sure to send an additional key to run the batch file.

batch_program.bat BlueSMiRF_Firmware_v1_0.bin COM4
batch_program.bat running esptool
batch_program.bat running esptool

After about 20 seconds, you should see the following message: Done programming! Ready for next board.

Successfully Programmed BlueSMiRF v2 - ESP32
Successfully Programmed BlueSMiRF v2 - ESP32

The batch file runs the following commands, where COM4 is replaced with the COM port that the BlueSMiRF product enumerated at and BlueSMiRF_Firmware_vx_x.bin is the firmware you would like to load.

esptool.exe --chip esp32 --port COM4 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 8MB 0x1000 bins/bootloader.bin 0x8000 bins/partitions.bin 0xe000 bins/boot_app0.bin 0x10000 BlueSMiRF_Firmware_v1_0.bin

Note

Some users have reported the 921600 baud rate does not work. Decrease this to 115200 as needed.

Tip

Finished programming the ESP32? Type CTRL + C , Y , and ENTER to exit the batch file. You can also close the window.

Upon completion, the BlueSMiRF v2 must be power cycled to exit bootloader mode. Once power cycled, the BlueSMiRF will start running the new firmware.

Note

We recommend disconnecting the USB cable from the USB-to-Serial Converter or your computer's COM port.

macOS / Linux

Get esptool.py. Connect a USB A to C cable from your computer to the USB-to-Serial. Now identify the COM port the USB-to-serial device enumerated at.

If the COM port is not showing, be sure the unit is turned On. If an unknown device is appearing, you’ll need to install drivers for your USB-to-serial device (we'll assume that you are using the CH340).

Once the correct COM port is identified, head to the GitHub repo for the BlueSMiRF v2 binaries and download all the contents. Unzip the contents in a known directory and copy the path.

Open a Terminal window and run the following command, where /dev/ttyUSB0 is replaced with the port that the USB-to-Serial board enumerated at and BlueSMiRF_Firmware_vx_x.bin is the firmware you would like to load.

py esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash  -z --flash_mode dio --flash_freq 80m --flash_size 8MB 0x1000 bins/bootloader.bin 0x8000 bins/partitions.bin 0xe000 bins/boot_app0.bin 0x10000 BlueSMiRF_Firmware_vx_x.bin

Note

Some users have reported the 921600 baud rate does not work. Decrease this to 115200 as needed.

Tip

Finished programming the ESP32? Type CTRL + C , Y , and ENTER to exit the batch file. You can also close the window.

Upon completion, the BlueSMiRF must be power cycled to exit bootloader mode. Once power cycled, the BlueSMiRF will start running the new firmware.

Note

We recommend disconnecting the USB cable from the USB-to-Serial Converter or your computer's COM port.

Troubleshooting

General Troubleshooting Help

Note

Not working as expected and need help?

If you need technical assistance and more information on a product that is not working as you expected, we recommend heading on over to the SparkFun Technical Assistance page for some initial troubleshooting.

If you don't find what you need there, the SparkFun Forums are a great place to find and ask for help. If this is your first visit, you'll need to create a Forum Account to search product forums and post questions.

Issues Uploading Code Manually via CLI

If you are seeing the following error when attempting to flash the binaries:

    A fatal error occurred: Failed to connect to ESP32: No serial data received. For troubleshooting steps visit: https://docs.espressif.com/projects/esptool/en/latest/troubleshooting.md_in_html
Done programming! Ready for next board.
Press any key to continue . . .
    
Successfully Programmed BlueSMiRF v2 - ESP32
Error Programming BlueSMiRF v2 - ESP32

Make sure to:

  • ensure that the wires are making connection and not loose
  • wired correctly between the USB-to-Serial Converter and your BlueSMiRF v2
  • COM Port is the same one that the USB-to-Serial converter enumerated to on your computer
  • install the appropriate drivers
  • in Bootloader Mode

Still having issues? Try a power cycle by following the steps below:

  • disconnecting the USB-to-serial converter from your computer
  • pushing down on the pair button for bootloader mode
  • connecting the USB-to-serial converter back to your computer

Can the BlueSMiRF v2 be used for wireless serial upload with an Arduino?

Currently, there is not support for wireless serial upload with an Arduino. We recommend removing the BlueSMiRF v2 and using a USB-to-serial converter to upload code to an Arduino.

Resources

Now that you've successfully got your SparkFun BlueSMiRF v2 up and running, it's time to incorporate it into your own project! For more information, check out the resources below: