DS18B20 / 1-wire via Little Wire (USB) / OpenWrt on TL-WR841ND

Posted by

I wanted to interface something to my WR841, without too much hassle.
But also some cheap way to do so, to keep advantages of the WR841 price…

Luckly, I already had an AVR-USB based platform, based on ‘Little Wire’ : http://littlewire.cc/

With its latest v1.1 firmware, 1-Wire is available via the Little Wire : that’s my perfect candidate to
add a DS18B20 and to make some temperature measures.

I have quickly cross-compiled the onewire.c example given in the C computer interfacing sources
(Openwrt buildroot, linking the source with libusb-0.1.12) and here is the result :


root@OpenWrt:~# cat /etc/openwrt_release
DISTRIB_ID="OpenWrt"
DISTRIB_RELEASE="Bleeding Edge"
DISTRIB_REVISION="r33276"
DISTRIB_CODENAME="attitude_adjustment"
DISTRIB_TARGET="ar71xx/generic"
DISTRIB_DESCRIPTION="OpenWrt Attitude Adjustment r33276"
root@OpenWrt:~# lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB
Bus 001 Device 003: ID 1781:0c9f Multiple Vendors USBtiny
Bus 001 Device 004: ID 1e3d:8246
root@OpenWrt:~# /root/onewire
> Little Wire firmware version: 1.1
> Address search ...
> Addr#0: 28 4F 4F 7E 2 0 0 3B
> End of search with 1 device(s) found
> Start the talking with the last device found
> 64 1 4B 46 7F FF C 10 1
> 63 1 4B 46 7F FF D 10 15
> 63 1 4B 46 7F FF D 10 15
> 64 1 4B 46 7F FF C 10 1

 

Update 20/03/2013 :

Created an OpenWrt source package and an ipkg (not tested)

4 comments

  1. Hi,
    I did not find your name on this page.
    This is an interesting project.

    I’m doing a similar project, but with a TL-WR703N router and LittleWire.
    Could you help me a little bit to port littleWire over to the mips WR703N router.

    I do not need much help, just a little clarification.
    I have difficulty to cross-compile the LittleWire library over to MIPS.
    In the C libraries, I compiled on debian linux using gcc, without problems.
    It works good.

    I’m not a newbie and not an expert. I have some skills at C dev.

    For example, I have ported my own USB to serial driver from i386 to
    the mips WR703N router, no problem. It works good.

    This is what I get as an error, when I use the makefile.
    The only change I made to the makefile is change CC=gcc to
    CC=mips-linux-uclibc-gcc .

    ————–
    mike@mike-System-Linux-Mint /home/mike/MIPStoolchains/littleWire $
    export PATH=/home/mike/MIPStoolchains/staging_dir_mips/bin:$PATH

    mike@mike-System-Linux-Mint ~/MIPStoolchains/littleWire $ make library
    Building library: opendevice…

    mips-linux-uclibc-gcc `libusb-config –cflags` `libusb-config –libs`
    -Ilibrary -O -g -D LINUX -c library/opendevice.c

    In file included from library/opendevice.c:18:
    library/opendevice.h:27:77: error: usb.h: No such file or directory
    In file included from library/opendevice.c:18:
    library/opendevice.h:33: error: expected ‘)’ before ‘*’ token
    library/opendevice.h:44: error: expected ‘)’ before ‘*’ token
    library/opendevice.c:86: error: expected ‘)’ before ‘*’ token
    library/opendevice.c:116: error: expected ‘)’ before ‘*’ token
    make: *** [opendevice] Error 1
    ————–

    If you have the time to help, It would be appreciated.

    I’m working on a open-source Hardware/Software project and would
    gladly send you what I have.

    Mike

    1. Hi Mike,

      My name is Jean-Jacques (you can use JJ).

      Your problem, and from what I remember, is probably related to the way you are compiling with ‘libusb-config’.
      It will return your host’s configuration, which is not what will run on the target.
      I remember I had to change paths in the Makefile for libusb to get it to work, but I never took the time to create a clean package for it.

      I will have a look at my code archive and will give you details in the next couple days.

      Thanks,

      JJ

    2. I found that my Makefile was starting by :

      OPENWRT=/home/jjm/openwrt/trunk
      STAGING_DIR=$(OPENWRT)/staging_dir
      export STAGING_DIR

      CC=$(STAGING_DIR)/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/bin//mips-openwrt-linux-gcc

      USBFLAGS = -I$(OPENWRT)/build_dir/target-mips_r2_uClibc-0.9.33.2/libusb-0.1.12
      USBLIBS = -L$(OPENWRT)/build_dir/target-mips_r2_uClibc-0.9.33.2/libusb-0.1.12/.libs/ -lusb

      Good Luck,

      JJ

    3. I took some time today to create a package and an ipkg file, but I have not tested them.
      See the update at the end of the article.

      JJ

Leave a Reply

Your email address will not be published. Required fields are marked *