Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: I2c requestFrom() Question

  1. #1

    I2c requestFrom() Question

    First post, I've used Teensy on other projects but not with i2c. I'm not sure what's going on here but it's probably pretty simple.

    Teensy 3.2 talking to a MAXREFDES117 pulse ox chip on eval board. It comes with stock code for the Uno and I've been attempting to convert it to the Teensy. Below is the output of the stock code I'm trying to emulate.
    Click image for larger version. 

Name:	Uno Stock.jpg 
Views:	34 
Size:	37.0 KB 
ID:	12841

    Here is the code I'm using:
    Code:
    #include <i2c_t3.h>
    
    void setup() {
      Wire.begin();
      Wire.setClock(25000);
    }
    
    void loop() {
    
      Wire.beginTransmission(0x57);
      Wire.write(0x00);
      Wire.endTransmission(false);          // start repeat
      
      Wire.requestFrom(0x57,1);
      //byte blah = Wire.read();
      Wire.endTransmission();
      
      delay(5000);
    }
    And here is the result:
    Click image for larger version. 

Name:	Teensy Output.jpg 
Views:	29 
Size:	34.0 KB 
ID:	12842

    My question is: Why are address 0x57 and data 0x00 written after the read attempt? Uncommenting Wire.read() changes nothing. Same issue with 100 kHz clock. Same issue with standard Wire library.

    Thanks in advance.

  2. #2
    I seem to have found a solution so I thought I'd include it here for others. I was under the impression that all i2c communications had to end with endTransmission(), but this is not the case. The code below produces the desired result, identical to the first image posted above.

    Code:
    #include "i2c_t3.h"
    
    void setup() {
      Wire.begin();
    }
    
    void loop() {
    
      Wire.beginTransmission(0x57);
      Wire.write(0x00);
      Wire.endTransmission(false);          // start repeat
      
      Wire.requestFrom(0x57,1);
      
      delay(5000);
    }

  3. #3
    Hello @MechanicalLumber

    I am also hoping to use the MAXREFDES117 to read heart rates.
    Did you by any chance Finnish your project and can share code on how to convert the data to BPMs?

    I guess ideally have their library handle most of it: https://github.com/MaximIntegratedRe...RD117_ARDUINO/

    Thanks.

  4. #4
    it looks like I am able to make this board:
    https://www.seeedstudio.com/MAXREFDE...OR-p-2762.html

    work with this library:
    https://github.com/sparkfun/MAX30105...ensor_Breakout

    The library is meant for MAX30105 but it seems to also work for the MAX30102 sensor.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •