{"id":1059,"date":"2013-10-03T22:20:55","date_gmt":"2013-10-04T02:20:55","guid":{"rendered":"http:\/\/tim.cexx.org\/?p=1059"},"modified":"2013-10-03T22:20:55","modified_gmt":"2013-10-04T02:20:55","slug":"notes-to-myself-test-a-bluetooth-low-energy-device-on-raspberry-pi-the-quick-way","status":"publish","type":"post","link":"https:\/\/tim.cexx.org\/?p=1059","title":{"rendered":"Notes to myself: Test a Bluetooth Low Energy device on Raspberry Pi, the quick way"},"content":{"rendered":"<p>Testing if the new nRF8001-based Mosquino BLE shield I built actually works.<br \/>\nWith the unmodified <a href=\"https:\/\/github.com\/guanix\/arduino-nrf8001\">library<\/a> and example code, it purports itself to the a Nordic heartrate monitor.<\/p>\n<p><center><a href=\"https:\/\/tim.cexx.org\/wp-content\/uploads\/mq-shield-ble.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tim.cexx.org\/wp-content\/uploads\/mq-shield-ble-300x151.jpg\" alt=\"mq-shield-ble\" width=\"300\" height=\"151\" class=\"aligncenter size-medium wp-image-1061\" srcset=\"https:\/\/tim.cexx.org\/wp-content\/uploads\/mq-shield-ble-300x151.jpg 300w, https:\/\/tim.cexx.org\/wp-content\/uploads\/mq-shield-ble-1024x516.jpg 1024w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/center><\/p>\n<p>Much of the below based on <a href=\"http:\/\/mike.saunby.net\/2013\/04\/raspberry-pi-and-ti-cc2541-sensortag.html\">Michael Saunby&#8217;s blog post on<\/a> checking out a TI SensorTag.<\/p>\n<p>Install bluez and hcitool (plus any dependencies). As of today, current version available from a stock raspbian is 4.99-2. NOTE: &#8220;gksu synaptic&#8221; from the console to get a working graphical package manager, if you&#8217;re into that sort of thing. (&#8220;Gtk-WARNING **: cannot open display: :0&#8221; probably means you used sudo instead of gksu; bad dog.)<\/p>\n<p>Then&#8230;<\/p>\n<p>$ sudo hcitool hci0 up<br \/>\n$ sudo hcitool lescan<\/p>\n<p>If all goes well, output like:<\/p>\n<p>LE Scan &#8230;<br \/>\nDF:32:3A:73:A3:1C Nordic HRM V1.0<br \/>\nDF:32:3A:73:A3:1C (unknown)<\/p>\n<p>If that&#8217;s your device, congratulations, it&#8217;s working!<\/p>\n<p>Connecting to it&#8230;<\/p>\n<p>$ gatttool -b DF:32:3A:73:A3:1C &#8211;interactive<br \/>\n[   ][DF:32:3A:73:A3:1C][LE]> connect<br \/>\n[CON][DF:32:3A:73:A3:1C][LE]> char-read-hnd 0x01<br \/>\n[CON][DF:32:3A:73:A3:1C][LE]><br \/>\nCharacteristic value\/descriptor: 00 18<br \/>\n[CON][DF:32:3A:73:A3:1C][LE]> <\/p>\n<p>Don&#8217;t ask me how to find out the handles your device supports or what the resulting data means; that&#8217;s an exploration for another day&#8230;<\/p>\n<p>Bonus trick: make the computer beep everytime it gets an advertising packet:<\/p>\n<p>$ sudo stdbuf -oL hcitool -i hci0 lescan | while read; do beep -l 20 -f 1000; done<\/p>\n<p>Good for range testing (I have not tested it).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Testing if the new nRF8001-based Mosquino BLE shield I built actually works. With the unmodified library and example code, it purports itself to the a Nordic heartrate monitor. Much of the below based on Michael Saunby&#8217;s blog post on checking out a TI SensorTag. Install bluez and hcitool (plus any dependencies). As of today, current [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_FSMCFIC_featured_image_caption":"","_FSMCFIC_featured_image_nocaption":"","_FSMCFIC_featured_image_hide":"","iawp_total_views":0,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1059","post","type-post","status-publish","format-standard","hentry","category-general"],"_links":{"self":[{"href":"https:\/\/tim.cexx.org\/index.php?rest_route=\/wp\/v2\/posts\/1059","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tim.cexx.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tim.cexx.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tim.cexx.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tim.cexx.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1059"}],"version-history":[{"count":3,"href":"https:\/\/tim.cexx.org\/index.php?rest_route=\/wp\/v2\/posts\/1059\/revisions"}],"predecessor-version":[{"id":1063,"href":"https:\/\/tim.cexx.org\/index.php?rest_route=\/wp\/v2\/posts\/1059\/revisions\/1063"}],"wp:attachment":[{"href":"https:\/\/tim.cexx.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1059"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tim.cexx.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1059"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tim.cexx.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1059"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}