Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is no I2C devices found when running from headed app #2

Closed
Rinsen opened this issue Aug 3, 2015 · 12 comments
Closed

There is no I2C devices found when running from headed app #2

Rinsen opened this issue Aug 3, 2015 · 12 comments
Labels

Comments

@Rinsen
Copy link
Owner

Rinsen commented Aug 3, 2015

For details #1

@Rinsen Rinsen added the bug label Aug 3, 2015
@avaranovich
Copy link

I am having a similar issue:

Exception thrown: 'System.IO.FileNotFoundException' in Rinsen.IoT.OneWire.dll
WinRT information: Slave address was not acknowledged.

Even though this line succeeds

 _ds2482_100 = new DS2482_100(new I2cDeviceLocator().GetI2cDevice(address).Result);

so it finds the controller, but fails to communicate with the sensor.

fails on this line

_i2cDevice.Write(new byte[] { FunctionCommand.ONEWIRE_RESET });

The connection is pretty straitforward

@Rinsen
Copy link
Owner Author

Rinsen commented Aug 26, 2015

Where do you have the DS2482-100 I2C to OneWire bridge in that connection?

It is required for this library to work as there is no hardware OneWire support in the Raspberry Pi.

I use this one, http://www.modmypi.com/raspberry-pi/breakout-boards/owfs-1-wire/r-pi-i2c-1-wire-owfs-expansion-module-

@avaranovich
Copy link

I overlooked that. Thought the library does something like https://learn.adafruit.com/adafruits-raspberry-pi-lesson-11-ds18b20-temperature-sensing/ds18b20 So to make it work on Windows IoT I need a bridge you referes to.

@Rinsen
Copy link
Owner Author

Rinsen commented Aug 26, 2015

For, at least, this code to work you need a bride like the one I linked there unfortunately.

One way to do it if you don´t want to buy a bridge like that is to use a Arduino as a bridge instead but my code here will not help you with that.

@fabianandres
Copy link

I tried to connect a DS18B20 sensor with my r-pi3. I'm using the same i2c-1-wire expansion module from modmypi.com.
But it doesn't work as expected.
It gets some data only one time. If I stopp application and start it again, programm fails at position:
_ds2482_100 = new DS2482_100(new I2cDeviceLocator().GetI2cDevice(address).Result);
I never get a response from this line of code.

Sensor is connected like this:
5v to red cable (vcc)
black one to power gnd
blue one to DQ

My questions: is the wiring correct?
What can cause this issue?

Thank you for any hint.

@Rinsen
Copy link
Owner Author

Rinsen commented Oct 10, 2016

Hi @fabianandres!

Have you made sure that you are disposing the OneWireDeviceHandler in a using block? Or reuse the same instance over and over again. The I2C bus that is used to communicate with DS2482-100 is a very limited resource that needs to be disposed every time if you let go of the instance.

using(var oneWireDeviceHandler = new OneWireDeviceHandler())
{
    foreach (var device in oneWireDeviceHandler.GetDevices<DS18B20>())
    {
        var result = device.GetTemperature();
        // Insert code to log result in some way
    }
}

I have been running a device for months without any issues.

@fabianandres
Copy link

Hi,

Thank you for your fast response.

Yes, I enclosed OneWireDeviceHandler in a using block.

Tried also to reuse same instance. This works until I restart application.

I tried to dispose instance after every reading.

if (this.oneWireDeviceHandler == null)

           {

               this.oneWireDeviceHandler = new OneWireDeviceHandler(true, true);

           }

           foreach (var device in oneWireDeviceHandler.OneWireDevices.GetDevices<DS18B20>())

           {

               var result = device.GetTemperature();

               this.tempData.Temperature = result;

               // Insert code to log result in some way

               device.DS2482_100.Dispose();

           }

           this.oneWireDeviceHandler.Dispose();

           this.oneWireDeviceHandler = null;

But the same result here.

After restarting application, it fails on this line: new OneWireDeviceHandler(true, true);

Do you any other idea, whats wrong?

Thank you,

Fabian

Von: Fredrik Rinsén [mailto:notifications@github.com]
Gesendet: Montag, 10. Oktober 2016 22:25
An: Rinsen/OneWire OneWire@noreply.github.com
Cc: fabianandres fabian.andres@morija.net; Comment comment@noreply.github.com
Betreff: Re: [Rinsen/OneWire] There is no I2C devices found when running from headed app (#2)

Hi!

Have you made sure that you are disposing the OneWireDeviceHandler in a using block? Or reuse the same instance over and over again. The I2C bus that is used to communicate with DS2482-100 is a very limited resource that needs to be disposed every time if you let go of the instance.

using(var oneWireDeviceHandler = new OneWireDeviceHandler())
{
foreach (var device in oneWireDeviceHandler.GetDevices())
{
var result = device.GetTemperature();
// Insert code to log result in some way
}
}

I have been running a device for months without any issues.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub #2 (comment) , or mute the thread https://github.com/notifications/unsubscribe-auth/ACVXoAqcR9DQgOw6HM7_6AzpmtDRJS9Gks5qyp8GgaJpZM4Fkmv2 . https://github.com/notifications/beacon/ACVXoB3dKsNZu0tjFc8GR2Iwk-F-MrOtks5qyp8GgaJpZM4Fkmv2.gif

@Rinsen
Copy link
Owner Author

Rinsen commented Oct 12, 2016

Could you create a as small as possible repro project in a github repository that I can try with the same problem?

It probably has to do with the project type in some way I think, but it´s strange... And I would like to investigate and try to fix this issue :)

@fabianandres
Copy link

Hello,

I created a repository at https://github.com/fabianandres/BrewSentinel

Thank you for your help!

Von: Fredrik Rinsén [mailto:notifications@github.com]
Gesendet: Mittwoch, 12. Oktober 2016 21:30
An: Rinsen/OneWire OneWire@noreply.github.com
Cc: fabianandres fabian.andres@morija.net; Mention mention@noreply.github.com
Betreff: Re: [Rinsen/OneWire] There is no I2C devices found when running from headed app (#2)

Could you create a as small as possible repro project in a github repository that I can try with the same problem?

It probably has to do with the project type in some way I think, but it´s strange... And I would like to investigate and try to fix this issue :)


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub #2 (comment) , or mute the thread https://github.com/notifications/unsubscribe-auth/ACVXoO8zrkf6rIF8M5pT1__ZaGMByM5zks5qzTVIgaJpZM4Fkmv2 . https://github.com/notifications/beacon/ACVXoMlnGuubJUvnZT6Qp1rLAmns0zxYks5qzTVIgaJpZM4Fkmv2.gif

@Rinsen
Copy link
Owner Author

Rinsen commented Oct 26, 2016

I think I have found the issue here, I will try to implement it and release a new version with some sample code but I have a lot of other things going on so I cant promise when it will be done but within some days at least.

But the problem is related to how Task<> and IAsyncOperation<> is working in headed and headless apps. For some reason that I can´t understand they differ. The solution in headed apps is to run an IAsyncOperation<> with a method call to .AsTask() to get a "normal" Task<> and things start to work as they do in headless mode. while waiting for a Task<> to complete.

I will post here as soon as it is done so you can test it @fabianandres

@Rinsen
Copy link
Owner Author

Rinsen commented Oct 27, 2016

@fabianandres
I have made a commit today that contains a sample for headed applications and I also have made some changes in the Rinsen.IoT.OneWire project to handle async calls in a way that seems to work.

And in the Headed sample you will see that I never dispose the OneWireHandler as this is for some reason not supported with my current implementation in headed mode. But it still works as it should in headless and there you can dispose it and create a new one if you like to.

I have not updated my nuget package right now but will do some more tests before I do that.

I will also close down this issue when that package is out as the main issue is resolved.

@Rinsen
Copy link
Owner Author

Rinsen commented Nov 1, 2016

I have published a new version to nuget now and will close this issue

https://www.nuget.org/packages/Rinsen.OneWire/0.1.5

@Rinsen Rinsen closed this as completed Nov 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants