Arduino Uno + BLE + iOS

等待 Apple Watch 发售的时间里, 完成了一只 "电离辐射探测器"


问: Wow, 听起来很 Cool 的样子, 但为什么要做这个啊? 
答: 为了更多的了解自己所处的这个大环境. 
除了嘴里能感受到的 涩涩的 高含碱量的自来水,
除了眼睛和鼻子能感受到的 昏天暗地的 饱含PM25粉尘的 让人呼吸困难的雾都空气,
还有看不见摸不着的也品尝不到的, 环境射线辐射
问: 辐射? 这.. 我们用来干嘛?
答: 我们要把它做在手表上, 然后随身携带, 任何时候 它要是发出 "嘀-嘀嘀--" 的声音, 那就是告诉你: 恭喜, 你可能找到原子弹材料 找到铀矿了, 而且它现在正在照耀着你, 不管你是在驴行 在喜马拉雅翻山越岭 还是新疆穿越沙漠 或者山洞探险.
问: 呃.. 还有么?
答: 还不够么
    1. 2011年3月日本福岛核电站事故 [1]
    2. 2014年5月南京(探伤)辐射源丢失
问: 听说了, 还有没有"近"一点的?
答: 你家厨房的大理石橱柜, 你客厅卧室的地板墙面.
问: 好吧
答: 嗯
问: 那它还有别的功能吗?
答: 你还想要什么功能. 能装洗衣粉 能榨果汁...
问: ... 你继续...

Arduino Uno + BLE module + iOS

Arduino + BLE module + iOS

  1. Arduino Uno * 1 (or Arduino mini pro)
  • BLE module (XM-10) * 1
  • iOS 7.0
  • Arduino IDE 1.0.6 (b1.5.8 will not work with RBL_nRF8001)

1. Connect BLE to arduino

1-1. Pins connect:

  • BLE TX ---> Arduino Pin 10 soft-RX
  • BLE RX ---> Arduino Pin 11 soft-TX
  • BLE GND ---> Arduino GND
  • BLE VCC ---> Arduino 3.3V

1-2. Codes for Arduino connection test:

Upload to Arduino then Open the serial monitor at 9600 baud.

Commands

The BLE module uses AT Commands to read and write system information, they do not need to be followed by a line break. If you don''t get a response when you enter a command something may not be connected properly.

When you''re connected and type in serial monitor:

# AT
OK
# AT+NAME
XM-10
# AT+NAME=MyBLE-10
OK

2. Codes for iOS

RedBearLab 的开源库, 已经有很好的 BLE for iOS framework ( based on Apple''s CoreBluetooth ).

兼容 CC2540 芯片. link

  1. 下载, 打开范例: SimpleChat
  • 修改 UUID (参数来自于 XM-10 的规格说明 pdf)
// BLEDefines.h
#define RBL_SERVICE_UUID                         "0xFFE0"
#define RBL_CHAR_TX_UUID                         "0xFFE1"
#define RBL_CHAR_RX_UUID                         "0xFFE1"
  • 编译测试.

2. Talk to iOS With Arduino using Bluetooth LE

剩下的这里就是具体的消息协议什么的. 略之


3. Final

Family

iOS app interface


Arduino Uno + BLE + iOS
Share this