FANTASTIC! The One-Wire code in the firmware appears solid to me. I haven't seen any issues with it. Although, I really wanted to see a much simpler and object oriented way of working with 1 wire, so I wrote a wrapper class (called OneWireNetwork) out of CW2's sample. I only tested it with my DS18B20 sensors, but I have more coming soon and hopefully will add classes for them. So, what I did was create a collection class of devices that has a "Discover" method to scan the One-Wire network for devices. I hope this can be the start of a One-Wire framework that will make this the easiest One-Wire platform available. I have attached the code to this post. It is a complete replacement for CW2's OneWireTestApp project from the first post. Also, this example works with 1, 2, 3, or more devices, using parasite power or not.
By using the library, the code gets very simple:
public static void Main()
// TODO: Change pin according to the actual wiring
var deviceNetwork = new OneWireNetwork(Pins.GPIO_PIN_D0);
// Interrogate the devices on the network (adding them to the collection)
// Loop through all the discovered devices
foreach (var aDevice in deviceNetwork)
Debug.Print("Address: " + aDevice.Address);
if (aDevice is DS18B20)
Debug.Print("Temp: " + (aDevice as DS18B20).Temperature);
1-Wire device present
Multiple devices present
The program ' Micro Framework application: Managed' has exited with code 0 (0x0).
Things still to add:
Support for reading and writing to the device memory
Throw Events for device alerts
Robust exception handling
Throw Events for devices being added or removed
Support for a variety of One-Wire devices
Automatic instantiation of classes based on detected device family (should probably use some Reflection here)
I think CW2's firmware should get included into the next Beta. Let's get more people trying to use it...
*** Thanks again to CW2 ***