Grbl_ESP32 with Bluetooth Serial Support

Bluetooth Serial has now been added to the master branch of Grbl_ESP32. Bluetooth Serial means the Bluetooth connection looks like a serial port when you pair with the device. This is ideal because it allows all existing gcode senders that support serial ports to use Bluetooth.

This was added using the Bluetooth Serial library that is part of the espressif/arduino-esp32 development environment. This library is relatively new and has a few issues, but I was able to work around them.

  • Sending Characters: The reporting done by Grbl sends characters a character at a time. This means dozens of calls to the library are needed for each response. This caused characters to be dropped. The solution is to send a full string in a single call using .print(), rather than sending individual characters using .write().  Grbl was written using the character at a time method to highly optimize the reporting. The raw speed of the ESP32 does not require that optimization and the resulting code is much more readable.
  • No Password: The library does not support the use of a password for the pairing. This is a big drawback, and needs to be considered before you enable Bluetooth. Apparently this was due to an upstream component that has now been fixed. Hopefully it means the library will be updated soon.

Why and when to use it.

The cost, size and wireless features of the ESP32 are the primary reason I ported Grbl to the ESP32. I make a lot of tiny CNC machines. A laptop is likely to be many times the size of the CNC machine. I wanted to control the machines via a phone or small tablet. I have found the connection to be very reliable, even for jobs lasting more than an hour. The phone can even be in the “off” state in your pocket and it will still stream reliably. The battery drain is accelerated, but not significantly (like listening to audio via Bluetooth) You do need to stay within range of the machine, although Grbl Controller (Android) appears to be able to resume a job.

Using Bluetooth.

It is optional. You enable the feature at compile time. That allows you to save some code space (not really an issue now). Once the feature is enabled, you can still turn it on or off via a serial port command. All Bluetooth traffic is echo’d to the serial port. This allows you to monitor the communications. You can also use the Serial port at any time, but it is not a good idea to do that while running a job. Here are the steps to set it up.

  • Make sure #define ENABLE_BLUETOOTH is not commented out in config.h.
  • Use a serial port terminal to set the Bluetooth name using $I=NAME, where NAME is the Bluetooth name you want. I don’t know all the naming rules, so keep it short and simple. There is no capability to use a password yet. Grbl converts all input to capital letters, so lowercase will cannot be used.
  • Reboot the ESP32 to turn on Bluetooth with that name. Grbl will send Starting Bluetooth:ESP32BT as the first item when booting to let you know Bluetooth is on. ESP32BT is the Bluetooth name I used in this case. Grbl will now respond on either Bluetooth or Serial data. All Bluetooth sends are echo’d on the Serial port if you want to watch the data.
  • You can now pair a phone or PC with Grbl_ESP32.
  • Caution: Do not pair while running a job. The ESP32 will likely interrupt and/or watchdog issues while the stepper timer is running and the pairing process is running.

Next Steps

  • Other modes: A phone also makes an awesome display and control panel. Maybe the PC is the primary sender and the phone acts as a pendant.
  • SD card. SD card is next on the roadmap. This pairs well with bluetooth, because the phone could select and start an SD card job.

If you want to be notified of future blog posts, please subscribe.



 

 

 

Share and Enjoy:
  • Print
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks

3 Responses to “Grbl_ESP32 with Bluetooth Serial Support”


  1. Franklin

    JoG no problem with bluetooth?.in some cases the axis movement is slow in bluetooth connection.

  2. bdring

    I have not seen that. Is it just jogging? What do you mean by slow?

  3. bdring

    Would you please post this issue in the issues section of the GitHub repo? That is the best place for us to discuss thing like this.

    https://github.com/bdring/Grbl_Esp32/issues

*