ESP8266 HM-10 IBeacon Proximity

Published

Introduction: ESP8266 HM-10 IBeacon Proximity

About: Arduino maniac and owner of IoT company. IT Enterprise Architect

With this tiny project you will be able to detect the nearest iBeacon Device to your thing.

Step 1: List of Materials

You need:

1. One NodeMCU

2. One HM-10

3. Four Dupont wires female-female

4. One PC

5. One USB Micro Cable

6. Arduino IDE

7. Library from https://github.com/dinosd/BLE_PROXIMITY

Step 2: Connecting Things

NodeMCU 3V3 to HM-10 VCC

NodeMCU GND to HM-10 GND

NodeMCU D5 to HM-10 TX

NodeMCU D6 to HM-10 RX

Step 3: Sketch

#include <SoftwareSerial.h>
#include <CDBLEProx.h>
void ble_event(BLE_PROXIMITY_EVENT eventArgs);
SoftwareSerial sw(D5,D6);
CDBLEProximity ble(&sw,ble_event);
void setup() {
  Serial.begin(57600);
  ble.begin();
}
void loop() {
  ble.update();
}
void ble_event(BLE_PROXIMITY_EVENT eventArgs) {
    if (eventArgs.eventID==BLE_EVENT_ON_DEVICE_LOST) {
        Serial.println("No device");  
        Serial.println("");
    }
    if (eventArgs.eventID==BLE_EVENT_ON_DEVICE_APPROACH) {
        Serial.println("New device");
        Serial.print("MAC: "); Serial.println(eventArgs.device.mac);
        Serial.print("HL : "); Serial.println(eventArgs.device.hilo);
        Serial.print("HI : "); Serial.println(eventArgs.device.hi);
        Serial.print("LO : "); Serial.println(eventArgs.device.lo);
        Serial.print("SIG: "); Serial.println(eventArgs.device.rssi);
        Serial.println("");
    }
    if (eventArgs.eventID==BLE_EVENT_ON_DEVICE_MOVED) {
        Serial.println("Device moved");
        Serial.print("MAC: "); Serial.println(eventArgs.device.mac);
        Serial.print("HL : "); Serial.println(eventArgs.device.hilo);
        Serial.print("HI : "); Serial.println(eventArgs.device.hi);
        Serial.print("LO : "); Serial.println(eventArgs.device.lo);
        Serial.print("SIG: "); Serial.println(eventArgs.device.rssi);
        Serial.println("");
    }
}

Share

Recommendations

  • Make it Move Contest

    Make it Move Contest
  • Casting Contest

    Casting Contest
  • Microcontroller Contest

    Microcontroller Contest
user

We have a be nice policy.
Please be positive and constructive.

Tips

Questions

2 Comments

giving error

C:\Users\SACHIN~2\AppData\Local\Temp\arduino_build_449536\libraries\BLE_PROXIMITY-master\CDBLEProx.cpp.o (symbol from plugin): In function `CDBLEProximity::CDBLEProximity(SoftwareSerial*, void (*)(BLE_PROXIMITY_EVENT))':

(.text+0x0): multiple definition of `CDBLEProximity::CDBLEProximity(SoftwareSerial*, void (*)(BLE_PROXIMITY_EVENT))'

C:\Users\SACHIN~2\AppData\Local\Temp\arduino_build_449536\sketch\CDBLEProx.cpp.o (symbol from plugin):(.text+0x0): first defined here

C:\Users\SACHIN~2\AppData\Local\Temp\arduino_build_449536\libraries\BLE_PROXIMITY-master\CDBLEProx.cpp.o (symbol from plugin): In function `CDBLEProximity::CDBLEProximity(SoftwareSerial*, void (*)(BLE_PROXIMITY_EVENT))':

(.text+0x0): multiple definition of `CDBLEProximity::CDBLEProximity(SoftwareSerial*, void (*)(BLE_PROXIMITY_EVENT))'

C:\Users\SACHIN~2\AppData\Local\Temp\arduino_build_449536\sketch\CDBLEProx.cpp.o (symbol from plugin):(.text+0x0): first defined here

C:\Users\SACHIN~2\AppData\Local\Temp\arduino_build_449536\libraries\BLE_PROXIMITY-master\CDBLEProx.cpp.o (symbol from plugin): In function `CDBLEProximity::CDBLEProximity(SoftwareSerial*, void (*)(BLE_PROXIMITY_EVENT))':

(.text+0x0): multiple definition of `CDBLEProximity::sendEmptyEvent()'

Thanks for sharing :)