silviodelgado70
Posts: 41
Joined: Sun Dec 01, 2013 10:36 pm

Re: One wire w1-gpio and w1-gpio-custom

Sat Mar 21, 2015 3:29 pm

I get an error during kernel compilation:

Code: Select all

[email protected]:~/Desktop/rpikernel/linux-rpi-3.18.y$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
make[1]: `include/generated/mach-types.h' is up to date.
  CALL    scripts/checksyscalls.sh
  CHK     include/generated/compile.h
  CHK     kernel/config_data.h
  CC [M]  fs/btrfs/super.o
In file included from fs/btrfs/transaction.h:21:0,
                 from fs/btrfs/super.c:48:
fs/btrfs/btrfs_inode.h:25:26: fatal error: ordered-data.h: No such file or directory
compilation terminated.
make[2]: *** [fs/btrfs/super.o] Error 1
make[1]: *** [fs/btrfs] Error 2
make: *** [fs] Error 2
Can anyone help me to solve this?

arturass
Posts: 1
Joined: Fri Mar 27, 2015 9:21 am

Re: One wire w1-gpio and w1-gpio-custom

Fri Mar 27, 2015 9:42 am

Hello,
I need to have additional one wire bus.
I'm trying to compile kernel with the changes suggested by http://holyhead.de/RaspberryPi/bcm2708- ... .12.21.txt
What I have done:
0 - updated my pi2 to latest kernel: 3.18.9
1 - Using compile instructions from https://learn.adafruit.com/raspberry-pi ... c/overview
2 - Change the bcm2709.c file. (not bcm2708.c as I have pi2)
3 - Compile and update kernel.
when booting using device_tree, I don't see multiple one wire masters, I also added additional logging when registering device (in bcm2709.c), so I see those messages in kernel log. Additional devices were registered.

when booting old mode (not using device_tree: I have "device_tree=" in /boot/config.txt) I can see multiple one wire masters, but then GPIO stopped working. I was using webiopi as well as rpi.gpio. I assume this old method is deprecated now.

I think I need to patch 1wire overlay, right? what about w1-gpio-overlay.dts? any thoughts?

Thanks in advance

bomilkar
Posts: 1
Joined: Tue Nov 24, 2015 9:28 am

Re: One wire w1-gpio and w1-gpio-custom

Tue Nov 24, 2015 10:04 am

This topic is quiet since several months now. Is it solved or just abandoned?

If it's solved (preferably without kernel patches) I'd like to hear about it.

Again: I want several 1W buses with several slaves on each 1W bus. The reason I want several 1W buses is that the location of the slaves (temperature sensors) is inconvenient for 1 single bus.

gerdesj
Posts: 24
Joined: Sun Nov 29, 2015 1:52 pm

Re: One wire w1-gpio and w1-gpio-custom

Sun Nov 29, 2015 10:22 pm

bomilkar wrote:This topic is quiet since several months now. Is it solved or just abandoned?

If it's solved (preferably without kernel patches) I'd like to hear about it.

Again: I want several 1W buses with several slaves on each 1W bus. The reason I want several 1W buses is that the location of the slaves (temperature sensors) is inconvenient for 1 single bus.
Probably not quite the answer you want but I had a job to do:

http://www.sheepwalkelectronics.co.uk/p ... ucts_id=67
http://www.sheepwalkelectronics.co.uk/p ... ucts_id=65

I put the thing from the first link on the Pi over the GPIO pins (cell added first - it comes with an RTC), I then connected the four temp sensors (I got the 2m versions) to the second linked device. Plugged in a standard ethernet cable to link them up. Fiddled around with drivers for 20 minutes.

For rather less than the usual price of a server room temperature monitoring device I had four sensors on the end of a real computer. A bit more fiddling with Icinga plugins and owfs and I have a system that any sysadmin can throw together with nothing more complicated tool-wise than a small flat blade screwdriver and a drill driver (for mounting that lot)

The interface thing above has six buses on it apparently but I'm not sure how far you can go on parasitic power. There are other boards available as well with less stuff on them and hence cheaper.

I'm not affiliated with that supplier but it was all a bit easy. However their supplied documentation is a bit rubbish (non existent) but their website points you vaguely in the right directions.

d1rtyd
Posts: 5
Joined: Sat Feb 06, 2016 11:01 pm

Re: One wire w1-gpio and w1-gpio-custom

Sun Feb 07, 2016 1:48 am

arturass wrote:Hello,
I need to have additional one wire bus.
...
Thanks in advance
Me too! Check out viewtopic.php?f=44&t=107894&p=900916#p900916 for someone making some progress on this. It does look like we need to modify the overlay file instead of patching the kernel.

goodfidelity
Posts: 2
Joined: Mon Mar 07, 2016 10:05 pm

Re: One wire w1-gpio and w1-gpio-custom

Sat Mar 12, 2016 8:06 am

This thread shows very interesting information for many users using one wire bus for energy monitoring.

Is there anywhere a precompiled kernel / installation can be downloaded?

I also want to know if anyone tried using more then four one wire buses? What is the theoretical limit?


Would be nice to compile a energy monitoring kernel with 6 one wire buses and four pulse counting buses, if that is possible.

Very thankful for input on this matter!

//GF

raspi-ninja
Posts: 1
Joined: Thu Mar 31, 2016 3:43 am

Re: One wire w1-gpio and w1-gpio-custom

Thu Mar 31, 2016 3:49 am

I was able to re-compile the kernel as described above. If you don't want to go through the trouble this video
https://www.youtube.com/watch?v=JW9wzbp35w8
I hooked up 81 sensors to his pi on 9 different gpio and used a custom bitbanging program to achieve it.
More details are there.

tsjoland
Posts: 3
Joined: Sun May 01, 2016 8:53 am

Re: One wire w1-gpio and w1-gpio-custom

Sun May 01, 2016 9:11 am

After following Maag:s instruction I got it all working fine, 4 busmasters and all ds18b20 sensors ending up in the /sys/bus/w1/devices/ folder giving me live data.
Next problem is that I can´t get Domoticz to read and present them as devices in Domoticz. Domoticz only presents the sensors coming from w1_busmaster1.

Edit
Modified Domoticz source file 1wirebykernel.c to read 4 busmaster slaves lists. Problem solved.

mikluz
Posts: 17
Joined: Thu Mar 31, 2016 11:52 am
Location: Szczecin, Poland

Re: One wire w1-gpio and w1-gpio-custom

Wed Jun 01, 2016 2:44 pm

Hi all,

I've found a few topics here and on the Internet which instructs how to change 1-wire default pin from pin 4 to another GPIO pin.

I put proposed line to my cmdline.txt file (bcm2708.w1_gpio_pin=XX):

Code: Select all

[email protected]_Home:/boot $ cat cmdline.txt 
dwc_otg.lpm_enable=0 console=tty1 console=serial0,115200 root=/dev/mmcblk0p7 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait bcm2708.w1_gpio_pin=18
But I can't see the DS18B20 device in the /sys/bus directory:

Code: Select all

[email protected]_Home:/sys/bus/w1/devices $ ls
00-740000000000  00-f40000000000  w1_bus_master1
The wiring is fine as I change DS18B20 data pin to GPIO4 RPi pin it works perfectly:

Code: Select all

[email protected]_Home:/sys/bus/w1/devices $ ls
00-4c0000000000  00-8c0000000000  28-031635236cff  w1_bus_master1
[email protected]_Home:/sys/bus/w1/devices $ cd 28-031635236cff
[email protected]_Home:/sys/bus/w1/devices/28-031635236cff $ cat w1_slave 
83 01 4b 46 7f ff 7f 10 41 : crc=41 YES
83 01 4b 46 7f ff 7f 10 41 t=24187

What shall I do to make 1-wire working on other GPIO pin than 4?

Also, I run up-to-date RPi [email protected]:

Code: Select all

[email protected]_Home:/sys/bus/w1/devices/28-031635236cff $ uname -a
Linux Sweet_Home 4.4.9-v7+ #884 SMP Fri May 6 17:28:59 BST 2016 armv7l GNU/Linux
Raspberry Pi 3 @ Raspbian

User avatar
Wilberforce
Posts: 3
Joined: Wed Mar 11, 2015 10:29 am

Re: One wire w1-gpio and w1-gpio-custom

Wed Jun 15, 2016 6:28 am

mikluz wrote:Hi all,

I've found a few topics here and on the Internet which instructs how to change 1-wire default pin from pin 4 to another GPIO pin.

I put proposed line to my cmdline.txt file (bcm2708.w1_gpio_pin=XX):
Sorry -that is the *old* way of doing it, it is done using a device tree overlay now.

In /boot/config.txt, add:

`dtoverlay=w1-gpio,gpiopin=4`

the output of `dmesg` should show you if your pin is picked up

enlijoe
Posts: 1
Joined: Thu Jan 05, 2017 3:37 am

Re: One wire w1-gpio and w1-gpio-custom

Thu Jan 05, 2017 3:40 am

Just in case anyone else wants to know this:

There is a I2C to one wire ic. It is very cheep and can control many one wire devices at once.

Mouser part # 700-DS2482S-100T&R and the cost is $1.68 for singles.

mrbronz61
Posts: 1
Joined: Thu Feb 16, 2017 6:34 pm

Re: One wire w1-gpio and w1-gpio-custom

Thu Feb 16, 2017 6:43 pm

Hi there...

Did you ever solve this issue

According to the DS18B20 Datasheet

The DS18B20 communicates over a 1-Wire bus that by definition requires only one data line (and ground) for communication with a central microprocessor.

In addition, the DS18B20 can derive power directly from the data line (“parasite power”), eliminating the need for an external power supply.

Each DS18B20 has a unique 64-bit serial code, which allows multiple DS18B20s to function on the same 1-Wire bus. Thus, it is simple to use one microprocessor to control many DS18B20s distributed over a large area.

Hope this helps

jpers
Posts: 24
Joined: Mon May 23, 2016 6:06 am

Re: One wire w1-gpio and w1-gpio-custom

Fri Jun 30, 2017 7:11 pm

impluse wrote:
Holyhead wrote:Thanks @fishfinger! :D
I've used your code stub to compile a patched 3.12.21 kernel implementing four 1-w busmasters.
For those interested, I've uploaded the patch file here http://holyhead.de/RaspberryPi/bcm2708- ... .12.21.txt.
hi...
Can you explain step by step how can i have more than one pin for 1-wire bus on single pi
You don't need more than one bus, if you use that sensor! From the SparkFun website: Each sensor has a unique 64-Bit Serial number etched into it - allows for a huge number of sensors to be used on one data bus.

See these instructions as well:

https://www.cl.cam.ac.uk/projects/raspb ... mperature/

And these, with the diagram for multiple sensors - they are simply wired in parallel, one wire bus is a bus after all!

http://arduino-info.wikispaces.com/Bric ... re-DS18B20

Janez.

TimSmall
Posts: 5
Joined: Sat Jun 03, 2017 11:14 am

Re: One wire w1-gpio and w1-gpio-custom

Tue Jul 11, 2017 3:24 pm

jpers wrote: You don't need more than one bus, if you use that sensor! From the SparkFun website: Each sensor has a unique 64-Bit Serial number etched into it - allows for a huge number of sensors to be used on one data bus.
In practice it's often most convenient to use star-shaped and/or long buses with branches, and these frequently won't work reliably, when instead defining multiple buses works fine. Maxim (developer of the 1-Wire bus) has detailed information here: https://www.maximintegrated.com/en/app- ... mvp/id/148.

Fortunately since Raspberry Pi kernel 4.9.28, you can setup multiple gpio 1-Wire buses by executing as root e.g.:

Code: Select all

dtoverlay w1-gpio gpiopin=22 pullup=0
dtoverlay w1-gpio gpiopin=23 pullup=0
dtoverlay w1-gpio gpiopin=25 pullup=0
sleep 5
ls -l /sys/bus/w1/devices/

giroged
Posts: 4
Joined: Fri Feb 02, 2018 2:24 am

Re: One wire w1-gpio and w1-gpio-custom

Fri Feb 02, 2018 3:15 am

TimSmall wrote:
Fortunately since Raspberry Pi kernel 4.9.28, you can setup multiple gpio 1-Wire buses by executing as root e.g.:

Code: Select all

dtoverlay w1-gpio gpiopin=22 pullup=0
dtoverlay w1-gpio gpiopin=23 pullup=0
dtoverlay w1-gpio gpiopin=25 pullup=0
sleep 5
ls -l /sys/bus/w1/devices/
Newbie here....This seems to be working for me but I encounter an annoying issue for which I would appreciate help or insight.

Background: I'm using a second user account (me) with the same groups and sudo privileges as the pi user and I've changed the pi user's name to something else for securty using:

Code: Select all

$sudo moduser --login newname pi. 

Now when I call sudo dtoverlay from the me user account, it runs but complains there's "No passwd entry for user 'pi'" (twice):

Code: Select all

[email protected]:~ $ sudo usermod --login newname pi
[email protected]:~ $ sudo dtoverlay w1-gpio gpiopin=18 pullup=0
No passwd entry for user 'pi'
No passwd entry for user 'pi'
[email protected]:~ $ sudo usermod --login pi newname
[email protected]:~ $ sudo dtoverlay w1-gpio gpiopin=18 pullup=0
[email protected]:~ $ 
Of course,there is no longer user pi, but something in dtoverlay is looking for a pi user passwd anyways. FWIW, the dtoverlay call seems to work as I am able to read 11 DS18B20's from 1-wire busses on the same RPi. I just wish I wasn't getting the No Passwd messages.

Thanks for any help!

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2584
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: One wire w1-gpio and w1-gpio-custom

Fri Feb 02, 2018 9:27 am

These error messages are triggered by the dtoverlay-pre and dtoverlay-post scripts that allow certain actions to be taken before adding or removing overlays. These hooks were added to allow the lxpanel volume control to be told to close its ALSA connections, otherwise unloading soundcard overlays tended to deadlock. The user ID is needed because lxpanelctl must be run as the logged in user, whereas sudo causes things to be run as root.

A small experiment suggests that the "exec su pi" in the script can be replaced by "exec su $SUDO_USER". If you can confirm that it solves the problem for you I'll get the scripts updated.

giroged
Posts: 4
Joined: Fri Feb 02, 2018 2:24 am

Re: One wire w1-gpio and w1-gpio-custom

Fri Feb 02, 2018 1:53 pm

PhilE wrote:
Fri Feb 02, 2018 9:27 am

A small experiment suggests that the "exec su pi" in the script can be replaced by "exec su $SUDO_USER". If you can confirm that it solves the problem for you I'll get the scripts updated.
I'd be happy to try that...which scripts do I need to modify and how? Are you referring to dtoverlay-pre and dtoverlay-post? I was only able to find binary files of these ( e.g. /usr/bin/dtoverlay-pre /opt/vc/bin/dtoverlay-pre).

Thanks!

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2584
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: One wire w1-gpio and w1-gpio-custom

Fri Feb 02, 2018 1:57 pm

They may be in /usr/bin (actually /opt/vc/bin - the others are symlinks) but they are text file scripts - just open them up in your favourite editor, provided you have root privileges or use sudo.

After some internal testing we've merged a patch that makes this change, but also falls back to LOGNAME before resorting to "pi". That should be in the next firmware release.

giroged
Posts: 4
Joined: Fri Feb 02, 2018 2:24 am

Re: One wire w1-gpio and w1-gpio-custom

Fri Feb 02, 2018 4:58 pm

Success!! Now, the "No passwd entry for user 'pi'" messages no longer appear when the pi user name is absent on the RPi (e.g. changed via sudo usermod --login newname pi).

One last question about managing overlays....Could reloading an overlay without first removing it lead to problems? I've been doing this multiple times without apparent issues (yet?) running a program reading several DS18B20 sensors on two different w1 masters (gpiopin=4 and gpiopin=18). Every time it runs (1x per minute from crontab) it calls the necessary dtoverlays from within the program:

Code: Select all

os.system('modprobe w1-gpio')   # loads w1-gpio module into the unix kernel
os.system('sudo dtoverlay w1-gpio gpiopin=4 pullup=0')  #Set up a w1 master on gpiopin=4
os.system('sudo dtoverlay w1-gpio gpiopin=18 pullup=0') #Set up another master on gpiopin=18
I noted that each time the program runs, the list of dtoverlays grows:

Code: Select all

[email protected]:~$ dtoverlay -l
Overlays (in load order):
0:  w1-gpio  gpiopin=4 pullup=0
1:  w1-gpio  gpiopin=18 pullup=0
2:  w1-gpio  gpiopin=4 pullup=0
3:  w1-gpio  gpiopin=18 pullup=0
4:  w1-gpio  gpiopin=18 pullup=0
5:  w1-gpio  gpiopin=4 pullup=0
6:  w1-gpio  gpiopin=18 pullup=0
Is this likely harmless or heading for trouble? Would it be a good idea to remove the overlays when the program exits.?

Many thanks!

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2584
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: One wire w1-gpio and w1-gpio-custom

Fri Feb 02, 2018 5:27 pm

[ "modprobe w1-gpio" is unnecessary - the overlay will ensure the module is loaded. ]

I'm sure your Pi would run out of some precious resource eventually if you were to load both overlays every minute. Why not check for the existence of the overlays before loading them, or load them in some other one-off script? Alternatively, unloading the overlays at the end of the script would be a good idea. If you know there are no other runtime overlays then "sudo dtoverlay -R" would be the simplest and most efficient way to remove your additions (by removing them all). If that isn't appropriate, run "sudo dtoverlay -r w1-gpio" twice.

UPDATE

The w1-gpio driver appears not to like being unloaded - I've had it crash a few times - so loading the overlays once, either in a separate script or after checking for their existence, is a better bet.

giroged
Posts: 4
Joined: Fri Feb 02, 2018 2:24 am

Re: One wire w1-gpio and w1-gpio-custom

Fri Feb 02, 2018 7:49 pm

Excellent! I should be good to go :-)
Cheers

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