One Wire Temp Sensor

Been looking at tutorials and source for One Wire gpio and I am wondering if anybody else is using this work?
I bought a dozen DS18B20 temp sensors to mess with.

The source notes for /sys/dev/ow/owll_if.m has to be the most elaborate source documentation ever.

Bravo Warner Losh
 
That's an RTD (Resistance Temperature Detector).

Other types of temperature measuring devices are thermocouples, and thermistors. A thermopile, is just a bunch of thermocouples.
 
How much wire length can I run to each detector?
Might do multiple sensors and power in one CAT6 run for 3 detectors.
 
The chip is not just a passive device. Here is the data sheet. http://datasheets.maximintegrated.com/en/ds/DS18B20.pdf. I found some information about maximum speed but nothing about minimum speed. About power supply see the options in figure6 and figure7. At least the parasite power supply gives a limit with respect to slow timing since the chip must be powered from a capacitor or so during data transmission. The application notes on page 17 should give reliable information.
 
Thank you for seeking the application note. It is an excellent document. By the way, I have not expected that the bus is suitable for more than 100m. This is good to know.
 
Got this working today on RPi2.
Code:
root@rpi2:~ # sysctl dev.ow
dev.ow.0.%parent: owc0
dev.ow.0.%pnpinfo:
dev.ow.0.%location:
dev.ow.0.%driver: ow
dev.ow.0.%desc: 1 Wire Bus
dev.ow.%parent:
root@rpi2:~ # sysctl dev.owc
dev.owc.0.%parent: gpiobus0
dev.owc.0.%pnpinfo: name=onewire compat=w1-gpio
dev.owc.0.%location: pin=4
dev.owc.0.%driver: owc
dev.owc.0.%desc: FDT GPIO attached one-wire bus
dev.owc.%parent:
root@rpi2:~ # sysctl dev.ow_temp
dev.ow_temp.0.parasite: 0
dev.ow_temp.0.reading_interval: 1000
dev.ow_temp.0.badread: 0
dev.ow_temp.0.badcrc: 0
dev.ow_temp.0.temperature: 23.500C
dev.ow_temp.0.%parent: ow0
dev.ow_temp.0.%pnpinfo: romid=28:ee:04:0c:1d:16:02:89
dev.ow_temp.0.%location:
dev.ow_temp.0.%driver: ow_temp
dev.ow_temp.0.%desc: Advanced One Wire Temperature
dev.ow_temp.%parent:
 
I really wanted 3 temperature detectors so here is what I ended up with:
Code:
root@rpi2:~ # sysctl dev.ow
dev.ow.2.%parent: owc2
dev.ow.2.%pnpinfo:
dev.ow.2.%location:
dev.ow.2.%driver: ow
dev.ow.2.%desc: 1 Wire Bus
dev.ow.1.%parent: owc1
dev.ow.1.%pnpinfo:
dev.ow.1.%location:
dev.ow.1.%driver: ow
dev.ow.1.%desc: 1 Wire Bus
dev.ow.0.%parent: owc0
dev.ow.0.%pnpinfo:
dev.ow.0.%location:
dev.ow.0.%driver: ow
dev.ow.0.%desc: 1 Wire Bus
dev.ow.%parent:
root@rpi2:~ # sysctl dev.owc
dev.owc.2.%parent: gpiobus0
dev.owc.2.%pnpinfo: name=onewire2 compat=w1-gpio
dev.owc.2.%location: pin=22
dev.owc.2.%driver: owc
dev.owc.2.%desc: FDT GPIO attached one-wire bus
dev.owc.1.%parent: gpiobus0
dev.owc.1.%pnpinfo: name=onewire1 compat=w1-gpio
dev.owc.1.%location: pin=27
dev.owc.1.%driver: owc
dev.owc.1.%desc: FDT GPIO attached one-wire bus
dev.owc.0.%parent: gpiobus0
dev.owc.0.%pnpinfo: name=onewire0 compat=w1-gpio
dev.owc.0.%location: pin=17
dev.owc.0.%driver: owc
dev.owc.0.%desc: FDT GPIO attached one-wire bus
dev.owc.%parent:
root@rpi2:~ # sysctl dev.ow_temp
dev.ow_temp.2.parasite: 0
dev.ow_temp.2.reading_interval: 1000
dev.ow_temp.2.badread: 0
dev.ow_temp.2.badcrc: 15
dev.ow_temp.2.temperature: 22.875C
dev.ow_temp.2.%parent: ow2
dev.ow_temp.2.%pnpinfo: romid=28:ee:6c:0c:20:16:01:8a
dev.ow_temp.2.%location:
dev.ow_temp.2.%driver: ow_temp
dev.ow_temp.2.%desc: Advanced One Wire Temperature
dev.ow_temp.1.parasite: 0
dev.ow_temp.1.reading_interval: 1000
dev.ow_temp.1.badread: 0
dev.ow_temp.1.badcrc: 23
dev.ow_temp.1.temperature: 22.687C
dev.ow_temp.1.%parent: ow1
dev.ow_temp.1.%pnpinfo: romid=28:ee:a3:1c:20:16:01:ff
dev.ow_temp.1.%location:
dev.ow_temp.1.%driver: ow_temp
dev.ow_temp.1.%desc: Advanced One Wire Temperature
dev.ow_temp.0.parasite: 0
dev.ow_temp.0.reading_interval: 1000
dev.ow_temp.0.badread: 0
dev.ow_temp.0.badcrc: 19
dev.ow_temp.0.temperature: 23.062C
dev.ow_temp.0.%parent: ow0
dev.ow_temp.0.%pnpinfo: romid=28:ee:e0:02:1d:16:02:59
dev.ow_temp.0.%location:
dev.ow_temp.0.%driver: ow_temp
dev.ow_temp.0.%desc: Advanced One Wire Temperature
dev.ow_temp.%parent:
 
Vadims website was what I used to get this running:
https://vzaigrin.wordpress.com/2016/01/12/one-wire-on-raspberry-pi-with-freebsd-11/

To add extra sensors I had to guess, improvise and glance at Linux.
So I just appended on a number to create separate owc buses in the rpi2.dtb:

Code:
    };

   onewire0 {
       compatible = "w1-gpio";
       gpios = <&gpio 17 1>;
 
   };

   onewire1 {
       compatible = "w1-gpio";
       gpios = <&gpio 27 1>;

   };

   onewire2 {
       compatible = "w1-gpio";
       gpios = <&gpio 22 1>;
 
   };

So I have 2 sensors powered by the 5V pins and one powered by the 3.3v pin.
I also have the DS3231 RTC working on the same board.
 
It is not necessary to actually create separate OWC bus's but I prefered the method. This works too on a single bus:
Code:
 };

   onewire {
       compatible = "w1-gpio";
       gpios = <&gpio 17 1>,<&gpio 27 1>,<&gpio 22 1>;

   };
This turns Pins 17,27,22 to onewire compatible and turns the pins ON.

Raspberry Pi header pin 11=17
Raspberry Pi header pin 13=27
Raspberry Pi header pin 15=22

I had to use other pins than the tutorial as I wanted to maintain the DS3231 RTC on Pi header pins 1,3,5,7,9

I am planning on running 3 CAT5 lines with each on its own bus with several sensors on each line.

The 4.7k resistor is a must as well or the bus errors out.
The resistors are also directional. They only work in one direction.
 
The resistors are also directional. They only work in one direction.
Excuse me? I understand that you will want to put a resistor the correct way to be able to read the markings in the correct order, but other than that resistors are not directional. In an electrical circuit, they will work no matter which way they are connected. :)
 
How much wire length can I run to each detector?
We use one-wire setups in a 500+ units lab security system and have tested length up to 100m with no problems. Even tried looping it around the spark-plug of a running engine - no problems. Twisted/untwisted is not relevant since one-wire does not use current loop. Plain standard 4wire telephone wire works just as well.
 
What sensor are you using if you don't mind me asking. I am interested in any OW sensors as they work so well. Mine on Pi have been up over a month now. I am planning on using phone wire already installed for temp sensors myself.
You using ultrasonic sensors for security? How about petite 3-wire like AWG30. Very minimal milliamp usage.
 
We use std ds1820 with parasite power for ambient temperatures; but not more then 10 on a single wire.
For the -80degC freezers we use ds2450 with real power on wire-3 connected to thermocouple.
For binary io we use ds2408 - also with dedicated power.
All of our cabling is 4wire untwisted telephone cable with 4p4c modular connectors.
 
The 4p4c connectors are a good way to go I think. I am now thinking about making a onewire hub//pi-hat using RJ9 Jacks.
It does seem telephone cable is more robust than needed but it is cheap.

I guess there is a standard 4P wiring layout you use? Black-Ground and Red-Power and Green data/signal or Yellow line?
 
Off Topic, but might be usefull: DalSemi uses six wires in RJ11 config. Don't know of a standard for RJ9. It's best to keep compatibility if only using 4 wires:
Code:
RJ11  Signal  RJ9 wire colour
1     VCC     -
2     GND     1    black
3     1Wdata  2    red
4     1Wgnd   3    green
5     NC      4    yellow
6     WAKE    -
Thus cable can be used in RJ11 socket using parasite power. We use RJ9-pin4-yellow for VCC; Not connected in RJ11 - so no problem.
 
From painful experience: parasite power, Cat5 cable, no termination at the end, no pullup resistor, and long runs (80 or 100 feet) will not work. At least not reliably. The quality of the "initiator" matters; I have some long runs that work so-so with the commercial HA7Net as a host, but don't work with anything else. Bit-banging a parallel port is the most marginal; the USB based DS9490 is considerably better. The Dallas (now Maxim) app notes are really helpful in designing 1-wire runs that work reliably.
 
My Pi2 has been very reliable. Good uptime and all sensors are reading. I do get spurious interrupt messages in the log.
My crochet image at p6.

Code:
FreeBSD 11.0-RELEASE-p6 (RPI2) #0 r308093M: Wed Jan  4 19:31:07 EST 2017

Welcome to FreeBSD!

root@rpi2:~ # uptime
 9:34PM  up 43 days, 14:58, 1 users, load averages: 0.01, 0.03, 0.00
 
Realtime-clock hanging in there too(first time I have checked it since setup):

Code:
root@rpi2:~ # ntpdate ntp.org
 4 Apr 21:38:12 ntpdate[31062]: step time server 128.4.24.98 offset -14.882408 sec
15 seconds in 3 months is acceptable to me.

This is from the DS3231 RTC module on the GPIO pins.
root@rpi2:~ # dmesg |grep ds3231
ds32310: <Maxim DS3231 RTC> at addr 0xd0 on iicbus1
 
Been working on my C.

Code:
root@rpi2:~/1wire # ./get_owtemp
OneWire Temperature Sensor #0= 24C
OneWire Temperature Sensor #1= 24C
OneWire Temperature Sensor #2= 26C
OneWire Temperature Sensor #3= 24C
OneWire Temperature Sensor #4= 24C
OneWire Temperature Sensor #5= -273C
 
Been building a prototype and it has been enjoyable to learn electronics.
I have built 4 boards for the PiHats and several sensor boards. Just starting to etch some parts to test.

boards1.jpg
 
Back
Top