Search code examples
swiftbluetooth-lowenergyibeaconsensorsbeacon

Where to get started programming iBeacon BLE sensor modules?


I'd really love to learn to program cheap sensors and modules such as this one: barometer sensor nRF51822 bluetooth module ibeacon LPS22HB, CR2032 battery holder, specifically to use within iOS and Swift.

I reached out to the company who makes them and tried researching how to get started multiple times, but I really can't figure out where to start. There are also pre-programmed modules, but my interest is programming these cheap ones to fit my needs.

I have the linked module, and a few others, and they appear and can be connected to using beacon detector apps, but display no understandable info.

I'd like to read the barometer pressure reading to start. Help is highly appreciated, I'd love to start working with these.

EDIT/UPDATE: I was able to read the modules manufacture name on one of many iBeacon scanner apps I tried and their name is Yunjia. With this information I am able to find alot more details online about what I have. One website says for these chips I can use LightBlue (the app I used to find the manufacturer name) to modify, read, and write to the module. Any additional advice is welcomed, I'll be researching and testing things out.

I also found the Schematics along with some additional info hidden in the seller website.

Edit 2: I found the manufactures little YouTube channel with some info, looks like I just have to do lots of research and testing and learn everything. https://www.youtube.com/channel/UCvqhWNqDE-v0je0X8XAEF2Q It contains some video instructions.

Edit 3: My short term goal of reading the barometer data was a success! After tons of digging I found I just had to write a value of 0x01 to turn on all sensors, then I was flooded with data and the barometer pressure in bytes which could be translated to the actual amount. Write 0x00 to trun off all sensors.


Solution

  • Apple's iBeacon framework is dirt-simple and very easy to use. It allows you to listen for beacons based a unique UUID, major id, and minor ID. It lets you know when a beacon enters or leaves range, and provides crude (immediate, near, medium, and far) distance values. You can create "beacon regions" that will notify your app when you enter or leave them. That's about it.

    If you want to do something like read barometric pressure or temperature readings, you will need to either write your own low-level BLE code or use an existing library. My guess is that these modules are using very standard hardware and that you should be able to find libraries to read their specialized data.

    Failing that, you will need specifications on their BLE interface and need to learn how to write Apple Core Bluetooth code. (The link you posted has zero specifications for the units. The only thing it provides is the numbers "nRF51822 bluetooth module ibeacon LPS22HB" (It's not in well-formed English so I don't know how to parse those descriptive terms. I'd google those numbers) Note that Core Bluetooth is a fairly low-level framework and not very easy to learn.

    EDIT:

    Googling "nRF51822", that is apparently an ARM based chip that includes radio hardware that supports BLE. It sounds like that is a general-purpose chip that vendor would use to build a BLE module. Given that, you'd probably have to reverse-engineer it to figure out how it works.

    The "LPS22HB" appears to be a solid state pressure sensor that can be used to build a barometric pressure measurement device. It's no doubt interfaced with the "nRF51822". Without specs you're going to have a very hard time figuring out how it's interfaced however.