This example show how to manage BLE sleep mode. * Do not confuse BLE sleep mode with Waspmote sleep modes.
Required Materials
1 x Waspmote
1 x Battery
1 x Bluetooth Low Energy module
1 x Bluetooth module antenna
1 x Expansion board (if socket 1 is used)
1 x SD card
Notes
- Socket 0 is used by default
- EEPROM is used in this example by default.
- 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
/* * ------------------ [BLE_18] - Sleep mode ------------------- * * Explanation: This example shows how to manage BLE sleep mode. * Do not confuse BLE sleep mode with Waspmote sleep modes. * * 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.0 * Design: David Gascón * Implementation: Javier Siscart */#include<WaspBLE.h>voidsetup() {USB.println(F("BLE_18 Example")); // 0. Turn BLE module ONBLE.ON(SOCKET0);}voidloop(){// 1. Put Bluetooth module into Sleep modeBLE.sleep();USB.println(F("Bluetooth module sleeping.")); // Now the Bluetooth module has the UART interface disabled // and is not able to receive any command.USB.print(F("BLE MAC is: "));USB.println(BLE.getOwnMac()); // The power consumption is reduced to the minimum.delay(5000);// 2. Wake up Bluetooth module USB.print(BLE.wakeUp(), DEC);USB.println(F("Bluetooth module alive.")); // UART interface is now enabled again, // the module is able to communicate with Waspmote. USB.print(F("BLE MAC is: "));USB.println(BLE.getOwnMac()); delay(5000);}
Output
H#
BLE_18 Example
Bluetooth module sleeping.
BLE MAC is: 000000000000
Bluetooth module alive.
BLE MAC is: 000780789EEB