{"id":281,"date":"2014-07-10T22:10:27","date_gmt":"2014-07-10T19:10:27","guid":{"rendered":"http:\/\/www.bashpi.org\/?page_id=281"},"modified":"2020-12-03T17:33:11","modified_gmt":"2020-12-03T15:33:11","slug":"how-to-get-ds9490r-adapter-and-ds18b20-sensors-working","status":"publish","type":"page","link":"https:\/\/www.bashpi.org\/?page_id=281","title":{"rendered":"How to get DS9490R adapter and DS18B20 sensors working"},"content":{"rendered":"<p><strong>This how-to has multiple pages.&nbsp;This page is about how to configure DS9490R adapter&nbsp;so that it will be possible to read temperature data. If you have not connected <strong>DS9490R<\/strong> adapter and sensors yet, please read <a title=\"How to connect DS9490R adapter and DS18B20 sensors\" href=\"http:\/\/www.bashpi.org\/?page_id=262\">previous page<\/a> first.<\/strong><\/p>\n<p>If you have adapter and sensors connected its time to:<\/p>\n<ol>\n<li>Create some non-root user account for 1wire- related stuff.<\/li>\n<li>Create mountpoint for <a href=\"http:\/\/owfs.org\">OWFS<\/a> (One Wire File System).<\/li>\n<li>Install OWFS packages.<\/li>\n<li>Configure OWFS, FUSE and UDEV<\/li>\n<li>Start and check is OWFS working.<\/li>\n<li>Configure services.<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<p><strong>1. User account<\/strong><\/p>\n<p>Running everything as <em>root<\/em> user is easy but not the best practise. So lets make our lives more difficult and create system account named <em>wire<\/em>. This user must be set as owner of DS9490R adapter device with UDEV rules. Command creates also home directory for user <em>wire<\/em>, it should be something like <em>\/home\/wire<\/em> what I will use and refer to later as <em>wire<\/em> user home directory.<\/p>\n<pre><code class=\"language-bash\">sudo useradd -r -m wire\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p><strong>2. Create mountpoint<br \/>\n<\/strong><\/p>\n<p>Lets create mountpoint for OWFS. Following commands create mountpoint <em>\/wire<\/em> if it does not already exist and change its owner.<\/p>\n<pre><code class=\"language-bash\">sudo [ -d \/wire ] || mkdir \/wire\nsudo chown wire:wire \/wire<\/code><\/pre>\n<p><strong>3. Install packages<br \/>\n<\/strong><\/p>\n<p>You need to install few packages to get OWFS working. Its enough when you install <em>owfs<\/em>, rest of the packages should be installed automatically because of dependencies.<\/p>\n<pre><code class=\"language-bash\">sudo apt-get install owfs\n<\/code><\/pre>\n<p><strong>4. Configure OWFS, FUSE and UDEV<br \/>\n<\/strong><\/p>\n<p>Switch off OFWS services what are not required at least in this project. Aparently if you don&#8217;t do it, some of these services grab DS9490R adapter for themselves and its not working properly later. I forgot to do that and spent half a day wondering why the f its not working although it was just perfect during previous install.<\/p>\n<pre><code class=\"language-bash\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; update-rc.d -f owftpd disable\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; update-rc.d -f owhttpd disable\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; update-rc.d -f owserver disable\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; service owftpd stop\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; service owhttpd stop\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; service owserver stop\n<\/code><\/pre>\n<p>Edit <em>\/etc\/owfs.conf<\/em> file. Comment in and modify <em>mountpoint<\/em> parameter &#8211; set value to <em>\/wire<\/em>. Also comment in <em>allow_other<\/em> line.<\/p>\n<pre>&nbsp;mountpoint = \/wire\n allow_other<\/pre>\n<p>If you did not have <a href=\"http:\/\/en.wikipedia.org\/wiki\/Filesystem_in_Userspace\">FUSE<\/a> installed yet, it should have been installed along with owfs packages. Edit fuse config file <em>\/etc\/fuse.conf<\/em> and comment in <em>user_allow_other<\/em> line.<\/p>\n<pre><code class=\"language-bash\">user_allow_other\n<\/code><\/pre>\n<p>Load fuse module<\/p>\n<pre><code class=\"language-bash\">sudo modprobe fuse\n<\/code><\/pre>\n<p>Add user <em>wire<\/em> to <em>fuse<\/em> group so that <em>wire<\/em> user could use it (fuse).<\/p>\n<pre><code class=\"language-bash\">sudo usermod -a -G fuse wire\n<\/code><\/pre>\n<p>Add UDEV rule. I added it to file <em>\/etc\/udev\/rules.d\/99-wire.rules<\/em> . Generally this rule is needed to automatically change owner of DS9490R adapter when device is plugged in. If you don&#8217;t change owner, you can still use it as root user which means mounting owfs as root user. Symlink creation in rule below is optional.<\/p>\n<pre><code class=\"language-bash\">ATTRS{idVendor}==\"04fa\", ATTRS{idProduct}==\"2490\", OWNER=\"wire\", GROUP=\"wire\", MODE=\"0660\", SYMLINK+=\"ds1490f\"\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p><strong>5. Start and check is OWFS working.<\/strong><\/p>\n<p>Start OWFS as user wire:<\/p>\n<pre><code class=\"language-bash\">sudo -u wire \/usr\/bin\/owfs --allow_other --timeout_volatile=30 --timeout_presence=300 -u -m \/wire<\/code><\/pre>\n<p>Check by listing owfs mountpoint contents. Switch to user <em>wire<\/em> first or run commands using sudo as shown below. In that way you can be sure that <em>wire<\/em> user can actually read contents.<\/p>\n<pre>sudo -u wire ls -la \/wire<code class=\"language-bash\">\n<\/code><\/pre>\n<p>Output should be something like below &#8211; note temperature sensor directories starting with 28.<\/p>\n<pre><code>\npi@raspberrypi ~ $ sudo -u wire ls -la \/wire\nkokku 4\ndrwxr-xr-x  1 root root    8 juuli 13 23:51 .\ndrwxr-xr-x 23 root root 4096 juuli 10 22:31 ..\ndrwxrwxrwx  1 root root    8 juuli 13 23:51 05.4AEC29CDBAAB\ndrwxrwxrwx  1 root root    8 juuli 13 23:51 10.67C6697351FF\ndrwxrwxrwx  1 root root    8 juuli 13 23:51 <strong>28.1D174B050000<\/strong>\ndrwxrwxrwx  1 root root    8 juuli 13 23:51 <strong>28.A1CFBA030000<\/strong>\ndrwxrwxrwx  1 root root    8 juuli 13 23:51 81.8DED33000000\ndrwxr-xr-x  1 root root    8 juuli 13 23:51 alarm\ndrwxr-xr-x  1 root root    8 juuli 13 23:51 bus.0\ndrwxr-xr-x  1 root root    8 juuli 13 23:51 bus.1\ndrwxr-xr-x  1 root root    8 juuli 13 23:51 settings\ndrwxrwxrwx  1 root root    8 juuli 13 23:51 simultaneous\ndrwxr-xr-x  1 root root    8 juuli 13 23:51 statistics\ndrwxr-xr-x  1 root root   32 juuli 13 23:51 structure\ndrwxr-xr-x  1 root root    8 juuli 13 23:51 system\ndrwxr-xr-x  1 root root    8 juuli 13 23:51 uncached\n<\/code><\/pre>\n<p>If you don&#8217;t see any temperature sensor directories starting with &#8220;28.&#8221; although sensors are connected, kill <em>owfs<\/em> process and try to start it again as root user (omit <em>-u wire<\/em> in command above). If you see 28.* temperature sensors after that, there is something wrong with device ownership. If you still don&#8217;t see any 28.* device it is probably something wrong with wiring.<\/p>\n<p>If you see contents like above, especially &#8220;catalogs&#8221; beginning with &#8220;28.&#8221; you can list sensor ID-s and temperatures with following command:<\/p>\n<pre>for f in `ls \/wire\/|grep 28.`; do echo -n \"Sensor ${f} temperature is \"; cat \/wire\/${f}\/temperature; echo ; done<code class=\"language-bash\">\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>Scripts in this page were tested on:<\/p>\n<ul>\n<li>Raspberry Pi Model B 512MB RAM. OS: Raspbian Wheezy, released in 2014-01-07. All updates installed on 1. september 2014.<\/li>\n<\/ul>\n<p>If you found this useful, say thanks, click on some banners or <a href=\"http:\/\/www.bashpi.org\/?page_id=105\">donate<\/a>, I can always use some beer money.<\/p>\n<p>NEXT &#8211; <a title=\"How to get DS9490R adapter and DS18B20 sensors working (automated)\" href=\"http:\/\/www.bashpi.org\/?page_id=325\">How to get DS9490R adapter and DS18B20 sensors working (automated)<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This how-to has multiple pages.&nbsp;This page is about how to configure DS9490R adapter&nbsp;so that it will be possible to read temperature data. If you have not connected DS9490R adapter and sensors yet, please read previous page first. If you have adapter and sensors connected its time to: Create some non-root user account for 1wire- related [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":262,"menu_order":0,"comment_status":"closed","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-281","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.bashpi.org\/index.php?rest_route=\/wp\/v2\/pages\/281","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bashpi.org\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.bashpi.org\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.bashpi.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bashpi.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=281"}],"version-history":[{"count":24,"href":"https:\/\/www.bashpi.org\/index.php?rest_route=\/wp\/v2\/pages\/281\/revisions"}],"predecessor-version":[{"id":767,"href":"https:\/\/www.bashpi.org\/index.php?rest_route=\/wp\/v2\/pages\/281\/revisions\/767"}],"up":[{"embeddable":true,"href":"https:\/\/www.bashpi.org\/index.php?rest_route=\/wp\/v2\/pages\/262"}],"wp:attachment":[{"href":"https:\/\/www.bashpi.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=281"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}