Skip to content

Firmware Overview

The BlueSMiRF v2 comes pre-programmed with the latest version of our open-source firmware. However, users are free to modify the firmware and/or reprogram their board for their purposes.

Our firmware provides short-range, point-to-point communication; allowing serial UART data to be transmitted between two Bluetooth devices. It includes support for both the SPP and BLE protocols and features a massive >10kB buffer for each RX and TX channel to compensate for transmission delays. The firmware also offers a set of AT-commands to configure the BlueSMiRF v2's settings: including the baud rate, flow control, LED mode, and Over-The-Air (OTA) updates over a 2.4GHz WiFi network to name a few.

  • Serial Bluetooth® Point-to-Point Communication
  • Bluetooth Protocols Supported
    • Serial Port Profile (SPP)
    • Bluetooth Low Energy (BLE)
  • Firmware Over-the-Air (OTA) Updates via 2.4GHz WiFi

Bluetooth Protocols

While Bluetooth Classic (Serial Port Profile or "SPP") is the primary communication protocol, which makes it highly compatible with Android devices and most computers, the BlueSMiRF v2 also supports Bluetooth Low Energy (BLE) protocol for connecting with Apple devices and other low-power devices.

Dependencies

For users looking to modify the firmware for their own use case, the following dependencies must be installed in the Arduino IDE:

Info

For documentation on the Bluetooth Serial library that is built into the ESP32 Arduino core, please refer to Espressif's API guide.

Board Settings

To upload the firmware, users will need to compile and upload the firmware in the Arduino IDE with the following board settings:

  • Board: ESP32 Dev Module
  • Flash Size: 8MB
  • Partition Scheme:
    • Default: Use custom partition file named BlueSMiRF_Partitions.csv
      • Partitions:
        • app0 (0x3C0000): 3.9MB
        • app1 (0x3C0000): 3.9MB
        • spiffs (0x1000): 4096
    • Alternative: Built-in Minimal SPIFFs (1.9MB APP with OTA)
  • PSRAM: Enabled

Bootloader Mode

Users can manually force the ESP32 into the serial bootloader mode with the PAIR button, to upload new firmware to the BlueSMiRF v2. Please, refer to the PAIR Button section below for more information.

Update Methods

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 by manually reprogramming the device with the new firmware.

Over-The-Air (OTA)

Because it's much easier to use, we recommend this method. However, it does require an internet connection through your local WiFi network. 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.

  1. Enter command mode:
    • UART Interface: $$$
    • Bluetooth Serial Link: +++ (remote access)
  2. Configure the AT-WiFiSSID and AT-WiFiPassword parameters for your local WiFi network
  3. Save the new settings (ATW)
  4. Issue the ATC command to check for new firmware.
  5. If new firmware is available, send the ATU command to begin an update.
  6. The device will restart after the update process is complete
Example

Below, is an example of this method using the UART interface. In the example, the WiFi network's SSID is sparkfun-guest and its password is sparkfun6333. The highlighted lines represent the commands that were sent.

Terminal

BlueSMiRF-v1.0

$$$
OK
at-wifissid=sparkfun-guest
AT-WIFISSID=sparkfun-guest
OK
at-wifipassword=sparkfun6333
AT-WIFIPASSWORD=sparkfun6333
OK
atw
ATW
OK
atc
ATC
Connecting to sparkfun-guest...
Connected!
Checking to see if an update is available from https://raw.githubusercontent.com/sparkfun/SparkFun_BlueSMiRF-v2_Binaries/main/BlueSMiRF-Firmware.json

Current firmware version: v1.0

New firmware version available: 1.1

OK
atu
ATU
Connecting to sparkfun-guest...
Connected!
Getting new firmware
Installing new firmware

[ 0%

[ 1%

[ 2%

.
.
.

[=================== 99%

[==================== 100%
]
BlueSMiRF-v1.1

Manually Reprogramming

If for some reason the OTA method can't be used, users can also manually reprogram the microcontroller on the BlueSMiRF v2.

  1. Download the Firmware: Download and unzip the contents of the SparkFun_BlueSMiRF-v2_Binaries GitHub repository.
  2. Connect Hardware: Wire the BlueSMiRF v2 to a USB-to-Serial converter, ensuring the TX and RX connections are crossed over. To automatically trigger a reset, connect the converter's DTR pin to the BlueSMiRF v2's RST PTH pad.

    USB-to-Serial Converter BlueSMiRF v2
    DTR RST (PTH Pad)
    RXI TXO
    RXI TXO
    3V3 VCC
    GND GND
  3. Identify the Port: Find your USB-to-Serial COM port using Windows Device Manager or your macOS/Linux terminal (e.g., /dev/ttyUSB0).

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

  4. Upload the Firmware: Open a command prompt or terminal, navigate to the unzipped firmware directory, and execute the appropriate flash command for your OS:

    • Windows: Run the following command in the command prompt
      .\batch_program.bat .\<firmware_name.bin> <COM_PORT>
      
    • macOS/Linux: Run the following command in the terminal
      ./batch_program.sh ./<firmware_name.bin> <COM_PORT>
      
    Script Details

    These scripts basically run the following command in a loop:

    <ESPTOOL_EXECUTABLE> --chip esp32 --port <COM_PORT> --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 <BINARY_FILE>
    

    Where the the following are variables are replaced with:

    • Windows:
      • <ESPTOOL_EXECUTABLE>: esptool.exe
      • <COM_PORT>: COM# (i.e. COM4)
    • Linux/MacOS:
      • <ESPTOOL_EXECUTABLE>: esptool
      • <COM_PORT>: /dev/tty* (i.e. /dev/ttyUSB0)
    • <BINARY_FILE>: BlueSMiRF_Firmware_vx_x.bin

    Tip

    Some users have reported issues, where the 921600 baud rate does not work. If you encounter this problem, reduce the baud rate to 115200.

  5. Start the Programming Process: When prompted, press a keyboard key to start the programming process.

    batch_program.bat running esptool
    batch_program.bat running esptool

  6. Enter Bootloader Mode: When the Connecting....... prompt pops up, press and hold the PAIR button.

    Tip

    Bootloader mode is active when the STATUS LED is dimly lit and the CONNECT LED is off.

  7. Wait for Process to Complete

  8. Reboot: Power cycle the BlueSMiRF by disconnecting and reconnecting power to exit bootloader mode and run the new firmware.

    Tip

    If you previously connected the DTR pin of the USB-to-Serial converter to the RST PTH pad on the BlueSMiRF v2, it isn't necessary to power cycle the board.

  9. Programming Complete:: Wait for the following prompt Done programming! Ready for next board.

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

  10. Next:

    • To exit, click Ctrl + C to exit the batch file. You can also just close the window.
    • Otherwise, connect another BlueSMiRF v2 to the USB-to-serial converter and click a keyboard key to program the next board

Changelog

  • v1.0 - Initial release
  • v1.1
    • Fixes exit command for Bluetooth connection
    • Increases maximum RX/TX buffer size