This example shows how to read and write public name of the Bluetooth module.
Required Materials
1 x Waspmote
1 x Battery
1 x Coin battery
1 x Bluetooth module Pro
1 x Bluetooth module antenna
1 x Expansion board (if socket 1 is used)
1 x SD card
Notes
- Socket 1 will be used to connect Bluetooth module (using expansion board)
- Socket 0 can also be used, plugging module directly.
- It is recommended to set RTC time to your actual time.
- SD card must be inserted to allow saving discovered devices.
- Never unplug module while Waspmote is turned ON.
- Bluetooth module antenna should be connected.
- The battery must be connected in ANY example.
- This example can be executed in Waspmote v12 and Waspmote v15
Code
/* * ------ BT PRO_07 - Get/Set Friendly name -------- * * Explanation: Read and write bluetooth module friendly name (visible * name). Name is software limited to 20 characters. * * Copyright (C) 2016 Libelium Comunicaciones Distribuidas S.L. * http://www.libelium.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Version: 1.1 * Design: David Gascón * Implementation: Javier Siscart */#include"WaspBT_Pro.h"voidsetup(){USB.println(F("BT_PRO_07 Example"));// Turn On Bluetooth moduleBT_Pro.ON(SOCKET1);}voidloop(){// 1. Set a friendly name of less than 20 charactersBT_Pro.setOwnName("My Bluetooth Pro");// 2. Read firendly nameUSB.print(F("Name: "));USB.println(BT_Pro.getOwnName());// 3. Set new friendly nameBT_Pro.setOwnName("Bluetooth module");// 4. Read new firendly nameUSB.print(F("New Name: "));USB.println(BT_Pro.getOwnName());delay(5000);}
Output
H#BT_PRO_07 ExampleName: My Bluetooth ProNew Name: Bluetooth module