memoryleak
Published © MIT

DIY iBeacon and Beacon Scanner with Raspberry Pi and HM13

Made your own iBeacon and track it with a Raspberry Pi as a beacon scanner!

BeginnerFull instructions provided1 hour13,742

Things used in this project

Hardware components

Seeeduino V4.2
Seeed Studio Seeeduino V4.2
×1
Seeed Studio Grove - Blueseeed - Dual model (HM13)
×1
Raspberry Pi 4 Model B
Raspberry Pi 4 Model B
×1
Li-Ion Battery 1000mAh
Li-Ion Battery 1000mAh
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

HM13 Scheme

Code

Turn HM13 into iBeacon

Arduino
// Use Library Manager or download here: https://github.com/sparkfun/SparkFun_HM1X_Bluetooth_Arduino_Library
#include <SparkFun_HM1X_Bluetooth_Arduino_Library.h>
#include <SoftwareSerial.h>

HM1X_BT bt;
char * uuid0 = "01234567";
char * uuid1 = "89ABCDEF";
char * uuid2 = "01234567";
char * uuid3 = "89ABCDEF";

SoftwareSerial btSerial(6, 7);

void setup() {
  Serial.begin(9600); // Serial debug port @ 9600 bps

  // bt.begin --
  // in this case takes a HardwareSerial connection and
  // a desired serial baud rate.
  // Returns true on success
  if (bt.begin(btSerial, 9600) == false) {
    Serial.println(F("Failed to connect to the HM-13."));
    while (1) ;
  }

  // Enable iBeacon
  if (bt.iBeacon(true)) {
    Serial.println("iBeacon enabled");
  } 

  // Configure iBeacon UUID's
  if (bt.setiBeaconUUID(uuid0, uuid1, uuid2, uuid3) == HM1X_SUCCESS) {
    Serial.println("Set iBeacon UUID");
  }
  Serial.println("UUID: " + String(bt.getiBeaconUUID()));

  // Set iBeacon major version
  if (bt.setiBeaconMajor(65011) == HM1X_SUCCESS) {
    Serial.println("Set iBeaconMajor");
  }

  // Set iBeacon minor version
  if (bt.setiBeaconMinor(12345) == HM1X_SUCCESS) {
    Serial.println("Set setiBeaconMinor");
  }

  // Reset to re-configure device
  if (bt.reset() == HM1X_SUCCESS) {
    Serial.println("Ready to iBeacon!");
  }
}

void loop() {
  if (bt.available()) {
    Serial.write((char) bt.read());
  }
  if (Serial.available()) {
    bt.write((char) Serial.read());
  } 
}

Credits

memoryleak

memoryleak

5 projects • 7 followers
A soft and hardware engineer motivated by interest and fun

Comments