What are the current options for supporting Bluetooth Low Energy (BLE)?

So I have two Electrons and they are working quite well! I’ve been looking into adding BLE support to talk to some local devices, and the only references I can find are two years old.

Obviously things can change a lot in a year or two, so I wanted to see if there are any recommendations on connecting BLE hardware to an Electron, and to see what sort of results others have had in this area.

Thanks for any insight and updates!

Check out http://Bluz.io

They have a BLE device that interfaces to the Particle build tools and APIs.

There’s also RedBear Duo. It can be programmed OTA through the Particle cloud and has both BLE and WiFi on the same dev board.

1 Like

The two suggestions above are good. I also ported the library for the Adafruit Bluefruit LE SPI nRF51 breakout boards. I only tested it with the Photon but it should work on the Electron as well. It’s “Adafruit_BLE” in the community libraries and here on github: https://github.com/rickkas7/Adafruit_BLE

Hey thanks for the ideas! I’ve seen the redbear but need the cell connectivity that I get on this Electron… though might be good for wifi option versions of this test setup.

I haven’t really looked at Bluz at all, that’s pretty interesting.

If I have an Electron and GPS unit already connected, I’d need something that would fit in together in the mix there. The Adafruit board mentioned:

Looks pretty small and perhaps that would be the best bet? I wonder if the Electron would have any power issues powering both the GPS and the BLE board. Has anybody tried both on the single board?

The Adafruit BlueFruit LE board can be powered at 3.3V and uses a minuscule amount of current, hence the “LE” or “Low Energy” part of the name, something like 20 mA maximum if I recall correctly, but it is a reasonable question. I’ll look it up and hook one up tomorrow and see if it works.

Awesome! I’d be really curious to hear how it goes. I’ll pick one up if it looks promising, it would be a fun addition to this project I’m tinkering with.

It does work! That’s an Electron (2G) on an AssetTracker, connected to an Adafruit Bluefruit LE SPI. I’m not sure what the use case for this contraption is, but it works. It’s the standard AssetTracker library with my port of the BLE library (Adafruit_BLE in the community libraries, or https://github.com/rickkas7/Adafruit_BLE). I used the Adafruit Bluefruit iOS phone app in UART mode and it prints the location from the asset tracker to the phone via Bluetooth. Neat!


#include "Particle.h"

#include "AssetTracker/AssetTracker.h"

#include "Adafruit_BLE/Adafruit_BLE.h"
#include "Adafruit_BLE/Adafruit_BluefruitLE_SPI.h"

#define BUFSIZE                        128   // Size of the read buffer for incoming data
#define VERBOSE_MODE                   true  // If set to 'true' enables debug output

#define BLUEFRUIT_SPI_CS               D4  	// Note: LIS3DH on the AssetTracker uses A2, don't use that!
#define BLUEFRUIT_SPI_IRQ              D3
#define BLUEFRUIT_SPI_RST              D2    // Optional but recommended, set to -1 if unused
// SPI: SCK=A3, MISO=A4, MOSI=A5
Adafruit_BluefruitLE_SPI ble(&SPI, BLUEFRUIT_SPI_CS, BLUEFRUIT_SPI_IRQ, BLUEFRUIT_SPI_RST);

enum BluetoothState { BLUETOOTH_CONNECT_WAIT, BLUETOOTH_CONNECTED };
BluetoothState bluetoothState = BLUETOOTH_CONNECT_WAIT;

// Creating an AssetTracker named 't' for us to reference
AssetTracker assetTracker = AssetTracker();

const unsigned long CHECK_PERIOD_MS = 10000;

unsigned long lastCheck = 0;


void setup() {
	Serial.begin(9600);

	// Enable Asset Tracker
    assetTracker.begin();
    assetTracker.gpsOn();


    if (ble.begin(VERBOSE_MODE)) {
    	ble.factoryReset();
    	ble.echo(false);

    	// Optional, print some information
    	ble.info();
    }
    else {
    	Serial.println("BLE initialization failed");
    }
}

void loop() {
    // You'll need to run this every loop to capture the GPS output
    assetTracker.updateGPS();

    switch(bluetoothState) {
    case BLUETOOTH_CONNECT_WAIT:
    	if (ble.isConnected()) {
    		Serial.println("BLE connected, switching to data mode");
    		ble.setMode(BLUEFRUIT_MODE_DATA);

    		bluetoothState = BLUETOOTH_CONNECTED;
    	}
    	break;

    case BLUETOOTH_CONNECTED:
    	if (!ble.isConnected()) {
    		Serial.println("BLE disconnected");
    		bluetoothState = BLUETOOTH_CONNECT_WAIT;
    		break;
    	}

    	break;

    }

    if (millis() - lastCheck >= CHECK_PERIOD_MS) {
    	lastCheck = millis();

    	String latLon = assetTracker.readLatLon();
    	Serial.println(latLon);

    	if (bluetoothState == BLUETOOTH_CONNECTED) {
    		ble.println(latLon.c_str());
    	}
    }

}

4 Likes

Hey wow, that’s awesome! I want to try and interact with some BLE sensors and things, and this would be a great way to get some of the data back to the core services. Looks like I’m ordering myself an Adafruit Bluefruit LE SPI!

Can’t wait to give this a spin and see if I get the same success you have.

Thanks again!

Adafruit Bluefruit LE SPI nRF51 is actually a peripheral only, and doesn't run in Central mode, which would cause the module to behave similar to your mobile phone or BLE enabled laptop.

better switch to nRF52832 so you can switch roles from peripheral to centeral by firmware wise.

1 Like

Newbie to BT/BLE, but how easy is it to move to one of the newer/cheaper/volume-ready models? EG SiLabs BGM113 is central/peripheral and 8.7mA peak at $5 (cheapest central role unit I have found) and there are several peripheral only modules for $3.50+. If I did not need FCC module, I am sure there are cheaper…

The project will use a photon+antenna module and BLE and a couple wired sensors with BLe peripheral GATT devices.

I am trying to get this module to work with your Library. I can use the adafruit app to query the device and connect to it but the sketch in your Library produces this outpput and then sits in the error

Adafruit Bluefruit AT Command Example
-------------------------------------
Initialising the Bluefruit LE module: OK!
Performing a factory reset:
AT+FACTORYRESET

<- Couldn't factory reset
Adafruit Bluefruit AT Command Example

I upgraded the firmware on the Adafruit BlueFruit LE to v7.7 which was the latest and i did the facotry reset by holding the DFU low. Any suggestions?

Hello,

I am a super newbie to the bluz world ( 0.5 hours old :stuck_out_tongue_winking_eye:) so I apologize in advance if this seems dumb!

I am working towards adding bluetooth functionality to my Electron such that it gets information from upto 4 local devices over bluetooth, processes and finally, publishes the information onto the Particle cloud via its cellular network. After a lot of research I decided that Bluz would be perfect for this application since it essentially does exactly that.

BUT then i read this...

Gateway Shield Programming Limitations
The gateway shield requires more resources to run then bluz DK. Therefore, some peripherals or resources may not be available or may be limited. The following is a list of differences from bluz DK to the gateway shield: - SPI and I2C are not available on the gateway shield to the user app - Only 1K of RAM is available to the user app - The System.sleep(SLEEP_MODE_CPU) is not available or necessary in the user app - There is no RGB LED for the nrf51822 on the gateway shield

Further, it is advised that no code be placed in the loop() function. This can block the gateway shield from working properly.

Now, my system uses SPI, I2C, UART and Serial1 communication for various sensors and I'm pretty sure my firmware is 1KB with most of the code, including publishes, inside the loop().

Can someone please help me understand this section of the docs...? Thank you :slight_smile:

These would actually be questions best asked at the bluz community.

1 Like

Is there anything out there that can be connected to a Particle Electron to use in BLE central mode? I want to communicate with a BLE device.

I was hoping for BLE support in the Boron, but it seems we won’t see BLE central support anytime soon, so I’d rather hook something up to my Electron.

FYI I have space constraints so I can’t just plug the Electron on top of some kind of shield. It would have to be a module that I connect to the pins on the Electron.

Since two years have passed I figured I’d ask if there are any new options with regards to BLE. RedBear seems to be have disappeared and I don’t know if BluZ has the right form factor (since I need something compatible with my CarLoop OBD2 shield).

Hey, friendly reminder that Bluz is done. So if you have Bluz boards already you are free to use them but new ones... can get complicated...
(but I'm interested to find out any options people might know)

@DrMickeyLauer, the Gen3 devices have built-in BLE but don’t support CAN bus like Gen2 devices (CarLoop will not work). Adding a UART BLE device (eg. HC-10) would need a UART port and a library to support the communications with a phone.

ReadBear’s team was swallowed by Particle, with its hardware being abandoned a couple of years or so ago and BluZ has also closed shop a while back as well.

So the crux of it is that to use CarLoop you are stuck with non-BLE Gen2 devices. You could move to Gen3 devices with external CANbus hardware and supporting libraries but that blows the CatLoop compatibility.

Ok, thanks. This and the WiFi AP situation kills my planned project then. I guess I have to go for something like a raspberry pi. Not a similarly slick form factor, but running a full blown OS, hence another league of possibilities. Seems like a niche no-one wants to pursue.

1 Like