Latest SDK 4.2 - Onewire Fails

Hi, Iam testing the new Onewire class 4.2, but it doesn’t work.

public static void Main()
        {
            OutputPort port = new OutputPort(EMX.Pin.IO27, false);
            OneWire onewire = new OneWire(port);

            ArrayList list = onewire.FindAllDevices();

            Debug.Print("Count: " + list.Count);

            foreach (string s in list)
            {
                Debug.Print(s);
            }

            System.Threading.Thread.Sleep(int.MaxValue);
        }

Thats my demo code, but all the time I get 0 devices found. But there are still 2 connected.

As you can see, the data pin is on IO27, is there any requirement on the pin?

With my multimeter I have seen, that the data pin is high when its idle.

Iam using DS18S20 sensors.

Hope someone give me a feedback why this code doesn’t work.

Best regards

Do you have a GHI Premium device? If so, can you go back to 4.1 and prove that works without changing the one-wire device setup/connections?

Yes Iam using EMX, but is it possible to install the GHI 4.1 Sdk side by side with the 4.2?

I while a go I have tested it with 4.1 and it works perfect, now I wanted to port the code, but it can’t find any sensor. After that I started with the demo, to see if in the code is any error.

So I have downgraded to 4.1 and with the old ghi library it works perfect. No modification to the hardware or wiring.

Nobody has an idea?

GHI would have to confirm…

??

Original post was 4 hours ago. We need time to test and confirm :slight_smile: At least couple days.

Yeah a few hours is a little quick to expect verification.

The reason I asked you to test 4.1 was so we could quickly eliminate something you’re doing at a hardware level. You’ve helped eliminate a variable and now GHI can do more tests.

Any progress on the ghi side?

@ Gus

Is there any progress on the onewire bug?

Sorry this took longer than expected. This si what we are working on now as we speak.

So one week later, any progress? When can we expact a fix?

We are working on it still. It is actually what is holding the whole SDK release.

so still a week later, any progress? is there a release date?

finally fixed. This was a very simple bug but very difficult to fix! The coming SDK will have the fix. Should be this week.

1 Like

@ Gus - Was this a bug specific to certain hardware or did this impact Cerb-Family as well?

@ Valkyrie-MT - It was only specific to EMX, however have you noticed a problem with One Wire on the Cerb-Family?

So finaly onewire is working … not really well, so I have to complain.

It seems that the onewire do not work realiable. May its my mistake but the msdn doc istn really helpfull.

I have two demo programs one with 4.1 and one with the final 4.2, both are searching for all devices on the onewire-bus.

I get following output with the same hardware:

4.1 output

4.2 output

4.1 Code

using System;
using Microsoft.SPOT;
using GHIElectronics.NETMF.Hardware;

namespace onewire4_1
{
    public class Program
    {
        public static void Main()
        {
            OneWire wire = new OneWire(EMX.Pin.IO27);
            int count = 0;

            while (true)
            {
                Debug.Print("=======================================");
                Debug.Print("Reset: " + wire.Reset());
                wire.Search_Restart();

                byte[] temp = new byte[8];

                while (wire.Search_GetNextDevice(temp))
                {
                    Debug.Print(ConvertToLong(temp).ToString());
                    count++;
                }

                Debug.Print("Count: " + count);

                count = 0;
                System.Threading.Thread.Sleep(2000);
            }
        }
        public static ulong ConvertToLong(byte[] input)
        {
            return (ulong)input[0] | (ulong)input[1] << 8 | (ulong)input[2] << 16 | (ulong)input[3] << 24 | (ulong)input[4] << 32 | (ulong)input[5] << 40 | (ulong)input[6] << 48 | (ulong)input[7] << 56;
        }
    }
}

4.2 code

using System.Collections;
using GHI.Premium.Hardware;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;

namespace onewire
{
    public class Program
    {
        public static void Main()
        {
            OutputPort port = new OutputPort(EMX.Pin.IO27, false);
            OneWire onewire = new OneWire(port);
            ArrayList list = new ArrayList();
            
            while (true)
            {
                Debug.Print("=======================================");
                Debug.Print("TouchReset: " + onewire.TouchReset());

                list = onewire.FindAllDevices();

                foreach (byte[] s in list)
                {
                    Debug.Print(ConvertToLong(s).ToString());
                }

                Debug.Print("Count: " + list.Count);
                list.Clear();

                System.Threading.Thread.Sleep(2000);
            }
        }

        public static ulong ConvertToLong(byte[] input)
        {
            return (ulong)input[0] | (ulong)input[1] << 8 | (ulong)input[2] << 16 | (ulong)input[3] << 24 | (ulong)input[4] << 32 | (ulong)input[5] << 40 | (ulong)input[6] << 48 | (ulong)input[7] << 56;
        }

    }
}

Hopefully someone can help me.

So you have 11 devices on your one wire bus, correct?
4.1 works fine but 4.2 do not detect any or detects 2?
What devices you have tested this on?
What sensor are you using?
Are the devices powered from power or from the data bus?
What value are you using for master pull up resistor?