iThe software for this project can now be found on GitHub!
To "compile" this software, you need the BlueGiga tools. These unfortunately only run on Windows and are different from the tools used for the BGM111. This is not the place to document the complete build process, please refer to the documentation from Silicon Labs.
A little explanation about the software. The chip and files used are configured in the SoundBeacon.bgproj file. This is the top level file loaded by the BlueGiga tools.
The hardware.xml configures the pins used for PWM output to generate the beeps. It does not enable the sleep timer, which was interfering with the PWM generation. Unfortunately this means the system draws ~9 mA right now, much more than a simple beacon should. I will have to optimize this later, but it seem to work right now with the oversized power system.
In gatt.xml the BLE services and characteristics are defined. Some of this stuff is boiler plate. The useful stuff is in the Battery Service, Immediate Alert and Telemetry services. The Battery Service and Immediate alert are defined in accordance with their Bluetooth SIG definitions. The Immediate Alert is used by the app to activate the sound signal. The Battery Service reports the battery percentage. Since LiFePO4 has a very flat discharge curve, it's hard to estimate a good percentage from the voltage, so this is not the most useful information. That is why I added a custom Telemetry service with a Battery Voltage characteristic (in 1/10 V), which is more useful to me.
The meat of the program is in the script.bgs file.
In the system boot event handler, hardware is configured and advertisement parameters are set. The advertisement rate is according to Apple's recommendations for iBeacons. The fast advertisement rates will burn more battery power than needed, but we have it available in this system. Compatibility with Apple iPhone is very important for this system since most blind people use iPhones because of superior accessibility.
The advertisement message is constructed to appear as an iBeacon. Major and minor numbers will have to be customized per beacon.
There is code to do ADC conversion for the Battery Percentage and Battery Voltage characteristics. There is also code to respond to the Immediate Alert write that triggers the sound signal to start. Generation of the beeps is handled by the timer event.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.