Scanning of beacon devices and printing their uuid on cloud

hi to everyone,
i want to scan beacon devices from the argon and show the number f beacon devices and print their uuid .

now for doing so i am first writing code for printing the total number of beacon devices near my argon and for that i have written this code.

const size_t SCAN_RESULT_MAX = 30;
BleScanResult scanResults[SCAN_RESULT_MAX];

void setup() {

void loop() {
    char buffer[20];
    // int a=10;
    int count = BLE.scan(scanResults, SCAN_RESULT_MAX);
    // delay(2000);   

now on doing so in my console in event name
no different values are being printed like this shown

now question is why are different values being printed at a time …
as BLE.scan is counting for all the number of beacons nearby the argon , so shouldn’t it print one fixed number,instead of different

Where is your BLE.on() call?
Also what beacon advertising interval are all your beacons using?
Could it be that during your 0.5 sec sometimes only one, two or none of the beacons may be advertising?

itis 5sec which is default as given in the docs …and i am using only 1 beacon device .

If that 5 seconds applies to the beacon this will account or the cases where you see 0 and 1 - as your 0.5sec scan period might catch the beacon (1) or not (0).
Furthermore, could it be that you have another 3rd party device also acting as beacon - this would account for the 2s.

5 sec is the interval for scanning the beacons by central device which is by default mentioned in the docs of REFERENCE by iot particle.
here my central device is Argon and peripheral is beacon.

but in the above program i changed that interval to 0.5 secs

one point to clear …(just to ask whether i am thinking right or not)
ble .scan() will only return the no of beacon devices which are near the argon central device???

if yes then will i get the no of bytes in advertisement data …(asking)- by the statement scanResult->advertisingData.getData(get_data, sizeof(get_data));
here scanResult is the object of the class BleScanResult
and get_data is my buffer of length 30

But you are overriding the default and that was all we knew of your tests :wink:

That depends on your definition of “near”

1 Like

see here is my terminal of consule.

and even if i try with default or by custum it is still sending different values even though i have only one beacon and both beacon and argon are placed next to each other

Then it is probably time to have a closer look at the actual advertise data the found beacons send.

do you mean scanResult->advertisingData.get(get_data, sizeof(get_data))?
If so, yes the return value of that call should return the actual count of data received (up to sizeof(get_data).

okay then by accessing the get_data buffer i should get the advertisement data…??

let me just try this then i respond back to u

Also check scanResult->address to see whether you are catching the same beacon multiple times.


from the past 1 hour on uploading the program from web ide this thing is coming …dont know what happened all of sudden
and in the web ide it is just showing TIME RUN OUT error

  1. my particle device is not getting flash from web ide
    when i run the diagnostics test it shows that their is one problem and
    also on signaling and ping it from the console it shows that device is not reachable by the particle cloud.
    Also it automatically gets disconnected to wifi and cloud on its own without any external activity randomy and then gets connected to both wifi and cloud .

  2. But argon keep on sending the data to the cloud as per the code which is last flashed on it and led status is cyan colour blinking …which means it is connected to cloud.

what is issue i cant figure out.

Your code is probably jamming up the cloud communication for prolonged periods.

Try Safe Mode to flash new code OTA.

It should be breathing - blinking means it’s not currently connected but tries to reconnect.

Try adding SYSTEM_THREAD(ENABLED) to your next code and see if this helps.

Even if i try to upload blink sketch that also is not getting flashed … I am here attaching a url of the video u can see that .

This is what happening randomly it randomly gets disconnected and tries to connect to net and cloud .

And this is what happening on uploading the code

beacouse of this thing i am trying to re-update the device OS from workbench
using the command FLASH APPLICATION AND DEVICE OS in command palette and putting the ARGON in DFU mode …but on doing so it here agin showing error
showing error code 2 .

now hoe to get ahead of this problem