multiple 1-wire sensor on One pin

tparvais

Member
Hello,

I know that we can interconnect multiple 1-wire sensor on the same bus and get info via their own address.

How is it possible via a PICAXE ? How can we connect multiple sensor to the same PIN, in order to limit the number of PICAXE to read many sensors

Idea/SCheme, code are welcome

Thank you

Thomas
 

Technical

Technical Support
Staff member
Use a 28x1 or 40x1 and the owin and owout commands.
You can then work out the unique address of each sensor and talk to each one directly.

It is more complicated than say, the readtemp command, but these commands only work with one sensor per input.
 

wbryan

New Member
The picaxe BASIC commands PDF refers to a 'One-Wire Tutorial' in the documentation for owin and owout. I've not been able to find this. Does it actually exist? Does anybody have a direct link to it? Thanks.

In answer the original question, I'm now making good progress with the LinkOEM product (link in this previous thread http://www.picaxeforum.co.uk/showthread.php?t=7808). I've got a AAG-Electronica weather station I've been using as an exercise to get to grips with PICAXE and 1-wire.

Will
 
Last edited:

tparvais

Member
Will,

This is exactly what I want to do: use PICAXE to datalog sensor info 1-wire from AAG-Electronica.

Regarding their products, are you satisfied ? Which ones have you ordered ?

It seems that the weather station is out of stock...
 

wbryan

New Member
I'm in the UK so got my weather station from http://www.audon.co.uk/

My gut feeling is that it's quite expensive, but it is nicely made and now I've got my head around talking to the various sensors via the LinkOEM I'm starting to think what to add to the system next. It'll probably be the rain 'bucket', then the barometer. I finally took it outside just this weekend, rather than manually driving it from the comfort of the living room.

My current setup is to have one picaxe 28x1 reading data from the 1-wire network periodically via the linkOEM. That picaxe samples the different sensors at different rates and does all the maths. For instance, the wind-direction is sampled every 5 seconds, but a consensus is reached once every 5 minutes as per the FAQ on the AAG website. The sensor data will be pushed via a radio link to another picaxe currently connected to the RevEd NetServer module, thus allowing me to publish the weather on the web.

It took a bit of work figure out how the LinkOEM works as a serial device, but I've got a nice set of routines to deal with exchanging hex bytes and words with it and to manage the various timers I'm using. The LinkOEM sends a hex byte in plain ascii as two characters. At the moment I'm using two 28x1's, but that's just for development work. Once I've got my code in shape I'll move to whatever is most suitable. I'll gladly publish bits or all of my code when I've got it tidied up and would be happy to answer any further questions you may have.

Will
 

lbenson

Senior Member
wbryan said above: "The picaxe BASIC commands PDF refers to a 'One-Wire Tutorial' in the documentation for owin and owout. I've not been able to find this. Does it actually exist? Does anybody have a direct link to it?"

I'd like to repeat that question. Does anyone have a direct link to the "One-Wire Tutorial"--or have code to show how owin works with multiple devices?
 

Technical

Technical Support
Staff member
The tutorial is being prepared.

As a starter this code will read the raw temp data from any DS18B20, as it uses the 'skip rom' (ignore serial number) command $CC
Code:
[B][FONT=Courier][SIZE=1][COLOR=#004f8a][LEFT]; Read raw temperature value from DS18B20
; (this achieves a similar function to the readtemp12 command)
main:
owout 1,%1001,($CC,$44)
‘ send ‘reset’ then ‘skip ROM’
‘ then ‘convert’ then apply ‘pullup’
pause 750 ‘ wait 750ms with strong pullup
owout 1,%0001,($CC,$BE)
‘ send ‘reset’ then ‘skip ROM’
‘ then ‘read temp’ command
owin 1,%0000,(b0,b1) ‘ read in result
sertxd (#w0) ‘ transmit value[/LEFT]
goto main
[/B][/COLOR][/SIZE][/FONT]
To read from more than one device you need to replace 'skip rom' $CC with the 'match rom' $55 command + the actual unique serial number (8 bytes)).

ie the first owout line above becomes
owout 1,%1001,($55,$xx,$xx,$xx,$xx,$xx,$xx,$xx,$xx,$44)

The unique serial number for each device is actually easiest found by experimentation, by using the 'readowsn' command on each 1-wire device one by one.

If using the weather station you could also use one of the free bits of weather station software to read out these unique numbers.
 

wbryan

New Member
Ahh, so it is possible to read multiple devices on a single one-wire bus without the linkOEM. I'll have a go at that once I've resolved all my current issues. I spent two evenings chasing an issue that turned out to be a shorted RJ11 connector on my recently purchased rain gauge. The next task is to figure out the barometer.

Will
 

retepsnikrep

Senior Member
I've used this idea/code succesfully for two ds18b20 devices on the same input with my BMS system, but does anyone know the limit on the number of these devices on the same bus?

I would like to read the temp of individual cells but how many can it cope with ona single input of a 28X1 with a single 4k7 pull up on the shared data line?

5, 10, 50?
 

hippy

Technical Support
Staff member
Most documents and projects I've seen using multiple DS18B20's refer to "many" which isn't entirely helpful but I have seen projects explicitly using 10.

A lot will depend upon network topology, cable used and distances the sensors are at so while there will be a limit it's hard to say where that will be. One-Wire(TM) protocol uses quite fast switching signals so as they degrade things start to become unreliable or not work.

Maxim have quite extensive documentation on their one-wire bus devices and the protocol so better answers and examples may be found there.
 
Top