BLE link between two Argons


I’ve been working on a uni assignment where we need to establish a BLE link between Argons, with one argon being the “Central” and the others “peripheral”.
I’ve written code to get the peripheral devices to behave as BLE peripherals, but am having trouble getting the “central” to read the data from the peripherals. The peripherals have their own UUIDs for both the device itself and the individual sensors. I can see the devices using Lightblue on my phone, and can read the data ok, but can’t find a way to get the master Argon to do the same.
The examples and forum posts I’ve seen all seem to be for commercial peripheral devices with predefined characteristics(like the heart rate monitor example). I found one example that was trying to connect to a specific device, but it was looking for a six byte address not a uuid?
Here is a simplified version of the sensor code I’ve written, (the real version has more sensors and other functions.) I’d be very grateful if someone could point me towards a solution that would allow me to have another Argon read the BLE characteristics. Ideally just by having the target UUIDs hard coded in the “central” program.
Thanks for any help.


  SYSTEM_MODE(MANUAL) //Disables WiFi and particle cloud functionality, greatly improves boot time after flashing.
  #define Serial_Baud 9600
  #define SAMPLE_PERIOD 5000

//Pin definitions:
  #define LDR_PIN A0

//Bluetooth UUIDs & services.
  const char* serviceUUID   = "9EC9FA46-E01B-4A2E-974C-D577CDFAE788"; //Service UUID
  const char* LightUUID     = "172A2E64-6D0D-4C6F-B898-9BD6E5E00E75"; //Light(LDR) UUID

  BleUuid Node2Service(serviceUUID);
  BleCharacteristic LIGHTCharacteristic("LIGHT", BleCharacteristicProperty::READ, LightUUID, serviceUUID, onDataReceived,(void*)LightUUID);

//Timer setup:
  Timer master_timer(SAMPLE_PERIOD, sample_sensors);

void setup(){

  //Add BLE characteristics

  // Advertising data
   BleAdvertisingData advData;

  // Add the Node_2 service

  // Start advertising

  //Start Timer

void loop(){


//This routine serves as the timer ISR, sampling all sensors and updating BLE characteristics.
void sample_sensors(){


// Static function for handling Bluetooth Low Energy callbacks
static void onDataReceived(const uint8_t* data, size_t len, const BlePeerDevice& peer, void* context) {}

You don’t connect to UUIDs.
You are connecting to a device via its MAC address, the advertised UUIDs are merely used to distinguish whether you want to connect to a particular device. Once you have decided (during scanning) which device you want you obtain the MAC of that particular device and use it to establish the connection.

So I guess that particular example is what you want to investigate a bit closer and try to extract the parts you need for your assignment.

BTW, when you refer to “one example” it would be good to also provide a linkt to it so we can have a look and make sure to be on the same page :wink:


Is there a way to determine the MAC addresses of my Argons in advance? ie to find the local Mac address?

I guess you should be able to use the Lightblue app.
You can also use BLE.address() to request the address on the device itself (after first calling BLE.begin() tho’).

However, the real life way of doing it is to first scan for available devices, traverse the list of found devices for the one you are looking for (e.g. by name, by service UUDI or similar) and then take it’s address from the scan results.

Thanks I’ll try that.

I’ve also been reading through Simple BLE Example (Scan Advertising Devices, List Details, Connect to One Sensor Device)
It looks very relevant to my problem. However all of the links neal_tommy posts to his revisions just open up the Web IDE and an empty file. Is this just cause he has since deleted the files? Or am I doing something wrong?

Thanks again for your help.

Yup, that’s the downside of shared links. Once the “parent” project gets deleted all previously shared revisions of that project also get purged.

However, I still got some BLE code that might be useful for you

@dave89 - sorry about that! Let me know which ones you’re looking for and I’d be happy to repost the links to those.

I eventually got a BLE Peripheral device working, emulating a Bicycle Speed Sensor on a stationary bike. It connected up to my watch and worked perfectly. I still have some of the code elements (much that @ScruffR helped me with).




Please do repost the links for Scanning BLe Devices Example code.

@RWB - let me know if this works. Or maybe even this one.