{"id":4393,"date":"2013-04-21T16:09:18","date_gmt":"2013-04-21T13:09:18","guid":{"rendered":"http:\/\/vaxxi.net\/log\/?p=4393"},"modified":"2013-04-21T16:25:36","modified_gmt":"2013-04-21T13:25:36","slug":"bitwizard-and-raspberry-pi-fun","status":"publish","type":"post","link":"https:\/\/vaxxi.net\/log\/bitwizard-and-raspberry-pi-fun\/","title":{"rendered":"bitwizard and raspberry pi fun"},"content":{"rendered":"<p>I&#8217;ve bought two expansion boards from <a href=\"http:\/\/bitwizard.nl\/\">Bitwizard NL<\/a> for the all wonderful <a href=\"http:\/\/www.raspberrypi.org\/\">Raspberry PI<\/a>: one <a href=\"http:\/\/bitwizard.nl\/wiki\/index.php\/User_Interface\">RPi User Interface<\/a> and one <a href=\"http:\/\/bitwizard.nl\/wiki\/index.php\/Relay\">Big Relay<\/a>. The UI because no DIY electronic project is complete without an LCD and the Big Relay because you need relays if you want to interface the Raspberry Pi with anything big (and the <a href=\"http:\/\/www.element14.com\/community\/docs\/DOC-51726\/l\/assembled-gertboard-for-raspberry-pi\">Gertboard<\/a> costs too much for my current needs). The Bitwizard Wiki is a very good source of documentation and the boards are very well produced, so I can happily recommend them. Here&#8217;s a small tutorial showing how to use them together &#8211; read the state of physical buttons, display their state on LCD and turn on\/off the corresponding relay (6 buttons, 6 relays).<\/p>\n<p><!--more--><\/p>\n<p>For the moment, I&#8217;m prototyping with shell scripting, so you need to get and install <a href=\"http:\/\/bitwizard.nl\/wiki\/index.php\/Bw_tool\">bw_tool<\/a>. Connect the RPi UI board on top of the Raspberry Pi using the GPIO header and the Big Relay board to the SPI0 header of the RPi UI board (using a 6 wire flat cable). It has to look like this:<\/p>\n<p><a href=\"http:\/\/vaxxi.net\/log\/wp-content\/uploads\/2013\/04\/raspberry_pi_with_rpi_ui_bitwizard.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/vaxxi.net\/log\/wp-content\/uploads\/2013\/04\/raspberry_pi_with_rpi_ui_bitwizard-600x450.jpg\" alt=\"Raspberry Pi with Bitwizard RPi UI board\" width=\"600\" height=\"450\" class=\"aligncenter size-large wp-image-4395\" srcset=\"https:\/\/vaxxi.net\/log\/wp-content\/uploads\/2013\/04\/raspberry_pi_with_rpi_ui_bitwizard-600x450.jpg 600w, https:\/\/vaxxi.net\/log\/wp-content\/uploads\/2013\/04\/raspberry_pi_with_rpi_ui_bitwizard-300x225.jpg 300w, https:\/\/vaxxi.net\/log\/wp-content\/uploads\/2013\/04\/raspberry_pi_with_rpi_ui_bitwizard.jpg 1024w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>Next, the logical flow step by step:<\/p>\n<p>&#8211; clear the display<br \/>\n&#8211; read the button state<br \/>\n&#8211; adjust numeric values accordingly to the button state<br \/>\n&#8211; set the relay state<br \/>\n&#8211; display button state on LCD<br \/>\n&#8211; go to &#8220;read the button state&#8221; and repeat<\/p>\n<p>The script is written in bash.<\/p>\n<p>Clearing the display is done with the following command (needs to be run only once, at beginning of script):<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\/usr\/bin\/bw_tool -a 94 -r 16 -v 0\r\n<\/pre>\n<p>Next, we read the button state.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nB1=$(echo &quot;ibase=16;`\/usr\/bin\/bw_tool -a 94 -R 0x20:s`&quot;|bc)\r\n<\/pre>\n<p>That means to read the 0x20 port (for button 1), translate the hex value by feeding the result into bc and assign the result to variable B1. A pressed button means B1 will have the value 257 (0101 in hex), an unpressed button will have the value 0. Let&#8217;s adjust accordingly:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nif &#x5B; $B1 = 257 ]; then \r\n\t\tB1=0;\r\n\t\tbw_tool -a 9c -w 20:1\t\t\t\t\r\n\telse\r\n\t\tB1=1;\r\n\t\tbw_tool -a 9c -w 20:0\t\t\r\n\tfi\r\n<\/pre>\n<p>Now we know that B1 is 0 for unpressed button and 1 for pressed button, so in the same if we can control the corresponding relay. &#8220;9c&#8221; is the SPI address of the Big Relay board and port 0x20 is the port corresponding to the first relay. We write &#8220;1&#8221; for closing the relay and &#8220;0&#8221; for opening it.<\/p>\n<p>After the buttons&#8217; state has been read and the relays turned on\/off, we can display their status on the LCD:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\/usr\/bin\/bw_tool -a 94 -r 17 -v 0\r\n\/usr\/bin\/bw_tool -a 94 -t &quot;B1:$B1 B2:$B2 B3:$B3  &quot;\r\n\/usr\/bin\/bw_tool -a 94 -r 17 -v 32\r\n\/usr\/bin\/bw_tool -a 94 -t &quot;B4:$B4 B5:$B5 B6:$B6  &quot;\r\n<\/pre>\n<p>and finally:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsleep 1\r\n<\/pre>\n<p>For all your Raspberry Pi and Arduino needs, head over to <a href=\"http:\/\/www.robofun.ro\/\">RoboFun<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve bought two expansion boards from Bitwizard NL for the all wonderful Raspberry PI: one RPi User Interface and one Big Relay. The UI because no DIY electronic project is complete without an LCD and the Big Relay because you need relays if you want to interface the Raspberry Pi with anything big (and the<a class=\"continue-link\" href=\"https:\/\/vaxxi.net\/log\/bitwizard-and-raspberry-pi-fun\/\">&#8230;(Continue Reading)<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[176,146,181,175],"class_list":["post-4393","post","type-post","status-publish","format-standard","hentry","category-gadgets","tag-bitwizard","tag-diy","tag-gadgets","tag-raspberry-pi"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>bitwizard and raspberry pi fun<\/title>\n<meta name=\"description\" content=\"I&#039;ve bought two expansion boards from Bitwizard NL for the all wonderful Raspberry PI: one RPi User Interface and one Big Relay. The UI because no DIY\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/vaxxi.net\/log\/bitwizard-and-raspberry-pi-fun\/\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"VAXXi\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/vaxxi.net\\\/log\\\/bitwizard-and-raspberry-pi-fun\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/vaxxi.net\\\/log\\\/bitwizard-and-raspberry-pi-fun\\\/\"},\"author\":{\"name\":\"VAXXi\",\"@id\":\"https:\\\/\\\/vaxxi.net\\\/log\\\/#\\\/schema\\\/person\\\/94a50a82939211f624b6bf7579d2f752\"},\"headline\":\"bitwizard and raspberry pi fun\",\"datePublished\":\"2013-04-21T13:09:18+00:00\",\"dateModified\":\"2013-04-21T13:25:36+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/vaxxi.net\\\/log\\\/bitwizard-and-raspberry-pi-fun\\\/\"},\"wordCount\":497,\"commentCount\":4,\"image\":{\"@id\":\"https:\\\/\\\/vaxxi.net\\\/log\\\/bitwizard-and-raspberry-pi-fun\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/vaxxi.net\\\/log\\\/wp-content\\\/uploads\\\/2013\\\/04\\\/raspberry_pi_with_rpi_ui_bitwizard-600x450.jpg\",\"keywords\":[\"bitwizard\",\"diy\",\"gadgets\",\"raspberry pi\"],\"articleSection\":[\"gadgets\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/vaxxi.net\\\/log\\\/bitwizard-and-raspberry-pi-fun\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/vaxxi.net\\\/log\\\/bitwizard-and-raspberry-pi-fun\\\/\",\"url\":\"https:\\\/\\\/vaxxi.net\\\/log\\\/bitwizard-and-raspberry-pi-fun\\\/\",\"name\":\"bitwizard and raspberry pi fun\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/vaxxi.net\\\/log\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/vaxxi.net\\\/log\\\/bitwizard-and-raspberry-pi-fun\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/vaxxi.net\\\/log\\\/bitwizard-and-raspberry-pi-fun\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/vaxxi.net\\\/log\\\/wp-content\\\/uploads\\\/2013\\\/04\\\/raspberry_pi_with_rpi_ui_bitwizard-600x450.jpg\",\"datePublished\":\"2013-04-21T13:09:18+00:00\",\"dateModified\":\"2013-04-21T13:25:36+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/vaxxi.net\\\/log\\\/#\\\/schema\\\/person\\\/94a50a82939211f624b6bf7579d2f752\"},\"description\":\"I've bought two expansion boards from Bitwizard NL for the all wonderful Raspberry PI: one RPi User Interface and one Big Relay. The UI because no DIY\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/vaxxi.net\\\/log\\\/bitwizard-and-raspberry-pi-fun\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/vaxxi.net\\\/log\\\/bitwizard-and-raspberry-pi-fun\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/vaxxi.net\\\/log\\\/bitwizard-and-raspberry-pi-fun\\\/#primaryimage\",\"url\":\"https:\\\/\\\/vaxxi.net\\\/log\\\/wp-content\\\/uploads\\\/2013\\\/04\\\/raspberry_pi_with_rpi_ui_bitwizard.jpg\",\"contentUrl\":\"https:\\\/\\\/vaxxi.net\\\/log\\\/wp-content\\\/uploads\\\/2013\\\/04\\\/raspberry_pi_with_rpi_ui_bitwizard.jpg\",\"width\":1024,\"height\":768,\"caption\":\"Raspberry Pi with Bitwizard RPi UI board\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/vaxxi.net\\\/log\\\/bitwizard-and-raspberry-pi-fun\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"VAXXiNET\",\"item\":\"https:\\\/\\\/vaxxi.net\\\/log\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"bitwizard and raspberry pi fun\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/vaxxi.net\\\/log\\\/#website\",\"url\":\"https:\\\/\\\/vaxxi.net\\\/log\\\/\",\"name\":\"\",\"description\":\"There must be some way out of here\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/vaxxi.net\\\/log\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/vaxxi.net\\\/log\\\/#\\\/schema\\\/person\\\/94a50a82939211f624b6bf7579d2f752\",\"name\":\"VAXXi\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/133cb32f29e4500787dc50b17f325e4d69b66c0126b8fedd4c15a8e850f06b21?s=96&d=mm&r=x\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/133cb32f29e4500787dc50b17f325e4d69b66c0126b8fedd4c15a8e850f06b21?s=96&d=mm&r=x\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/133cb32f29e4500787dc50b17f325e4d69b66c0126b8fedd4c15a8e850f06b21?s=96&d=mm&r=x\",\"caption\":\"VAXXi\"},\"sameAs\":[\"http:\\\/\\\/vaxxi.net\\\/log\\\/\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"bitwizard and raspberry pi fun","description":"I've bought two expansion boards from Bitwizard NL for the all wonderful Raspberry PI: one RPi User Interface and one Big Relay. The UI because no DIY","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/vaxxi.net\/log\/bitwizard-and-raspberry-pi-fun\/","twitter_misc":{"Written by":"VAXXi","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/vaxxi.net\/log\/bitwizard-and-raspberry-pi-fun\/#article","isPartOf":{"@id":"https:\/\/vaxxi.net\/log\/bitwizard-and-raspberry-pi-fun\/"},"author":{"name":"VAXXi","@id":"https:\/\/vaxxi.net\/log\/#\/schema\/person\/94a50a82939211f624b6bf7579d2f752"},"headline":"bitwizard and raspberry pi fun","datePublished":"2013-04-21T13:09:18+00:00","dateModified":"2013-04-21T13:25:36+00:00","mainEntityOfPage":{"@id":"https:\/\/vaxxi.net\/log\/bitwizard-and-raspberry-pi-fun\/"},"wordCount":497,"commentCount":4,"image":{"@id":"https:\/\/vaxxi.net\/log\/bitwizard-and-raspberry-pi-fun\/#primaryimage"},"thumbnailUrl":"http:\/\/vaxxi.net\/log\/wp-content\/uploads\/2013\/04\/raspberry_pi_with_rpi_ui_bitwizard-600x450.jpg","keywords":["bitwizard","diy","gadgets","raspberry pi"],"articleSection":["gadgets"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/vaxxi.net\/log\/bitwizard-and-raspberry-pi-fun\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/vaxxi.net\/log\/bitwizard-and-raspberry-pi-fun\/","url":"https:\/\/vaxxi.net\/log\/bitwizard-and-raspberry-pi-fun\/","name":"bitwizard and raspberry pi fun","isPartOf":{"@id":"https:\/\/vaxxi.net\/log\/#website"},"primaryImageOfPage":{"@id":"https:\/\/vaxxi.net\/log\/bitwizard-and-raspberry-pi-fun\/#primaryimage"},"image":{"@id":"https:\/\/vaxxi.net\/log\/bitwizard-and-raspberry-pi-fun\/#primaryimage"},"thumbnailUrl":"http:\/\/vaxxi.net\/log\/wp-content\/uploads\/2013\/04\/raspberry_pi_with_rpi_ui_bitwizard-600x450.jpg","datePublished":"2013-04-21T13:09:18+00:00","dateModified":"2013-04-21T13:25:36+00:00","author":{"@id":"https:\/\/vaxxi.net\/log\/#\/schema\/person\/94a50a82939211f624b6bf7579d2f752"},"description":"I've bought two expansion boards from Bitwizard NL for the all wonderful Raspberry PI: one RPi User Interface and one Big Relay. The UI because no DIY","breadcrumb":{"@id":"https:\/\/vaxxi.net\/log\/bitwizard-and-raspberry-pi-fun\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/vaxxi.net\/log\/bitwizard-and-raspberry-pi-fun\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/vaxxi.net\/log\/bitwizard-and-raspberry-pi-fun\/#primaryimage","url":"https:\/\/vaxxi.net\/log\/wp-content\/uploads\/2013\/04\/raspberry_pi_with_rpi_ui_bitwizard.jpg","contentUrl":"https:\/\/vaxxi.net\/log\/wp-content\/uploads\/2013\/04\/raspberry_pi_with_rpi_ui_bitwizard.jpg","width":1024,"height":768,"caption":"Raspberry Pi with Bitwizard RPi UI board"},{"@type":"BreadcrumbList","@id":"https:\/\/vaxxi.net\/log\/bitwizard-and-raspberry-pi-fun\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"VAXXiNET","item":"https:\/\/vaxxi.net\/log\/"},{"@type":"ListItem","position":2,"name":"bitwizard and raspberry pi fun"}]},{"@type":"WebSite","@id":"https:\/\/vaxxi.net\/log\/#website","url":"https:\/\/vaxxi.net\/log\/","name":"","description":"There must be some way out of here","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/vaxxi.net\/log\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/vaxxi.net\/log\/#\/schema\/person\/94a50a82939211f624b6bf7579d2f752","name":"VAXXi","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/133cb32f29e4500787dc50b17f325e4d69b66c0126b8fedd4c15a8e850f06b21?s=96&d=mm&r=x","url":"https:\/\/secure.gravatar.com\/avatar\/133cb32f29e4500787dc50b17f325e4d69b66c0126b8fedd4c15a8e850f06b21?s=96&d=mm&r=x","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/133cb32f29e4500787dc50b17f325e4d69b66c0126b8fedd4c15a8e850f06b21?s=96&d=mm&r=x","caption":"VAXXi"},"sameAs":["http:\/\/vaxxi.net\/log\/"]}]}},"_links":{"self":[{"href":"https:\/\/vaxxi.net\/log\/wp-json\/wp\/v2\/posts\/4393","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vaxxi.net\/log\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vaxxi.net\/log\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vaxxi.net\/log\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vaxxi.net\/log\/wp-json\/wp\/v2\/comments?post=4393"}],"version-history":[{"count":7,"href":"https:\/\/vaxxi.net\/log\/wp-json\/wp\/v2\/posts\/4393\/revisions"}],"predecessor-version":[{"id":4401,"href":"https:\/\/vaxxi.net\/log\/wp-json\/wp\/v2\/posts\/4393\/revisions\/4401"}],"wp:attachment":[{"href":"https:\/\/vaxxi.net\/log\/wp-json\/wp\/v2\/media?parent=4393"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vaxxi.net\/log\/wp-json\/wp\/v2\/categories?post=4393"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vaxxi.net\/log\/wp-json\/wp\/v2\/tags?post=4393"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}