I am currently trying to use my nrf51822 evaluation board as a beacon. This is working pretty well but I need to have it broadcast its current battery level as well. From what I have seen this means I need to make some kind of interrupt to tell the chip to update the advertising message. Could anyone point me in the direction of some information on this topic?
If it helps I am currently basing everything off of the ble_app_beacon example code and that works just fine.
This is actually implemented in the nrf51-ble-app-temp, available here, so I'd recommend you to take a look on it. In summary, it uses app_timer to trigger a periodic timeout, in which it uses the ADC to measure the battery level, and updates the advertisement data.
Thanks a lot, this is exactly what I needed. I do have one question though, what does the battery reading the ADC sends back correspond to?
I'm not sure I understand your question, but is it covered by either of these?
In that example, the value that comes out of the ADC is converted to a value between 0 and 100 (0x64) and then sent over the air. Please note that I'd rather recommend using manufacturer specific data for this, instead of the service data used by the example. The reason the example uses service data is for backwards compatibility with earlier apps.
Those links help a good bit. I am still struggling with how exactly the calculation works and how I can verify it. Testing my actual battery voltage gives me 3.0v outside of the circuit, testing it in the working circuit gives 2.85v, the ACD however gives 0x55( or 85%) out of 3.0v which would correspond to 2.55v. When using the devlopement board with USB power it reads 0x65 when the max voltage is set to 3.0v in the code. What would be causing this discrepancy?
Ole Morten, your example(nrf51-ble-app-temp) is How does the search?