Give Your BLEBot a New Name

Give Your BLEBot a New Name

Tutorial for changing the name used by the FirmataBLE library and updating your Node.js libraries to connect with the new name.

  • 521 views
  • 0 comments
  • 3 respects

Components and supplies

Apps and online services

About this project

At the Hackster Hardware Meetup Seattle, we had a bunch of BLE Bot 9000 robots. The problem was that all of the bots exposed the same services and names, so you can't choose the robot you want to control. The solution to controlling your bot is to give it a unique name, so that when you scan for devices you only connect to your device. This tutorial covers how to change the name of your BLE Bot 9000, and how to to connect to a bot by name.

The first thing we need to do is install the Firmata library:

Step 1. Start up your Arduino IDE. If you need to install the IDE, you can find the download here: Arduino IDE.

Step 2. From the menu choose "Sketch, Include Library, Manage Libraries".

Step 3. Type in firmata in the filter your search box.

Step 4. Choose "Firmata Built-In by Firmata Developers" and click the Install button.

Next we need to change the name the bot will be broadcasting:

Step 1. Navigate to the folder where the StandardFirmataBLE example is stored. On my computer it is at "C:\Program Files (x86)\Arduino\libraries\Firmata\examples\StandardFirmataBLE"

Step 2. Open the bleConfig.h file in a text editor, such as Notepad++. You can install Notepad++ from https://notepad-plus-plus.org/download/v7.3.1.html

Step 3. Change the FIRMATA_BLE_LOCAL_NAME value from "FIRMATA" to the name you want to use (on my computer this was line 27). NOTE: The new name must be 8 characters or less. In this example I use "MYBOT".

#define FIRMATA_BLE_LOCAL_NAME "MYBOT"

Step 4. Save your updated bleConfig.h file. (Make sure you overwrite the existing file. Windows will try to save in a different folder if you aren't running as Admin, since the file is in the "c:\program files (x86)" folder.)

Now we need to install FirmataBLE onto our Arduino 101 board:

Step 1. Start up your Arduino IDE.

Step 2. Connect your Arduino 101 to your computer's USB port.

Step 3. From your Arduino IDE menu choose "Tools, Board, Arduino/Genuino 101". (NOTE: If you do not see your Arduino 101 board, then choose "Tools, Board, Board Manager", search for "Intel Curie Boards" and install it.)

Step 4. From your Arduino IDE menu choose "Tools, Port, and the serial port with the Arduino 101".

Step 5. From your Arduino IDE menu choose "File, Examples, Firmata, StandardFirmataBLE".

Step 6. From your Arduino IDE menu choose "Sketch, Upload" to upload the FirmataBLE software into your Arduino.

Install software on your phone to scan for the Arduino (optional):

Step 1. Install "nRF Connect for Mobile" on your phone.

Step 2. Start "nRF Connect" and go to the scanner tab.

Step 3. Click "Scan".

You should see your Arduino 101 broadcasting the name you gave it earlier! If you see "FIRMATA" instead, then you need to confirm that the bleConfig.h file contains your changed name.

Follow the directions to get Node.js communication to your bot

Step 1. Follow the directions at https://www.hackster.io/29284/ble-bot-9000-c150b8

  • Load Arduino Sketch -- you can skip since you already did it above.
  • Load Firmata Client -- you need to do these steps so your computer can connect to your bot. If you are running Windows, see the comments section because Phillip Horn has some useful tips.
  • Run the code -- this will help make sure it works (but you will connect to the first bot found)

Update your project to support named bots

Step 1. If you followed the directions on the ble-bot-9000 you should have a file named "node_modules\ble-serial\index.js". You need to replace it with the file from https://raw.githubusercontent.com/pvanallen/ble-serial/f7ade7ad533d20b3434c6c4fc984d6b764a1661d/index.js

Step 2. You should also have a "control.js" file. You need to replace it with the file from https://raw.githubusercontent.com/jamisonderek/Firmata-BLE-Bot/master/control.js

Step 3. Edit your "control.js" file and replace {localName:'FIRMATA'} with {localName:'MYBOT'} (or whatever you named your bot).

Step 4. Run the program. NOTE: You can turn on DEBUG to see devices it finds.

set DEBUG=ble-serial 
node control.js

You should now only connect to bots matching your name. The updated control.js file also makes Z and X keys control the speed of the bot.

Code

Changing the name of your bot from FIRMATA to MYBOTArduino
The #define that you need to modify is near the top of the bleConfig.h header file.
#define FIRMATA_BLE_LOCAL_NAME "MYBOT"

Comments

Similar projects you might like

Arduino101 BLE Autonomous Rover

Project tutorial by 4 developers

  • 15,520 views
  • 2 comments
  • 32 respects

Flightduino 101

Project tutorial by Tom Minnich

  • 12,596 views
  • 3 comments
  • 34 respects

Wolf: Search and Rescue Multi-Terrain Robot

Project tutorial by Husky Mai

  • 7,430 views
  • 3 comments
  • 46 respects

VEPCRo - Vertical External Pole Climbing Robot

Project showcase by Pramod C Wickramasinghe

  • 6,835 views
  • 11 comments
  • 35 respects

Robot Rover - iPhone controlled using Blynk Joystick

Project tutorial by jim Myracle

  • 4,975 views
  • 0 comments
  • 17 respects

VoiceBot101

by Gregory O. Voronin

  • 5,133 views
  • 6 comments
  • 35 respects
Add projectSign up / Login