Git Product home page Git Product logo

onewire's People

Contributors

noismaster avatar rinsen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

onewire's Issues

Stopwatch is never started in DS2482_100

In WaitForOneWireReady(), a new Stopwatch() is created, but never started. As a result, the if-test (stopWatch.ElapsedMilliseconds > 5000) will never evaluate to true:

var stopWatch = new Stopwatch();
do
{
if (stopWatch.ElapsedMilliseconds > 5000)
{
throw new InvalidOperationException("One Wire bus busy for too long");
}
_i2cDevice.WriteRead(new byte[] { FunctionCommand.SET_READ_POINTER, RegisterSelection.STATUS }, status);
} while (status[0].GetBit(StatusBit.OneWireBusy));

This can easily be fixed by changing line 329 to var stopWatch = Stopwatch.StartNew();

The same issue can be found in this piece of code in ReadStatus(bool setReadPointerToStatus = false):

var stopWatch = new Stopwatch();
do
{
if (stopWatch.ElapsedMilliseconds > 1)
{
throw new InvalidOperationException("One Wire bus busy for too long");
}
_i2cDevice.Read(statusBuffer);
} while (statusBuffer[0].GetBit(StatusBit.OneWireBusy));

Also, is the 1 millisecond time-out here not way too short? Or is there a specific reason for this?

Regards

Slave address was not acknowledged

Hi,

thank you for your code, but I had no success with it. I used an schematic like http://www.raspi.cz/wp-content/uploads/2012/11/ds2482-1_bb.jpg and I get this exception in the catch-block in your sample code in LogTemperatures(ThreadPoolTimer timer):

{System.IO.FileNotFoundException: The system cannot find the file specified.

Slave address was not acknowledged.
at Windows.Devices.I2c.I2cDevice.Write(Byte[] buffer)
at Rinsen.IoT.OneWire.DS2482_100.OneWireReset()
at Rinsen.IoT.OneWire.OneWireDeviceHandler.GetConnectedOneWireDevices()
at Rinsen.IoT.OneWire.OneWireDeviceHandler.get_OneWireDevices()
at Rinsen.IoT.OneWire.OneWireDeviceHandler.GetDevicesT
at OneWire.StartupTask.LogTemperatures()}

Maybe you have an idea?

Wiring for DS18B20

For the DS18B20 thermistor do you just need to connect it to any one of the GPIO ports?

Thanks

Announcement: New version released

I have released a new version with a lot of new features but also some breaking changes.

See the sample app and documentation for more details.

Add I2cDevice to OneWireDeviceHandler ctor

Firstly, thanks for a great project. Just started using it but going well so far.

I need a OneWireDeviceHandler ctor with a I2cDevice instead of the AD0/AD1 parameters. Long story but basically I am auto discovering what is connected to my I2C bus and instead of creating a device to detect the DS2482 and then disposing of it and then letting OneWireDeviceHandler create it again, adding a new ctor is more efficient. Below is what I added to line 60 of OneWireDeviceHandler.cs for your consideration in one of the next builds.

    /// <summary>
    /// One wire device handler via DS2482-100
    /// </summary>
    /// <param name="i2cDevice">Opened I2cDevice</param>
    /// <exception cref="Rinsen.IoT.OneWire.DS2482100DeviceNotFoundException">Thrown if no DS2482-100 device is detected</exception>
    public OneWireDeviceHandler(Windows.Devices.I2c.I2cDevice i2cDevice)
    {
        _ds2482_100 = new DS2482_100(i2cDevice);

        try
        {
            _ds2482_100.OneWireReset();
        }
        catch (Exception e)
        {
            throw new DS2482100DeviceNotFoundException("No DS2482-100 detected, check that AD0 and AD1 is correct in ctor and that the physical connection to the DS2482-100 one wire bridge is correct.", e);
        }

        _oneWireDeviceTypes = new Dictionary<byte, Type>();

        AddDeviceType<DS18S20>(0x10);
        AddDeviceType<DS18B20>(0x28);
    }

Add Support For LightningProvider

Currently, this project only works with the standard (inbox) drivers. A minor tweak is required to add support for the lightning drivers.

Onewire DS2482100DeviceNotFoundException under linux (Azure IoT Edge)

I couldnt get the Onewire working for IoT Edge on Raspberry.
IoT Edge on Rasperry: this mean Linux on Raspberry and solution is running as a docker on it.
I2C is working and docker can see it. I have another I2C device connected and working which is using drivers from https://github.com/dotnet/iot.
I even tried disconnect another device from the I2C bus to leave just Onewire alone but still the same error message.
It was working under Windows IoT core.

Unhandled Exception: Rinsen.IoT.OneWire.DS2482100DeviceNotFoundException: No DS2482-100 detected, check that AD0 and AD1 is correct in ctor and that the physical connection to the DS2482-100 one wire bridge is correct. ---> System.IO.IOException: Error 121 performing I2C data transfer.
at System.Device.I2c.UnixI2cDevice.ReadWriteInterfaceTransfer(Byte* writeBuffer, Byte* readBuffer, Int32 writeBufferLength, Int32 readBufferLength)
at System.Device.I2c.UnixI2cDevice.Transfer(Byte* writeBuffer, Byte* readBuffer, Int32 writeBufferLength, Int32 readBufferLength)
at System.Device.I2c.UnixI2cDevice.Write(ReadOnlySpan 1 value)
at Rinsen.IoT.OneWire.DS2482Channel.OneWireReset()
at Rinsen.IoT.OneWire.DS2482DeviceFactory.PrivateCreateDs2482_100(I2cDevice i2cDevice, Boolean disposeI2cDevice)
--- End of inner exception stack trace ---
at Rinsen.IoT.OneWire.DS2482DeviceFactory.PrivateCreateDs2482_100(I2cDevice i2cDevice, Boolean disposeI2cDevice)
at HomeModule.Measuring.RinsenOneWireClient.ReadSensors() in /app/Measuring/RinsenOneWireClient.cs:line 25
at HomeModule.Schedulers.HomeTemperature.ReadTemperature() in /app/Schedulers/HomeTemperature.cs:line 41
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.b__7_1(Object state)
at System.Threading.QueueUserWorkItemCallbackDefaultContext.<>c.<.cctor>b__5_0(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.QueueUserWorkItemCallbackDefaultContext.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

Support for DS2760B

Hallo,

I'm trying to use your "simple library" to read my old OneWire temperature sensor.
Could you please help me out a little, I'm one of those people that need a little more examples in order to compensate the lack of knowledge... :-)

Please advice
Dann

Support DS2482-800

What is the level of effort to support the 800 version of the chip? I love the idea of a full C# version of DS1820B temperature monitors, but I do not want to be limited by 4 sensors.

Using with Raspberry Pi 3

I read through the closed question regarding wiring the DS18B20, but I think that refers to connecting to a Raspberry Pi prior to 3? I'm seeing a lot of articles on connecting the DS18B20 to the Raspberry Pi 3 GPIO04 pin, having the 3.3 wire connected to the data wire with a 4.7KOhm resistor. Unfortunately all the code samples is written in languages other than C#. The project I'm working on is built on a Raspberry Pi 3 running Windows 10 IoT Core.

This is more of a question than an issue with your project. First, in the closed question you mention the Raspberry Pi isn't equipped with a OneWire pin (I think that's how you described it), but are you referring to Pi's older than the Raspberry Pi 3? Second, if OneWire is truly capable on Raspberry Pi 3, does that mean the i2c 1-wire Owf expansion is obsolete on the Raspberry Pi 3? Third, assuming both questions are "Yes", will your OneWire library work with projects connected to a Raspberry Pi 3 with a DS18B20 sensor?

Thank you for your time!

Negative temp conversions is wrong

TEMPERATURE (°C) DIGITAL OUTPUT(BINARY, MSB, LSB) DIGITAL OUTPUT (HEX)
+125 0000 0111 1101 0000 07D0h
+85* 0000 0101 0101 0000 0550h
+25.0625 0000 0001 1001 0001 0191h
+10.125 0000 0000 1010 0010 00A2h
+0.5 0000 0000 0000 1000 0008h
0 0000 0000 0000 0000 0000h
-0.5 1111 1111 1111 1000 FFF8h
-10.125 1111 1111 0101 1110 FF5Eh
-25.0625 1111 1110 0110 1111 FE6Fh
-55 1111 1100 1001 0000 FC90h

This is how it should work, and it doesn't.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.