How to use ble Beacon with gr lychee

Hi , Ineed to interface a bluetooth beacon with gr lychee and get its position.Any code samples or helpful datas?

  • These AT commands will help to get the range of BLE BEACON or any other BLE modules.

    AT+BLESCAN=<enable>[,<interval>] //This command returns the following string

    +BLESCAN:<addr>,<rssi>,<adv_data>,<scan_rsp_data>,<addr_type>

    OK

    here <addr> is the mac id of available BLE devices
    <rssi> is the range of the device, it is a negative integer value this value is used to calculate the device distance.Higher the value,nearer the device


    example AT command set

    AT+BLEINIT=1 // initialise BLE as client
    AT+BLESCAN=1,3 //enables BLE scan for 3 seconds and returns available bluetooth devices and their rssi value
  • In reply to jihas:

    Hi Jihas,

    Have you already found a sample code or any information to help you interface a BLE Beacon with GR-LYCHEE?

    JB
    RenesasRulz Forum Moderator

    https://renesasrulz.com/
    https://academy.renesas.com/
    https://en-us.knowledgebase.renesas.com/

  • In reply to JB:

    The below documents may describe about iBeacon(page 76). Could you confirm that?
    www.espressif.com/.../esp32_at_instruction_set_and_examples_en.pdf
    I've not tried that, but that is interesting me. So when I have a chance, I'll try that.
  • In reply to Okamiya Yuuki:

    Yes I tried that commands and it worked. But sometimes AT+BLESCAN gives me an error. It may be beacuse im using esp32's other functions too in the code.Then i deinit BLE after every scan and then init again and the error is gone.
  • In reply to jihas:

    code

    #include <Arduino.h>
    #include <ESP32.h>
    BufferedSerial esp32(P7_1, P0_1, 1024);
    ATParser_os esp_parser(esp32);

    /*Serial monitor baudrate 9600*/

    void setup() {
    pinMode(PIN_LED_GREEN, OUTPUT);
    pinMode(PIN_LED_YELLOW, OUTPUT);
    pinMode(PIN_LED_ORANGE, OUTPUT);
    pinMode(PIN_LED_RED, OUTPUT);
    pinMode(PIN_ESP_IO0, OUTPUT);
    pinMode(PIN_ESP_EN, OUTPUT);
    pinMode(PIN_SW0, INPUT);
    pinMode(PIN_SW1, INPUT);

    esp32.baud(115200);
    digitalWrite(PIN_ESP_IO0, HIGH);
    digitalWrite(PIN_ESP_EN, LOW);
    delay(10);
    digitalWrite(PIN_ESP_EN, HIGH);
    esp_parser.setTimeout(1500);
    if (esp_parser.recv("ready")) {
    printf("ESP32 ready\r\n");
    }
    else {
    printf("ESP32 error\r\n");
    digitalWrite(PIN_LED_RED, HIGH);
    while (1);
    }
    esp_parser.setTimeout(5000);
    }

    void loop()
    {
    int value;
    if(esp_parser.send("AT+BLEINIT=1") && esp_parser.recv("OK"))
    {
    printf("OK\n");
    }
    /*Change the mac id with yours
    example
    my beacon mac id is 0c:b2:b7:7f:ad:e8
    esp_parser.recv("+BLESCAN:0c:b2:b7:7f:ad:e8,%d,",&value );
    */
    esp_parser.send("AT+BLESCAN=1,1") && esp_parser.recv("+BLESCAN:0c:b2:b7:7f:ad:e8,%d,",&value );
    printf("rssi=%d\n",value);
    delay(3000);

    }