OpenWrt Forum Archive

Topic: 1-wire protocol to make a LaFonera read temperature from a DS18B20

The content of this topic has been archived on 29 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hello,

I'm working on a DIY project with a LaFonera router. I'll have up to 8 relays/tyristors being switched by a PCF8574 (via I2C Protocol) and I'll read temperature through a DS18B20 sensor (via 1-Wire protocol).
LaFonera router have 4 GPIO's available so I'll use 3 (2 for I2C and 1 for 1-w), and I'll still have 1 available for anything else :-)

I have the latest trunk version loaded and the I2C part is working fine. For further information on the I2C part, check my other topic.
Now, I'm trying to implement the 1-Wire part based on the http://squidge.sourceforge.net/w1/ site. However, I'm having some difficulties because it seems the W-1 module is not sucessfully loaded into the kernel: "w1_gpio: Unknown symbol ar231x_gpiodev (err 0)"

What I have so far:

root@OpenWrt:/sys/devices# opkg list-installed | grep -i w1
kmod-w1 - 2.6.37.6-1
kmod-w1-gpio-custom - 2.6.37.6-2
kmod-w1-master-gpio - 2.6.37.6-1
kmod-w1-slave-therm - 2.6.37.6-1
root@OpenWrt:/sys/devices# lsmod | grep -i w1
w1_therm                1664  0
w1_gpio_custom           800  0
root@OpenWrt:/sys/devices# dmesg | grep -i w1
wire: exports duplicate symbol w1_remove_master_device (owned by kernel)
Custom GPIO-based W1 driver version 0.1.1
w1_gpio: Unknown symbol ar231x_gpiodev (err 0)
root@OpenWrt:/sys/devices#

Googling for these keywords resulted in few clues...

I'm prety new to OpenWRT, and I'm having difficulties identifying the correct contact for each package. I mean, I could try to contact the package owners in order to get some user-manual, or just some tips on how to get it working...

Any suggestion or tip? Would it be a patch needed?

Thanks in advance,
Jabss

I'm not really experienced with onewire, but

jabss wrote:

"w1_gpio: Unknown symbol ar231x_gpiodev (err 0)"

is caused by Karls patch (it eliminates ar231x_gpiodev), maybe he knows what to do. From what I could see, it is very similar to the i2c-gpio driver, so I don't have a clue why i2c works and w1 does not.

Hello,

I contacted Karl and it seems there is no problem with the GPIO patch.
As I could understand from Karl's e-mail (I don't have much knowledge about programing) it seems there is a problem with the way the w-1 code "asks" for a pin because the "ar231x_gpiodev" symbol should never have been getting accessed by any one wire code anyway, it should just be asking the kernel about getting a gpio pin, not a particular gpio platform driver. This is handled with gpiolib and sysfs by a "struct gpio_chip" pointer.  This sounds like "less-good" code in the 1-wire implementation.

How can I know who is/are the developer of the w-1 drivers, so I could warn him/them about this problem?

Thanks!
Jabss

I think I found your mistake: by installing the w1 packages, you used the repositories of the openwrt servers, instead the one that you built. You need to edit /etc/opkg.conf. Most likely the first line links to something like downloads.openwrt.org/snapshots/trunk and so on. Change that to the directory, where you keep your built packages (bin/atheros/packages). So, if you have enough free ram on the router, just copy it over to /tmp and change that mentioned line in opkg.conf to file:///tmp/packages. Alternatively, you can run a web server on your pc and change the link in opkg.conf to something like http://url/to/your/pc/packages.

Hello,

I'm almost sure I used the binaries from my build. However, I'll repeat everyting this weekend.
By the way, should I reflash everything or a opkg remove (and install) will sufice?

Thanks,
Jabss

Just uninstall w1-gpio (and w1-gpio-custom first, since it depends on w1-gpio) and then install your version. From what I could see, it is only w1-gpio which causes the troubles about the ar231x_gpiodev dependency. You can also just copy those two packages to /tmp on your router and then issue something like: opkg install /path/to/your/packages.opkg

Hello,

Tried to unistall and install and got some kernel errors, so I flashed everything back again. I then installed the 1-wire packages and realised in the webpage ( http://squidge.sourceforge.net/w1/ ) and realised that after all it's expected to have some of these errors: "There will probably be an error message from the kernel to tell you that the device has not been associated with a driver."

Anyway, I looked into the "/sys/devices/w1 bus master/" and there it was a "28-0000033a6183" directory!

root@OpenWrt:/sys/devices/w1 bus master# ls
28-0000033a6183            w1_master_attempts         w1_master_remove
driver                     w1_master_max_slave_count  w1_master_search
subsystem                  w1_master_name             w1_master_slave_count
uevent                     w1_master_pointer          w1_master_slaves
w1_master_add              w1_master_pullup           w1_master_timeout
root@OpenWrt:/sys/devices/w1 bus master# cd 28-0000033a6183/
root@OpenWrt:/sys/devices/w1 bus master/28-0000033a6183# ls
driver     id         name       subsystem  uevent     w1_slave
root@OpenWrt:/sys/devices/w1 bus master/28-0000033a6183# cat w1_slave
1d 01 4b 46 7f ff 03 10 c5 : crc=c5 YES
1d 01 4b 46 7f ff 03 10 c5 t=17812
root@OpenWrt:/sys/devices/w1 bus master/28-0000033a6183#

There is 17,812º in the sensor!

It works! I'm very happy now!

Thanks for all of your tremendous help!
Jabss

Dear Jabss,

I have a ASUS WL-500g Premium (V1) router where I have 2 USB ports and 4 RJ45 ports. I installed OpenWRT on it and though to use OWFS and digitemp (or rrdtool) to read temperature in my house (home automation ideas).

Now I found how to use DS18B20 (temperature reader) on an RJ11, I have two main question I presume ou will easily answer. I ask you this because I am not an electronical guy.
1) As my router has RJ45 and USB ports :
    a) can I directly connect my DS18B20 on the RJ45 cables like this (for RJ11) ? : http://rosset.org/linux/temperature/howto1.html
        If well, as I want to have more than one DS18B20 on the cable :
            I) on which line (from the 8 lines in the cat 5 RJ45 cable considering the standard RJ45 connection) must I connect the DS18B20 ?
           II) must I connect all the DS18B20 in serial on the two same colored small cables (the 2 selected lines of the cat 5 RJ45 cable) or must / could I use two other different lines ?
    b) when the DS18B20 is connected on the two cables could I directly connect the RJ45 cable to the RJ45 port of the router or must I use a specific connector between the router and this cable (on which the DS18B20 are mounted) ?
    c) then if I must connect it to the USB port which adapter must I use between the USB port and the mounted RJ45 cable ?

Sincerely thanks for your experience share.

Miguipda ;-)

Hello Miguipda,

I'm not familiar the Asus WL-500gP router, anyway I'm afraid getting your project done will not be so easy as connecting a DS18B20 into any of the router ethernet ports...
However, I think it might be possible to acomplish it in one of two ways.

But, before anyting else, please keep in mind that any router's RJ-45 ports are intended for ethernet only. If you connetct anything else (like the DS18B20) to it you can risk to burn something, so please don't do it :-)

Option 1)
My home automation projects rely on routers GPIO's, which are "general purpose Input/Output" pins that you can control its state with software ( http://en.wikipedia.org/wiki/General_Pu … put/Output ).
The OpenWrt W-1 packages mentioned in the above posts implement the 1-wire protocol in one of these GPIO's. That's where I connect the DS18B20 (which is, as you know, a 1-wire device), and where I suggest you to connect.
The drawback of this is that you'll need to open your router and identify one available GPIO. Again, I don't know the WL500gP router and therefore don't know if there is any available (you have to check the forum for HW details on your router. In alternative you may want to open a new post asking some help in finding it). Sometimes it might be needed to use a GPIO that can be feeding a router LED (GPIO's are frequently used to feed status LED's).

Option 2)
When checking the site you referenced I could notice other possibility: The DS18B20 "talks" 1-wire, right? I believe the site has a 1Wire-RS232 converter (I'm not so good at french - http://rosset.org/linux/temperature/howto2.html ). Then, you just need a cheap RS232-USB converter. Maybe something like ( http://www.ebay.com/itm/USB-2-0-RS232-S … 2316800dce ).
In order to choose the RS232-USB converter, you may need to choose a chipset that is supported by OpenWRtT. Again, you can check the forum and try to find some information about it.
You'll have to check the feasibility for this option. Searching and asking help in the forum might be necessary.
This option can give you more work, but at least you don't need to open your router.

So, answering your questions:

1a) No, you can't. Please keep in mind that any router's RJ-45 ports are intended for ethernet only. If you connetct anything else (like the DS18B20) to it you can risk to burn something, so please don't do it :-)

1a I-II) You can have as many as DS18B20's in the same bus as you want. You can connect them in paralell with the same pinout because the 1-w bus is designed for it. However, you'll have to connect it to a proper pin (try to find a GPIO in your router and then load the software mentioned above). It will not work if you connect to a RJ-45 port!

1b)You can connect the DS18B20 directly into any GPIO port (don't forget the pull-up resistor). There is no connector/adapter that translates 1-wire to Ethernet, so you can't really use the RJ-45 ports for the DS18B20.

1c)As I mentioned in the option 2, you can try to have a 1-wire <-> RS232 <-> USB connetction. As you know, almost all USB devices need a driver to work properly. In this case you'll need to find a RS232-USB adapter that has it's driver implemented in the OpenWRT.

I know that probabily this wasn't the answer you were expecting, but I't better you know this in advance rather than risking damaging your material... Keep in mind that it will be possible. The thing is that it will be more challenging :-)

Good Luck!
Jabss

The discussion might have continued from here.