miso が 2024年02月01日19時12分16秒 に編集
初版
タイトルの変更
AE-TYBLE16を使ってボタン電池で長期動作可能なiBeacon開発ボードを作ってみた
タグの変更
AE-TYBLE16
nRF51822
Arduino
メイン画像の変更
記事種類の変更
製作品
本文の変更
# AE-TYBLE16の中身はnRF51822 秋月で購入してから早数年・・・・・・積み基板として余生を過していたこのマイコン。放置しているのは勿体ない、Ultra Low Power Modeで5μAの消費電流を実現出来てBLEも使える。  現実逃避のため、実験用の開発ボードの製作を行なった。 # 参考にしたサイト [AE\-TYBLE16をArduinoIDEで使う\(JLinkなしでBluetooth接続まで\) \#ArduinoIDE \- Qiita](https://qiita.com/KameLong/items/5e7e61f44d4e7a74539c) # Arduino IDEのセットアップ 基本的には参考サイトと殆ど同じなので、以下同様の流れなので割愛。 1. arduino-nRF5を導入 2. nRF5FlashSoftDeviceを導入 3. s130_nrf51_2.0.1_softdevice.hexを導入 4. system_nrf51.cを修正し # 今回作成したiBeacon向けの開発ボード ボタン電池で動くようにしてます。詳細は割愛。  # とりあえずiBeaconとしての動作確認 nRF Connect for Desktop Bluetooth Low Energyで動作確認、ちゃんとUUID見えてるのでOKそうです。  # 転がっていたiBeaconのコードそのまま [ae\-tyble16\-beacon\-arduino/beacon/ibeacon/iBeacon\.ino](https://github.com/MypaceEngine/ae-tyble16-beacon-arduino/blob/master/beacon/ibeacon/iBeacon.ino) をそのまま動かしたところ平均4.81mAと相当厳しい感じでした。これをそのままボタン電池で使うのは(ry  # 最適化して Ultra Low Power Mode & ビーコン間隔を延ばした 平均11.85μAとなり満足。これならボタン電池でも余裕だ。  # 最終的なコード ``` #include <BLEPeripheral.h> #include <iBeacon.h> #include "nrf_soc.h" #include "nrf_nvic.h" iBeacon beacon; void setup() { char* uuid = "a196c876-de8c-4c47-ab5a-d7afd5ae7129"; unsigned short major = 0; unsigned short minor = 0; unsigned short measuredPower = -55; beacon.setAdvertisingInterval(5000); beacon.begin(uuid, major, minor, measuredPower); sd_power_mode_set(NRF_POWER_MODE_LOWPWR); sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE); // This saves power } void loop() { beacon.loop(); // Enter Low power mode sd_app_evt_wait(); // Exit Low power mode // Clear IRQ flag to be able to go to sleep if nothing happens in between sd_nvic_ClearPendingIRQ(SWI2_IRQn); } ```