Main Site Documentation

Onewire device network


#1

Hi there,
has anyone looked at making a onewire class that can handle many devices, handles on the fly addition/removal etc?


#2

Brett,

that is on my list too. Maybe we can have a peek here: http://sourceforge.net/projects/owdotnet/ (not to reinvent the wheel :wink: )


#3

Thanks Eric, nice to know someone else is looking…

My eyes glazed over trying to locate source to look for inspiration from on the sourceforge project - plus it seems pretty stagnant.

I have a kind of working solution - I say kind of because it’s just using arrays and I want it to be more general and use an arraylist. I have an arraylist sample starting to be coded but have spent hardly any time seeing if it’ll work (and I don’t know if I have the knowledge to make it work!) - I’ve been focussed on figuring out other hardware items and figuring out how to make the display component work effectively.


#4

Brett,

The source code can be found here: http://owdotnet.svn.sourceforge.net/viewvc/owdotnet/Source/Classes/OWdotNET/

what kind of devices you are looking at?

I have:
[ulist]
[li]DS18B20[/li]
[li]DS18S20[/li]
[li]DS2438[/li]
[/ulist]

The DS2438 is essentially a battery monitor, but includes also temperature. The sensors were bought from http://www.ibuttonlink.com/sensors.aspx and I have MS-T, MS-TL and MS-TH.

Another good library, though for arduino, is the one from Miles Burton: http://milesburton.com/wiki/index.php?title=Dallas_Temperature_Control_Library. He made a wrapper around the OneWire library which makes it very easy to work with the sensors.

I hope we can come up with something similar and extensible. A class per device type looks like a good approach to me, seen that every device has different addresses and scratchpad locations.

Greetings,
Eric

PS.: I’m also writing a driver for the Maxim DS1307 RTC, useful for those wanting a battery backed up RTC on their Fez Panda :wink: First tests will be done early next week.


#5

I’ve only got DS18B20’s since temperature readings is all I’m currently interested in.

Yeah I have downloaded the source from there (I did figure it out :slight_smile: eventually ;D ) Still to open it and review…


#6

What I would like to have as end result is something like this:


      FEZ_Components.DallasSensors ds = new DallasSensors(Cpu.Pin.GPIO_Pin10);
      var sensors = ds.queryAll();
      foreach (var sensor in sensors)
      {
        Debug.Print(sensor.address);  // xx-xx-xx-xx-xx
        Debug.Print(sensor.model);    // DS1920
        Debug.Print(sensor.altModel); // DS18B20
        Debug.Print(sensor.Type);     // Temperature / Humidity / Light / Volt / Current
        Debug.Print(sensor.Value);    // the value based on Type
      }


#7

Brett,

did you got anywhere with the onewire sensors ?

Eric


#8

Hi Eric,
no didn’t spend any time on this past what I did 2 months ago. ping me offline on hotmail - brett_pound at… and I’ll ship you the (untested) code I did put together


#9

I actually just finished coding a DS18B20 library that includes an DS18B20 class and a DS18B20List class to do this. I just have to decide how I want to share it. I’m not sure what the exact etiquette is for posting to the wiki since there is an existing DS18B20 class listed there.

My code basically exposes all of the basic functions for the DS18B20 and allows you to modify the alarm registers and resolution configuration register. The DS18B20List is able to search for all devices on the onewire network (ignoring devices that aren’t DS18B20) and directly issue bulk commands (like using skip ROM to initiate a conversion on all devices). It inherits (currently) from an ArrayList.

I don’t know if this is what you were thinking of, but I’m certainly interested in sharing what I have.


#10

HVACengi,

would you be willing to sent your code to eric.vdb at gmail ?
I have also DS18S20 and DS2438 sensors.

Eric


#11

Sure thing, as soon as I get home from work I’ll zip and send it.


#12

Great, thanks


#13

same here, i’d appreciate a look at your code too. sounds exactly like what I am trying to achieve (although I personally was going to avoid sending broadcast start conversion commands, I wanted to iterate through my list and direct them individually).

I have mine in a draft email to send to you Eric, but I’ve not had time to explain where it’s at fully - I’ll include you too HVAC guy if you ping me (email listed above).


#14

Message sent to both of you. Sorry it took me a while, I forgot about some plans that I had for the evening, and then I had to find all of the executable files and remove them before gmail would send the file.

Brett:
You should be able to iterate through my implementation just fine since it acts like a list. I have removed the inheritance from array list, however, due to frustrations with casting from a non-typed list (it’s amazing how much I rely on typed lists in my full framework programming). Technically it currently is closer to implementing IList, but true implementation would require me to work with plain objects more often than I liked.


#15

HVACengi,
can you please email me your code for handling multiple DS18B20 devices on 1-wire network?
My email is victor at borescopeit dot com

Greatly appreciate your help!


#16

HVACengi,
I’m working on code to handle multiple DS18B20 devices on a 1-wire network.
I’ve read you already invented the wheel.
Can you roll it over, please? :wink: :wink:
email is: wim dot cranen at wccandm dot nl
Thanks, appreciate it.

Cu Wim.


#17

The right way is ot post here so anyone can benefit :slight_smile: code.tinyclr.com


#18

Good, better, best.


#19

I have working code for multiple DS18B20, DS18S20 and DS2438 sensors on a OneWire bus working.
The only part I’m struggling with is the temperature conversion. Once I cleaned up the code I will post it here. In the meanwhile, if someone is willing to help (WimC maybe) feel free to do so.

Greetings


#20

EriSan:


byte tempLow = oneWire.ReadByte();
byte tempHigh = oneWire.ReadByte();
float temperature = ((tempHigh << 8 ) + tempLow) / 2.0f;

Should give you the temperature for DS18.20 devices.