{"id":1649,"date":"2020-07-06T18:39:44","date_gmt":"2020-07-06T17:39:44","guid":{"rendered":"https:\/\/ofalcao.pt\/blog\/?p=1649"},"modified":"2020-07-06T18:39:44","modified_gmt":"2020-07-06T17:39:44","slug":"installing-bluepy-on-ev3","status":"publish","type":"post","link":"https:\/\/ofalcao.pt\/blog\/2020\/installing-bluepy-on-ev3","title":{"rendered":"Installing &#8216;bluepy&#8217; on EV3"},"content":{"rendered":"\n<p>Another python BLE library &#8211; not the most maintained, certainly not the most trendy but at the moment the only one I managed to install and use on EV3 (running ev3dev of course): <a href=\"https:\/\/github.com\/IanHarvey\/bluepy\">bluepy<\/a>.<\/p>\n\n\n\n<p>Short instructions:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>start from a totally fresh ev3dev installation<\/li><li>enable Wi-Fi and Bluetooth (assuming you have a USB hub with a compatible Wi-Fi dongle and a compatible BLE dongle)<\/li><li>update:<\/li><\/ul>\n\n\n\n<p><code>sudo apt update<br>sudo apt upgrade<br>sudo apt dist-upgrade<\/code><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>install &#8216;pip&#8217; and &#8216;bluepy&#8217; requirements (~15 min):<\/li><\/ul>\n\n\n\n<p><code>sudo apt install python3-pip libglib2.0-dev libcap2-bin<\/code><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>update &#8216;pip&#8217;:<\/li><\/ul>\n\n\n\n<p><code>python3 -m pip install --upgrade pip<\/code><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>install &#8216;bluepy &#8216;at last (~25 min):<\/li><\/ul>\n\n\n\n<p><code>python3 -m pip install bluepy<\/code><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>give proper permissions:<\/li><\/ul>\n\n\n\n<p><code>sudo setcap 'cap_net_raw,cap_net_admin+eip' ~\/.local\/lib\/python3.5\/site-packages\/bluepy\/bluepy-helper<\/code><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>test it:<\/li><\/ul>\n\n\n\n<p><code>robot@ev3dev:~$ \/home\/robot\/.local\/bin\/blescan<br>Scanning for devices\u2026<br>Device (new): 90:84:2b:4b:bf:59 (public), -70 dBm<br>Flags: &lt;06><br>Tx Power: &lt;00><br>Incomplete 128b Services:<br>Complete Local Name: 'Pybricks Hub'<\/code><\/p>\n\n\n\n<p>A few notes:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>I used &#8216;ev3dev-stretch-ev3-generic-2020-04-10&#8217; that&#8217;s the same version that LEGO EDECUATION calls &#8216;EV3 Micropython 2.0&#8217; and already includes Pybricks<\/li><li>bluepy uses a &#8220;bluepy-helper&#8221; based on BlueZ&#8217;s gatttool, it has been deprecated and sooner or later will be removed from BlueZ stack<\/li><li>there are some known bugs in &#8216;bluepy&#8217; that have been fixed in a fork, see &#8216;<a href=\"https:\/\/pypi.org\/project\/ble-serial\/\">ble-serial<\/a>&#8216; instructions on how to install it if you think it might help<\/li><\/ul>\n\n\n\n<p>this had been used with <a href=\"https:\/\/github.com\/JorgePe\/randomideas\/blob\/master\/topgear-controller.py\">this script<\/a> to control the Top Gear technic car after flashing the Control+ hub with Pybricks 3.0.0a firmware:<\/p>\n\n\n\n<figure class=\"wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Pybricks control over Nordic UART Service (part II)\" width=\"840\" height=\"473\" src=\"https:\/\/www.youtube.com\/embed\/zvy0BS-2rJE?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>sometimes the script fails after establishing the connection with the Nordic UART Service, not sure why yet.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Another python BLE library &#8211; not the most maintained, certainly not the most trendy but at the moment the only one I managed to install and use on EV3 (running ev3dev of course): bluepy. Short instructions: start from a totally fresh ev3dev installation enable Wi-Fi and Bluetooth (assuming you have a USB hub with a &hellip; <a href=\"https:\/\/ofalcao.pt\/blog\/2020\/installing-bluepy-on-ev3\" class=\"more-link\">Continuar a ler<span class=\"screen-reader-text\"> &#8220;Installing &#8216;bluepy&#8217; on EV3&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[4],"tags":[217,360,223],"series":[],"class_list":["post-1649","post","type-post","status-publish","format-standard","hentry","category-admiravel-mundo-novo","tag-ble","tag-bluepy","tag-python"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2Mhyv-qB","_links":{"self":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts\/1649","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/comments?post=1649"}],"version-history":[{"count":0,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts\/1649\/revisions"}],"wp:attachment":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/media?parent=1649"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/categories?post=1649"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/tags?post=1649"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/series?post=1649"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}