Coder Social home page Coder Social logo

Comments (9)

Thejayman77 avatar Thejayman77 commented on July 17, 2024

I too am having an issue working with I2C/Remote-Arduino. I'm using an HDC100x temp sensor, and can read the Device ID (0x1000) using the native Arduino Wire library commands. However, when using the I2C event/callback functionality, I receive no response except for 0s.

To verify, I am having the callback function called, but no data is received using the DataReader variable.

I'm not sure if I'm doing it correctly, but here's the code I'm using:

arduino.pinMode(20, PinMode.I2C);
arduino.pinMode(21, PinMode.I2C);
arduino.I2c.enable();
arduino.I2c.I2cReplyEvent += getData;

arduino.I2c.beginTransmission(0x40);
arduino.I2c.write(0xff);
arduino.I2c.endTransmission();
arduino.I2c.requestFrom(0x40, 2);
private void getData(byte myAdd, byte myReg, Windows.Storage.Streams.DataReader myRep)
        {
            var ignored = Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                textBox.Text = "Received: ";
                byte[] myVals = new byte[2];
                myRep.ReadBytes(myVals);
                foreach (byte i in myVals)
                {
                    textBox.Text += i;
                }
            });
        }

I've tried putting the data gathering inside and out of async functions without any change. I've also tried changing how the data is gotten from the myRep variable. I'm guessing I might be missing something fundamental, but maybe someone can offer some additional guidance.

from remote-wiring.

Thejayman77 avatar Thejayman77 commented on July 17, 2024

OK, got it working with the UNO. Perhaps I was having problems because I was trying to use the DUE and it's not quite fully supported? Not sure, but I still receive zeros on the Due, and the Uno is still a little finicky, though I can receive the correct response.

I had to issue two requestFrom statements, but also needed to request more bytes than I actually needed to read out the register from my device. For instance, when checking the ID, I only actually needed to request 2 bytes to verify reading was correct. Instead, I used a request for 18 bytes, twice. This allowed me to click a button, and get the correct response from the register that had the device ID. Without putting two identical requestFrom statements, I had to click the read button (That I programmed) multiple times before the correct response was obtained.

I went back and tried this with the Due, but it still only gave me zeros. I also tried on the SDA/SCL(1) pins on the Due, with no difference in outcome.

So, perhaps a timing issue, or maybe something else, but there's at least one way to get it to work (On the Uno). I think the Due Firmata might be problematic. Other functionality does work on the Due, but not the I2C from what I can see.

Hope this makes sense. Let me know if you still have problems.

from remote-wiring.

zfields avatar zfields commented on July 17, 2024

Ideally you would use remote-wiring to create a virtual instance of your Arduino and send the I2C transactions in the standard Arduino format.

from remote-wiring.

Thejayman77 avatar Thejayman77 commented on July 17, 2024

I wasn’t aware of an remote-wiring instance version of Wire.read. I believe it used to show up, but no longer does.

For example, if I have an instance of remote-wiring called ‘arduino’, I can’t make a call to arduino.I2c.read() as I would make a call to wire.read() in Arduino.

Is there something similar? Are you guys aware that the callback doesn’t specify the register upon reading it after a response? Or am I just doing something wrong?

I even tried using a firmata call (Using .getRegister()), but still don’t see anything in the reg variable except for 0.

From: Zachary J. Fields [mailto:[email protected]]
Sent: Tuesday, May 17, 2016 9:00 PM
To: ms-iot/remote-wiring [email protected]
Cc: Jason A. Hegedus [email protected]; Mention [email protected]
Subject: Re: [ms-iot/remote-wiring] How to use I2C functionality (#93)

Ideally you would use remote-wiring to create a virtual instance of your Arduino and send the I2C transactions in the standard Arduino format.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHubhttps://github.com//issues/93#issuecomment-219897607

from remote-wiring.

zfields avatar zfields commented on July 17, 2024

@turkycat wrote the i2c functionality, so he is the best to answer your question. I'm on vacation, but if we don't hear from him before I get back, then I'll try and work out an answer for you.

from remote-wiring.

mcinnes01 avatar mcinnes01 commented on July 17, 2024

Yes this is pretty much where I'm coming undone, the only details or examples I've seen reference methods that either no longer exist or are used in a different way. I did find some fairly helpful bit here: https://channel9.msdn.com/Events/Ignite/Australia-2015/MOB222 and here: https://github.com/mitchdenny/msftignite2015au-mob222.

from remote-wiring.

IoTGirl avatar IoTGirl commented on July 17, 2024

Hi Jesse,
Could you please take a look at this issue?
Sincerely,
IoTGirl

from remote-wiring.

lucora avatar lucora commented on July 17, 2024

I've solved in this mode (I don't know how) :

// in my case I used a buffer with 16 bytes array

   private async void ButtonI2CReceive_OnClick(object sender, RoutedEventArgs e)
    {
        arduino.I2c.enable();
        arduino.I2c.requestFrom(9, 16);
        await Task.Delay(10);
        arduino.I2c.requestFrom(9, 16);
    }

I receive only one event on trigger it.

from remote-wiring.

saraclay avatar saraclay commented on July 17, 2024

If this issue is still relevant, please file this at: https://github.com/MicrosoftDocs/windows-iotcore-docs

from remote-wiring.

Related Issues (20)

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.