Thanks Ytai, Im using Pin 25, & 26 on board, so can i use twiNum 0?
On Friday, March 21, 2014 9:09:39 PM UTC, Ytai wrote: > > One thing that pops immediately is that twiNum should be either 0, 1 or 2, > not 26. > Another thing is that the address probably doesn't need to be inside the > request buffer. > Yet another thing is that you probably want to only read back 2 bytes and > not 4. > > In the future, it would help a lot if you look at logcat before posting > your code - you should have an exception there with the current code. > > > On Fri, Mar 21, 2014 at 1:59 PM, Marius Vosylius > <[email protected]<javascript:> > > wrote: > >> I'm struggling to get my TWI reading out, Im not sure where Im going >> wrong? >> >> TMP102 DataSheet >> https://www.sparkfun.com/datasheets/Sensors/Temperature/tmp102.pdf >> >> Any help or example would me really appreciated. >> >> Main Class: >> >> // IOIO pin 26 = SDA, pin 25 = SCL >> >> private final int twiNum = 26; >> >> // TextView Display Temperature >> >> private TextView tmpTextView; >> >> private TwiMaster twi; >> >> int address; >> >> byte[] request = new byte[] { 0x00, 0x48}; >> >> byte[] response = new byte[4]; >> >> Setup: >> >> twi = ioio_.openTwiMaster(twiNum, TwiMaster.Rate.RATE_100KHz, false); >> >> Loop: >> >> address = 0x48; >> >> try { >> >> twi.writeRead(address, false, request, request.length, response, >> response.length); >> >> /* Update UI */ >> >> updateViews(); >> >> } catch (InterruptedException e) { >> >> ioio_.disconnect(); >> >> } catch (ConnectionLostException e) { >> >> throw e; >> >> } >> >> private void updateViews() { >> >> runOnUiThread(new Runnable() { >> >> @Override >> >> public void run() { >> >> tmpTextView.setText(String.valueOf(response)); >> >> } >> >> }); >> >> } >> >> -- >> You received this message because you are subscribed to the Google Groups >> "ioio-users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> To post to this group, send email to [email protected]<javascript:> >> . >> Visit this group at http://groups.google.com/group/ioio-users. >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "ioio-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/ioio-users. For more options, visit https://groups.google.com/d/optout.
