Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Arjun S
Created September 2, 2024

SmartNav : An Navigation System for Visually Impaired Users.

Develop an indoor navigation system using beacon technology, tactile maps, and voice-guided instructions to empower impaired individuals.

20
SmartNav : An Navigation System for Visually Impaired Users.

Things used in this project

Story

Read more

Schematics

SmartNav : An Navigation System for Visually Impaired Users.

Code

SmartNav : An Navigation System for Visually Impaired Users.

C/C++
This code sets up a Bluetooth Low Energy (BLE) beacon using the ArduinoBLE library on an Arduino board. It defines a BLE service and characteristic, and then advertises the beacon's presence. When a central device (e.g., a smartphone) connects to the beacon, the code sends a predefined beacon data packet through the characteristic.
#include <ArduinoBLE.h>

BLEService beaconService("181A");
BLECharacteristic beaconCharacteristic("2A19", BLERead | BLENotify, 20);

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

  if (!BLE.begin()) {
    Serial.println("Failed to initialize BLE!");
    while (1);
  }

  BLE.setLocalName("Beacon");
  BLE.setAdvertisedService(beaconService);
  beaconService.addCharacteristic(beaconCharacteristic);
  BLE.addService(beaconService);

  BLE.advertise();
  Serial.println("Bluetooth device active, waiting for connections...");
}

void loop() {
  BLEDevice central = BLE.central();

  if (central) {
    Serial.print("Connected to central device: ");
    Serial.println(central.address());

    while (central.connected()) {
      byte beaconData[] = {0x02, 0x01, 0x06, 0x1A, 0xFF, 0x4C, 0x00, 0x02, 0x15, 0xE2, 0xC5, 0x6D, 0xB5, 0xDF, 0xFB, 0x48, 0xD2, 0xB0, 0x60, 0xD0, 0xF5, 0xA7, 0x10, 0x96, 0xE0, 0x00};
      beaconCharacteristic.setValue(beaconData, sizeof(beaconData));
    }

    Serial.print("Disconnected from central device: ");
    Serial.println(central.address());
  }
}

Credits

Ranganatha G S

Posted by Arjun S
Thanks to Ranganatha G S and Arjun S.

Comments