{"id":78,"date":"2020-02-09T00:57:12","date_gmt":"2020-02-08T23:57:12","guid":{"rendered":"http:\/\/vmd48343.contaboserver.net\/?p=78"},"modified":"2020-02-14T08:53:08","modified_gmt":"2020-02-14T07:53:08","slug":"raspberry-pi-und-i2c","status":"publish","type":"post","link":"https:\/\/www.duoweb.de\/index.php\/2020\/02\/09\/raspberry-pi-und-i2c\/","title":{"rendered":"Raspberry Pi und I\u00b2C"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\">GPIO<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">SPI und I\u00b2C aktivieren<\/h2>\n\n\n\n<p><pre class=\"wp-block-preformatted\">sudo raspi-config<\/pre><\/p>\n\n\n\n<p>Interfacing Options<\/p>\n\n\n\n<p>Dort kann man die I2C aktivieren&#8230;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">I\u00b2C Baudrate anpassen<\/h2>\n\n\n\n<p>Die Baudrate muss nicht zwangsl\u00e4ufig angepasst werden. Wenn man dies tun will, dann geht es bspw. so:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#Remove Module\nmodprobe -r i2c_bcm2708\n\n#Change baudrate\nsudo bash\ncd \/etc\/modprobe.d\nnano i2c_bcm2708.conf\noptions i2c_bcm2708 baudrate=400000\n\n#Load module\nmodprobe i2c_bcm2708<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">I\u00b2C und PHP \u00fcber Apache<\/h2>\n\n\n\n<p>Damit der www-Dienst direkt den I2C-Bus steuern kann, muss www-data (das Konto vom Apache) zu der I2C Gruppe hinzugef\u00fcgt werden.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo adduser www-data i2c\n<\/pre>\n\n\n\n<p>Ggf. apache neustarten<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo service apache2 restart<\/pre>\n\n\n\n<p>In die PHP-Datei muss folgender Auruf rein (Beispiel)<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">shell_exec ('\/usr\/sbin\/i2cset -y 1 0x20 0x12 12');<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>GPIO SPI und I\u00b2C aktivieren sudo raspi-config Interfacing Options Dort kann man die I2C aktivieren&#8230; I\u00b2C Baudrate anpassen Die Baudrate muss nicht zwangsl\u00e4ufig angepasst werden. Wenn man dies tun will, dann geht es bspw. so: #Remove Module modprobe -r i2c_bcm2708 #Change baudrate sudo bash cd \/etc\/modprobe.d nano i2c_bcm2708.conf options i2c_bcm2708 baudrate=400000 #Load module modprobe i2c_bcm2708<\/p>\n<p class=\"more-link\"><a href=\"https:\/\/www.duoweb.de\/index.php\/2020\/02\/09\/raspberry-pi-und-i2c\/\" class=\"themebutton2\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[11,9],"tags":[],"class_list":["post-78","post","type-post","status-publish","format-standard","hentry","category-linux","category-raspberry"],"_links":{"self":[{"href":"https:\/\/www.duoweb.de\/index.php\/wp-json\/wp\/v2\/posts\/78","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.duoweb.de\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.duoweb.de\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.duoweb.de\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.duoweb.de\/index.php\/wp-json\/wp\/v2\/comments?post=78"}],"version-history":[{"count":4,"href":"https:\/\/www.duoweb.de\/index.php\/wp-json\/wp\/v2\/posts\/78\/revisions"}],"predecessor-version":[{"id":210,"href":"https:\/\/www.duoweb.de\/index.php\/wp-json\/wp\/v2\/posts\/78\/revisions\/210"}],"wp:attachment":[{"href":"https:\/\/www.duoweb.de\/index.php\/wp-json\/wp\/v2\/media?parent=78"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.duoweb.de\/index.php\/wp-json\/wp\/v2\/categories?post=78"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.duoweb.de\/index.php\/wp-json\/wp\/v2\/tags?post=78"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}