cron2
Posts: 3
Joined: Tue Jan 31, 2012 9:48 pm

Re: 1wire using GPIO?

Wed Feb 01, 2012 9:46 am

Hi,

I've been experimenting with Dallas' 1wire-sensors a lot recently, and sometimes it's a bit hard to reach certain places with cables, due to "lack of cable ducts" - so using a small local device there to drive the measurements bus, and communicate back using WiFi is the only viable option.  The R-PI very much looks like it wouldfill that niche

Now, the question is how to connect the 1wire bus to the R-PI.  "Traditional" busmasters connect to serial ports or USB, but since the R-PI only has a single port and the standard USB 1wire busmasters cost about the same as the whole R-PI, this is not sounding overly attractive.

The current linux kernel has support for in-kernel 1wire drivers using GPIO pins to drive the 1wire bus with bit-banging.  Which sounds very attractive.

Now the real question: what are the specs of the R-PI GPIO pins?  What voltage do they use?  What would be needed to drive a 1wire bus from there?  (Given the power limitations of the R-PI, I would use "powered" 1wire with extra +5V from the PSU that feeds the R-PI, and not use "parasitic powered" 1wire where the sensors draw their power from the bus line).

If using the GPIOs is not feasible - I've seen mention of an UART on the SoC.  Is this something that the Linux kernel already supports, and presents as a /dev/tty* device?  What signal levels does the UART present to the outside?  TTL/3.3V?  (So one could hook a MAX232 or something to it, and then drive a RS232/1wire busmaster from there).

looking forward to your answers and ideas

gert

cron2
Posts: 3
Joined: Tue Jan 31, 2012 9:48 pm

Re: 1wire using GPIO?

Wed Feb 01, 2012 10:06 am

Hi,

ok, question about the UART is answered in the Wiki (3.3V TTL levels).  It's still not the preferred approach, as GPIO should be able to do this with less extra hardware - if possible at all...

gert

jubbs
Posts: 2
Joined: Sat Feb 04, 2012 2:17 am
Contact: Website

Re: 1wire using GPIO?

Sat Feb 04, 2012 2:24 am

According to this document a UART controlling a one wire network could be the simplest option.

http://www.maxim-ic.com/app-no.....mvp/id/214

error404
Posts: 351
Joined: Wed Dec 21, 2011 11:49 pm

Re: 1wire using GPIO?

Sat Feb 04, 2012 3:11 am

Using GPIO should be possible. See the previous thread on this topic...

cron2
Posts: 3
Joined: Tue Jan 31, 2012 9:48 pm

Re: 1wire using GPIO?

Fri Feb 10, 2012 10:40 am

jubbs said:


According to this document a UART controlling a one wire network could be the simplest option.

http://www.maxim-ic.com/app-no.....mvp/id/214


This is an approach I didn't even think of yet - directly drive the 1wire bus from the UART  (I was thinking of using one of the maxim serial-to-1wire chips to do so).  Interesting.  Might need some 3.3V->5V driver chip, though.

Time for the PIs to ship so I can start fiddling with that

hzrnbgy
Posts: 106
Joined: Mon Dec 26, 2011 10:55 pm

Re: 1wire using GPIO?

Sat Feb 11, 2012 10:03 am

I was just finishing my DS18B20 (temperature sensor) driver for an 8-bit microcontroller.

The timing requirements for these 1-wire devices are somehow harder to implement in a full blown OS like Linux. You would be better off having a separate controller (an 8 bit MCU) that talks to the device and have Linux talk to the MCU.

The DS18B20 alone requires resolution of at least 5 microsec to work properly. A $2 AVR attiny chip can easily handle this.

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

Re: 1wire using GPIO?

Wed May 16, 2012 5:53 pm

And what about this?

http://www.acmesystems.it/1wire

It seems that the RPi uses bigbanging, too. So it is possible, isn't it?

GadgetUK
Posts: 61
Joined: Thu Jan 19, 2012 6:02 pm

Re: 1wire using GPIO?

Thu May 17, 2012 9:17 pm

Far better would be to use an i2c 1-wire bus master, I've just got these working, full details in my blog post here: http://go.je/iire

bateau62
Posts: 5
Joined: Sun May 20, 2012 1:50 pm

Re: 1wire using GPIO?

Sun May 20, 2012 2:26 pm

For those wanting to run more than very few sensors or want to run long onewire cable lengths, I strongly suggest not using the Dallas provided bus masters, but using some improved bus masters. I personally use the ones from IbuttonLink (LinkOEM to be precise, driven through a UART). They behave very well, are fairly robust against ESD by themselves, although I strongly suggest adding some low capacity ESD protection circuitry to them for anything more than a couple of meters or anything going outside of the house, no matter the length.
I have only seen some fairly infrequent CRC problems with DS2438 devices (and just 1 automated retry always fixed it), and I had to capacitively load the DS2450 devices (but they are known troublemakers), but for the rest they run very well. I've had only 1 temp sensor reading error in over 5 years, running a hole range of temp sensors on parasitic power, together with a load of I/O, counter and hygro sensors, some even over flat cable (don't do that).

If you want to connect only one temp sensor on a short leash, then bit-banging through GPIO can be OK, but believe me, once you get the hang of these buggers, you'll want more.

As for the libraries/drivers used, I've looked at OWFS, but found the code to be not portable enough (I develop and debug on Windows, run live on OpenBSD), very difficult to integrate in a tight close-to real time environment, and of bad quality, prone to break some sensors over time (some code hammers on the flash memory config registers, wearing them out prematurely), so I've constructed my own C library, from some Dallas provided examples.
But YMMV.
My 2 cents.

Return to “Automation, sensing and robotics”