sampo
Posts: 3
Joined: Fri Sep 28, 2012 3:23 pm

Re: kernel patch for Dallas 1-wire interface

Fri Sep 28, 2012 3:34 pm

Hi
I just downloaded 2012-09-18-wheezy-raspbian and put it on my SDCARD.

It has kernel:
Linux raspberrypi 3.2.27+ #160 PREEMPT Mon Sep 17 23:18:42 BST 2012

Should this kernel support DS18S20 sensor?

When I connect it to a GPIO pin 4 and then do:
sudo modprobe w1-gpio
sudo modprobe w1-therm
I got no device under /sys/bus/w1/devices/w1_bus_master1

I did the wiring like this with the difference that i have DS18S20 instead of DS18B20
http://www.cl.cam.ac.uk/freshers/raspbe ... ection.png
Is this sensor not supported by the kernel or is there just something wrong with my wiring?

Thanks!

davidmam
Posts: 101
Joined: Tue Dec 06, 2011 4:13 pm

Re: kernel patch for Dallas 1-wire interface

Fri Sep 28, 2012 5:05 pm

Are the wee PCBs with the dual RJ45 sockets on your own design or are they available somewhere?
They look kind of just what I need for a project..

repton
Posts: 91
Joined: Sat Mar 17, 2012 6:06 pm
Location: North Yorkshire, UK.
Contact: Website

Re: kernel patch for Dallas 1-wire interface

Fri Sep 28, 2012 7:02 pm

davidmam wrote:Are the wee PCBs with the dual RJ45 sockets on your own design or are they available somewhere?
They look kind of just what I need for a project..
I'm not sure what the rules on advertising are here so mods please let me know if I'm being naughty here...

They are my design, I run a small home business selling 1-wire products including some modules using PCBs of my own. See the website in my signature for more information.

Paul
UK Supplier of 1-Wire components, kits and modules:
http://www.sheepwalkelectronics.co.uk/

repton
Posts: 91
Joined: Sat Mar 17, 2012 6:06 pm
Location: North Yorkshire, UK.
Contact: Website

Re: kernel patch for Dallas 1-wire interface

Fri Sep 28, 2012 7:18 pm

sampo wrote:Is this sensor not supported by the kernel or is there just something wrong with my wiring?
I know this isn't really much help but the kernel should support both the DS1S20 and DS18B20 and as far as I can tell your wiring is right (certainly that diagram is right).

I'm using "3.2.27+ #171 PREEMPT" and have both types of sensor working on it using the same method you have used.

Paul
UK Supplier of 1-Wire components, kits and modules:
http://www.sheepwalkelectronics.co.uk/

davidmam
Posts: 101
Joined: Tue Dec 06, 2011 4:13 pm

Re: kernel patch for Dallas 1-wire interface

Sun Sep 30, 2012 2:34 pm

repton wrote:
davidmam wrote:Are the wee PCBs with the dual RJ45 sockets on your own design or are they available somewhere?
They look kind of just what I need for a project..
I'm not sure what the rules on advertising are here so mods please let me know if I'm being naughty here...

They are my design, I run a small home business selling 1-wire products including some modules using PCBs of my own. See the website in my signature for more information.

Paul
Ah! We have an existing relationship as I acquired my 1-wire sensors from you..

sergiosanche
Posts: 1
Joined: Mon Oct 01, 2012 12:54 pm

Re: kernel patch for Dallas 1-wire interface

Mon Oct 01, 2012 1:14 pm

Hi Frank, congratulations on your work with 1-wire. As you know, identify the temperature sensors is not straightforward. Is it possible to communicate with the sensors using another GPIO pin? Could get a temperature sensor 1-wire on pin 4 and one on the GPIO pin 10? Could be the pin a parameter that is passed to the module? Thus the path to access data could contain the pin and know which is the sensor data. Could you tell me what changes should be made and what files?
A greeting and thank you very much

netomx
Posts: 80
Joined: Tue Oct 11, 2011 4:06 am

Re: kernel patch for Dallas 1-wire interface

Mon Oct 01, 2012 7:36 pm

it is easy to know what sensor is it. COnnect one, get its ID, connect the second, check the ID. as simple as that

Stephen99
Posts: 12
Joined: Fri Oct 05, 2012 6:18 pm

Re: kernel patch for Dallas 1-wire interface

Fri Oct 05, 2012 6:25 pm

Hi,

In case anyone with problems getting their devices to be recognised has the same problem I had:

Don't forget that there are two numbering schemes for the GPIO pins!

You need to connect it to the pin 3 up from the 3.3V output (otherwise known as GPIO 7) *not* the one 7 up from the 5v pin (which is GPIO 23 in 'native' speak).

When I had it on the right pin, it worked first time :)

Thanks very much Frank. Great work!

Stephen

nr.
Posts: 144
Joined: Wed Oct 03, 2012 8:51 am
Location: The Fens
Contact: Website

Re: kernel patch for Dallas 1-wire interface

Fri Oct 12, 2012 3:55 pm

Just in case this is useful to anyone, a quick bit of perl to read temperature sensors on a 1-wire interface:

Code: Select all

#!/usr/bin/perl

$count = 0;

open(INDEX, "cat /sys/bus/w1/devices/w1_bus_master1/w1_master_slaves|");
@index = <INDEX>;
close(INDEX);

foreach (@index) {
  chop;
  $crc = "NO ";
  while ($crc ne "YES") {
    open(SENSOR, "cat /sys/bus/w1/devices/$_/w1_slave|");
    @data = <SENSOR>;
    close(SENSOR);
    $crc = substr(@data[0], 36, 3);
    $attempt++;
    die if ($attempt == 25);
  }
  my $temp = (substr(@data[1], 29, 5)/1000.00);
  my $fahr = ($temp*9.0/5.0)+32.00;
  $date = `date "+%b %d %H:%M:%S"`;
  chop $date;
  print "$date Sensor $count C: $temp F: $fahr\n";
  $count++;
}
There are probably a million ways this could be improved - I'm not really much of a perl programmer. I've set an arbitrary value of 25 attempts to get a valid CRC - in practise this could probably come down to three or four. Anyhow - if it's any use to anyone, please take it and do something with it :)

Ta,
--
nr.

User avatar
jvesalius
Posts: 4
Joined: Wed Oct 10, 2012 12:12 pm

Re: kernel patch for Dallas 1-wire interface

Fri Oct 12, 2012 8:37 pm

Inspired by the poster above, I wrote a quick PHP script to read a single DS18B20 sensor and echo the temperature. Install lighttpd and drop the script in /var/www and you have a quick way to check your temperature.

Code: Select all

<?php
//File to read
$file = '/sys/devices/w1_bus_master1/10-000802292522/w1_slave';

//Read the file line by line
$lines = file($file);

//Get the temp from second line 
$temp = explode('=', $lines[1]);

//Setup some nice formatting (i.e. 21,3)
$temp = number_format($temp[1] / 1000, 1, ',', '');

//And echo that temp
echo $temp . " °C";
?>

kixunil
Posts: 2
Joined: Sat Oct 13, 2012 3:49 pm

Re: kernel patch for Dallas 1-wire interface

Sat Oct 13, 2012 4:08 pm

I have recent kernel (3.2.27) but I'm unable to load module:
# modprobe w1-gpio
ERROR: could not insert 'w1_gpio': Exec format error
dmesg:
cn: version magic '3.2.27+ preempt mod_unload modversions ARMv6 ' should be '3.2.27+ preempt mod_unload modversions ARMv6 p2v8 '

I suppose kernel or module (or both) was build incorrectly.

Any ideas?

kixunil
Posts: 2
Joined: Sat Oct 13, 2012 3:49 pm

Re: kernel patch for Dallas 1-wire interface

Sat Oct 13, 2012 4:51 pm

Sorry, reboot solved it. :)

LeroyZ84
Posts: 32
Joined: Fri Jul 27, 2012 9:23 pm
Location: Earth, Europe, Netherlands, Deventer

Re: kernel patch for Dallas 1-wire interface

Thu Oct 18, 2012 8:53 pm

sampo wrote:Hi
I just downloaded 2012-09-18-wheezy-raspbian and put it on my SDCARD.

It has kernel:
Linux raspberrypi 3.2.27+ #160 PREEMPT Mon Sep 17 23:18:42 BST 2012

Should this kernel support DS18S20 sensor?

When I connect it to a GPIO pin 4 and then do:
sudo modprobe w1-gpio
sudo modprobe w1-therm
I got no device under /sys/bus/w1/devices/w1_bus_master1

I did the wiring like this with the difference that i have DS18S20 instead of DS18B20
http://www.cl.cam.ac.uk/freshers/raspbe ... ection.png
Is this sensor not supported by the kernel or is there just something wrong with my wiring?

Thanks!
Do you got it fixed? I'm running into the same issue, can't find a solution.
Kernel : Linux raspberrypi 3.2.18+ #20

Wiring looks good.. weird stuff.... tried another sensor,still nothing. modules w1-gpio + w1-therm loaded, but no visible devices in /sys/bus/w1/devices...

Edit: Found it.. had the resistor between data and ground instead of data and vdd
www.­djredmar.­com:­8080

kristfin
Posts: 1
Joined: Mon Oct 29, 2012 11:17 am

Re: kernel patch for Dallas 1-wire interface

Sun Nov 04, 2012 9:09 pm

hi,
was just testing this out. think i have followed all the guidelines, however i never get anything but 85000 reading. if i skip the resistor i get t=0, with 2k2 i get 127937 and with 4k7 and 10k i get 85000

Code: Select all

// no resistor
pi@raspberrypi /sys/bus/w1/devices $ cat 28-000002a88233/w1_slave
00 00 00 00 00 00 00 00 00 : crc=00 YES
00 00 00 00 00 00 00 00 00 t=0
// 2k2
pi@raspberrypi /sys/bus/w1/devices $ cat 28-000002a88233/w1_slave
ff 07 4b 46 7f ff 01 10 2f : crc=2f YES
ff 07 4b 46 7f ff 01 10 2f t=127937
// 4k7 or 10k
pi@raspberrypi /sys/bus/w1/devices $ cat 28-000002a88233/w1_slave
50 05 4b 46 7f ff 0c 10 1c : crc=1c YES
50 05 4b 46 7f ff 0c 10 1c t=85000
// version
pi@raspberrypi /sys/bus/w1/devices $ uname -a
Linux raspberrypi 3.2.27+ #250 PREEMPT Thu Oct 18 19:03:02 BST 2012 armv6l GNU/Linux
i've tried more than one ds18b20.
any ideas what could be wrong?

uzi18
Posts: 1
Joined: Fri Nov 09, 2012 5:35 am

Re: kernel patch for Dallas 1-wire interface

Fri Nov 09, 2012 5:42 am

Why not use ready and tested w1-master-gpio module from OpenWrt?
You can define gpio to use durring module loading.

repton
Posts: 91
Joined: Sat Mar 17, 2012 6:06 pm
Location: North Yorkshire, UK.
Contact: Website

Re: kernel patch for Dallas 1-wire interface

Thu Nov 15, 2012 7:20 pm

For anyone looking for a simple plug in way of using this 1-Wire driver I now have my RPI1 module for sale which makes it simple to connect 1-Wire devices to the GPIO connector to use with the w1_gpio module.

http://www.sheepwalkelectronics.co.uk/RPI1.shtml

Paul
UK Supplier of 1-Wire components, kits and modules:
http://www.sheepwalkelectronics.co.uk/

Eradicatore
Posts: 23
Joined: Sun Jul 29, 2012 1:21 am

Re: kernel patch for Dallas 1-wire interface

Thu Nov 22, 2012 1:33 am

rleyden wrote:
Frank Buss wrote:I've applied the patch to the Raspbian kernel, this is the new repository:
Frank,
Thanks for the Raspbian patch. I got my DS18B20 sensor probe working after some trial and error.
I didn’t initially add a resistor to my pre-wired probe ( http://www.ebay.com/itm/1pcs-Waterproof ... 969wt_1503 ) because the Ebay listing said “no external components required”. Without the resistor the sensor is not detected. With a 4 K ohm resistor, everything was fine.

I also tried the method in your first post (I hadn’t read to the end of this thread). There were no errors but “lsmod” showed that w1-gpio hadn’t loaded. Of course, I didn't have the resistor at that point either.
Rich

Thank you!!! This was just the tip/reminder I needed. I got it working just fine right after the 4.7K pullup was added. Awesome. Just a few modprobe's 3 wires, and a pullup. Thank you for all the work Mr. Buss!

User avatar
Frank Buss
Posts: 92
Joined: Fri Jan 06, 2012 4:39 pm
Contact: Website

Re: kernel patch for Dallas 1-wire interface

Thu Nov 22, 2012 6:21 am

BTW: the patch is no longer needed, now it is in the official Raspbian distribution. I've created a short howto:

http://www.frank-buss.de/raspberrypi/index.html

jon wise
Posts: 46
Joined: Thu May 31, 2012 8:21 pm

Re: kernel patch for Dallas 1-wire interface

Sun Nov 25, 2012 5:14 pm

Where can I find a list of supported devices?
I would like to move my current greenhouse thermostat which uses DS2405 switches and DS1820 thermometers to Raspberry Pi. Will these work?

stuartmarsden
Posts: 4
Joined: Sat May 26, 2012 12:52 pm

Re: kernel patch for Dallas 1-wire interface

Wed Nov 28, 2012 9:00 pm

I have just posted a patch to WebIOPi to add basic 1-Wire support.

Details on WebIOPi thread http://www.raspberrypi.org/phpBB3/viewt ... 73#p223373

I only have one thermometer sensor. So I can only test with that. Happy if those with more devices prove it can work with them. Read only at the moment. Lists all connected devices on the web page and lets you get the w1_slave contents or extract the temperature.

Hope it is helpful

Stuart

davidmam
Posts: 101
Joined: Tue Dec 06, 2011 4:13 pm

Re: kernel patch for Dallas 1-wire interface

Wed Nov 28, 2012 11:16 pm

jon wise wrote:Where can I find a list of supported devices?
I would like to move my current greenhouse thermostat which uses DS2405 switches and DS1820 thermometers to Raspberry Pi. Will these work?
Should do - just wire it in appropriately (to GPIO4 for data, a 4.7k resistor between that and +3.3v (pin 2), and the ground to pin 6.)

sudo modprobe w1-temp or some such and the data should just appear in /dev

mkj
Posts: 7
Joined: Sat Dec 08, 2012 4:22 am
Location: Perth, Australia
Contact: Website

Re: kernel patch for Dallas 1-wire interface

Sat Dec 08, 2012 4:32 am

Frank Buss wrote:
Grey Whittney wrote:Does the bus take into account the parasitic mode requirements (such as driving the data bus during conversions)?
But the GPIO pin can't deliver enough current to power external devices and it could destroy the CPU, if you try it. It is not a high-current GPIO, as available on some AVR chips.
I've patched the w1-gpio driver to perform a pullup as required for parasite power mode. See https://github.com/mkj/rpi-linux/commit ... 87382b06f5 . Note that it changes the w1 API so any other w1 modules will also need recompiling.

It's not enabled by default, "modprobe w1_gpio pullup=1" to try it. It works fine with my single DS18B20 (4.7k resistor, vcc pin tied to ground as per the datasheet). I haven't tried multiple devices yet. The max active current is 1.5mA which should't be a problem for the CPU, though be careful. I haven't checked that it works with non parasite devices, though don't see why it wouldn't.

rayoul
Posts: 2
Joined: Fri Jul 27, 2012 2:38 pm

Re: kernel patch for Dallas 1-wire interface

Tue Dec 11, 2012 7:55 pm

[quote="szigeti"][quote="szigeti"]After the loaded the (w1-ds2408) kernel module I see the following:

[code]pi@raspberrypi ~ $ ls -l /sys/bus/w1/devices/29-0000000fde25/
total 0
-r--r--r-- 1 root root 1 Sep 7 08:11 activity
-r--r--r-- 1 root root 1 Sep 7 08:11 cond_search_mask
-r--r--r-- 1 root root 1 Sep 7 08:11 cond_search_polarity
lrwxrwxrwx 1 root root 0 Sep 7 08:11 driver -> ../../../bus/w1/drivers/w1_slave_driver
-r--r--r-- 1 root root 4096 Sep 7 08:11 id
-r--r--r-- 1 root root 4096 Sep 7 08:11 name
-rw-rw-r-- 1 root root 1 Sep 7 08:18 output
drwxr-xr-x 2 root root 0 Sep 7 08:11 power
-r--r--r-- 1 root root 1 Sep 7 08:11 state
-rw-rw-r-- 1 root root 1 Sep 7 08:11 status_control
lrwxrwxrwx 1 root root 0 Sep 7 08:11 subsystem -> ../../../bus/w1
-rw-r--r-- 1 root root 4096 Sep 7 08:11 uevent
pi@raspberrypi ~ $
[/code]

How can read/write the ports?[/quote]

I got the following examples from the kernel modul's developer but I don't have time to test it.
read: [b]dd if=./output bs=1 count=1 | hexdump[/b]
write: [b]echo \x01 |dd of=./output bs=1 count=1[/b]

I will be happy if somebody try it and send back every feedback.[/quote]

Hi!

I've test those commands, the reading is Ok and returns:
0000000 00ff
0000001
(i think 00ff is the status of switches in binaries it's 11111111)

I'd some problems with the write command. in fact I think it's working but you need some stuff:
you need to wire pin 10 (rzst) and pin 3 (Vcc) of the ds2408 (I found that in the datasheet). and in the directory you need to do:
[code]sudo chmod og=rw output[/code].
If not you may have errors with the output file.
when I do the write command it's working but return an error (erreur d'entrée/sortie) i think it's I/O in english. but when I redo the read command 00ff change (for x01 it return 0078).

I think it could help you.

ps: sorry for my bad english!!!

rayoul
Posts: 2
Joined: Fri Jul 27, 2012 2:38 pm

Re: kernel patch for Dallas 1-wire interface

Wed Dec 12, 2012 9:15 am

rayoul wrote: I've test those commands, the reading is Ok and returns:
0000000 00ff
0000001
(i think 00ff is the status of switches in binaries it's 11111111)

I'd some problems with the write command. in fact I think it's working but you need some stuff:
you need to wire pin 10 (rzst) and pin 3 (Vcc) of the ds2408 (I found that in the datasheet). and in the directory you need to do:

Code: Select all

sudo chmod og=rw output
.
If not you may have errors with the output file.
when I do the write command it's working but return an error (erreur d'entrée/sortie) i think it's I/O in english. but when I redo the read command 00ff change (for x01 it return 0078).

I think it could help you.

ps: sorry for my bad english!!!
Hi again
It works fine!
I've test switches with a multimetter. when you turn on the rasp, all switch are open, and the read command return 00ff=11111111(in binary)=ÿ (in text)
P0=first number in binary mode
p1= second number
...
P7= eight'th number.
You have to convert binary in text to have your output file working correctly.
for exemple, to switch on P1,P3,P5,P7 and switch off the others, the binary is "01010101" in text it's "U".
the command is: echo \U |dd of=output bs=1 count=1 (when you are in the folder of your device)
it return an error but if you read with "dd if=output bs=1count=1" you can read 0055, wicht is in hex to binary 01010101. with the multimetter I can test switches and P1,P3,P5,P7 are tied with the ground pin and the oters are not.
remenber to tied the pin 10 (rszt) to pin 3 (Vcc) of your ds2408, and each time you disconnet ds2408, you have to redo the chmod on the output file.

hope it will help.

Question to Frank Buss,
I've some ds2406 (switch), but there's no module for them. Do you now if it's far from the ds2408 and how can I help to make a module?

Thank's for this hard work on 1-wire with GPIO.

Rayoul

szigeti
Posts: 10
Joined: Thu Sep 06, 2012 1:29 pm

Re: kernel patch for Dallas 1-wire interface

Tue Dec 18, 2012 2:49 pm

rayoul wrote: for exemple, to switch on P1,P3,P5,P7 and switch off the others, the binary is "01010101" in text it's "U".
the command is: echo \U |dd of=output bs=1 count=1 (when you are in the folder of your device)
it return an error but if you read with "dd if=output bs=1count=1" you can read 0055, wicht is in hex to binary 01010101. with the multimetter I can test switches and P1,P3,P5,P7 are tied with the ground pin and the oters are not.

Rayoul
Thanks Rayoul,
It works fine, but I have a problem:

Which ASCII character is good for the "00000000" or "11111111" pin output?

Gabor

Return to “Interfacing (DSI, CSI, I2C, etc.)”

Who is online

Users browsing this forum: No registered users and 20 guests