element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • Product Groups
  • Store
    Store
    • Visit Your Store
    • Choose Another Store
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
Raspberry Pi
  • Products
  • More
Raspberry Pi
Blog Raspberry Pi speaks 1-wire with Adafruit's Occidentalis image
  • Blog
  • Forum
  • Documents
  • Events
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Raspberry Pi requires membership for participation - click to join
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: fustini
  • Date Created: 8 Aug 2012 5:45 PM Date Created
  • Views 1088 views
  • Likes 0 likes
  • Comments 14 comments
Related
Recommended
  • ladyada
  • raspberry_pi
  • 1wire
  • raspberrypi
  • adafruit

Raspberry Pi speaks 1-wire with Adafruit's Occidentalis image

fustini
fustini
8 Aug 2012

Adafruit recently released their own Raspberry Pi image, Occidentalis v0.1:

http://learn.adafruit.com/system/assets/assets/000/001/532/medium800/occidentalis.png?1343962191

This is our first distro,  Occidentalis v0.1. Rubus occidentalis is the black raspberry.  It is derived from Raspbian Wheezy July 15


We have made a few key changes to make it more hardware-hacker friendly!

  • Updated to Hexxeh firmware
  • 4 Gig SD image (will not fit in 2 G cards!)
  • I2C and hardware SPI support
  • I2C/SPI modules initialized on boot
  • sshd on boot
  • ssh keygen on first boot
  • runs ahavi daemon (Bonjour client) and is called raspberrypi.local
  • Realtek RTL8188CUS wifi support
  • One wire support on GPIO #4 when loaded

 

I thought that looked like a nice list of improvements.  I'd already been using I2C with bootc.net's image, but the new 1-wire support piqued my interest.  I downloaded & flashed the Occidentalis image onto a SD card and then booted up:

image

The login is the usual pi/raspberry.  Before I tested out 1-wire, I thought I would check to see if my Asus USB-N13 was supported as Adafruit compiled the driver it needs, rtl8192cu, into the kernel in their image.  To my delight, the USB-N13 was immediately recognized (unlike with the "regular" Raspbian Wheezy image):

image

Alright, on to some electronics!  The Occidentalis page states about 1-wire:

One wire is most commonly used for DS18B20 temp sensors. The Pi does not have 'hardware' 1-wire support but it can bitbang it with some success.

The page also highlights the commit that makes it possible:

 

Dallas one wire interface with the Linux w1 GPIO bitbanging implementation on GPIO 4

 

I already had the DS18B20 temperature sensors, so I just hooked it up as the page described:

Connect a DS18B20 with VCC to 3V, ground to ground and Data to GPIO #4. Then connect a 4.7K resistor from Data to VCC.

image

(note: I'm using the Adafruit Pi Plate on top of Raspberry Pi to make the connections; FTDI cable for serial console is also pictured)

 

I continued to follow the documentation:

Then run as root: modprobe w1-gpio and then modprobe w1-therm to attach the temperature submodule. Then you can run cat /sys/bus/w1/devices/28-*/w1_slave to read the temperature data from the bus


The first line has the CRC, if its "NO" then the data is corrupted. If you get a good CRC check, the second line has t=temperature in 1/100 of a degree Centigrade. For example, below, the temperature is 24.5°C


Since 1-wire is bitbanged, its flakier than SPI or I2C.  We do not have any 1-wire tutorials for the RPi at this time

Here is a screenshot of my results:

image

The temperature value was 34000 which I believe would mean 34 C or 93 F.  This seems hotter than it actually was, so I'm planning to verify the results with the I2C TMP102 temp sensor next to the DS18B20.

 

Cheers,

Drew

  • Sign in to reply

Top Comments

  • morgaine
    morgaine over 10 years ago +1
    It was very interesting for me to see your article Drew, as I've had a soft spot for 1-Wire and iButtons since the early 90's and have lots of such devices here, mostly early serial number and storage…
  • Former Member
    Former Member over 10 years ago

    Hello Drew,

     

    Thanks, you're right, it is GPIO4 which is in fact Pin 7, sorry for the mistake image

     

    Thank you for your support.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • fustini
    fustini over 10 years ago in reply to fustini

    Ah, I think that the difference is that "GPIO #4" is physically pin 7 on the header:

     

    http://elinux.org/RPi_Low-level_peripherals#General_Purpose_Input.2FOutput_.28GPIO.29

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • fustini
    fustini over 10 years ago in reply to Former Member

    Very interesting.  I had thought 1-wire support was hardcoded to use GPIO #4.  You might want to post in their Raspberry Pi forum group to ask: http://forums.adafruit.com/viewforum.php?f=50&sid=916cbc3b8cadc53e8a8268d9d014e69b

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Former Member
    Former Member over 10 years ago

    Hello,

     

    I've managed to get DS18B20 sensors working correctly with Occidentalis image but I needed to connect Data to GPIO #7 instead of GPIO #4, is there an error in the adafruit instructions?

     

    Thank you for your support,

     

    Fabrice FAURE


    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • fustini
    fustini over 10 years ago in reply to daloele

    Yeah, I kinda of remember that from when I used to have a 1-wire temp sensors in a server room hooked up to a Linux server.  This 1-wire support I'm describing above is just bit-banged so maybe not the most robust solution (good for a single DS18B20 for simple temp sensing though).  This site posted about what's probably a more "proper" solution of interfacing 1-wire to the Pi by using 1-wire bus ICs: http://raspberrypi.homelabs.org.uk/category/1-wire/

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2023 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • Facebook
  • Twitter
  • linkedin
  • YouTube