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

Thread: Teensy 4.0 Adafruit_BNO055 cant find i2c device

  1. #1
    Junior Member
    Join Date
    Aug 2019
    Posts
    11

    Teensy 4.0 Adafruit_BNO055 cant find i2c device

    I'm trying the Adafruit_BNO055 with the new Teensy 4.0 using the example sketch:
    Code:
    #include <Wire.h>
    #include <Adafruit_Sensor.h>
    #include <Adafruit_BNO055.h>
    #include <utility/imumaths.h>
      
    Adafruit_BNO055 bno = Adafruit_BNO055(55);
     
    void setup(void) 
    {
      Serial.begin(9600);
      Serial.println("Orientation Sensor Test"); Serial.println("");
      
      /* Initialise the sensor */
      if(!bno.begin())
      {
        /* There was a problem detecting the BNO055 ... check your connections */
        Serial.print("Ooops, no BNO055 detected ... Check your wiring or I2C ADDR!");
        while(1);
      }
      
      delay(1000);
        
      bno.setExtCrystalUse(true);
    }
     
    void loop(void) 
    {
      /* Get a new sensor event */ 
      sensors_event_t event; 
      bno.getEvent(&event);
      
      /* Display the floating point data */
      Serial.print("X: ");
      Serial.print(event.orientation.x, 4);
      Serial.print("\tY: ");
      Serial.print(event.orientation.y, 4);
      Serial.print("\tZ: ");
      Serial.print(event.orientation.z, 4);
      Serial.println("");
      
      delay(100);
    }
    After checking the connection:
    vin -> 3.3v
    gnd -> gnd
    sda -> pin18
    scl -> pin19

    I've tried the i2c_scanner sketch with no response:
    Scanning...
    No I2C devices found
    I'm missing something? Both the bno055 lib and the scanner are using Wire.h, is that correct?
    I've also tried i2c_t3 but from the compilation errors I think that teensy 4.0 isnt supported.

  2. #2
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,265
    Generally on Teensy's you need 2 pull-up resistors, one between SCL (pin 19/A5) and 3.3v, and the other between SDA (pin 18/A4) and 3.3v, unless one or more devices on the i2c bus already has pull-up resistors. The i2c scanner either hanging or not finding the devices is usually a sign that you need the resistors. For 3.3v devices like the Teensy, a typical value would be 2.2K ohms, but depending on the complexity of your i2c bus, you may need to adjust that. You can use higher values, such as the 4.7K that was typically used for 5v systems, but you may find that higher i2c speeds won't work.

  3. #3
    Junior Member
    Join Date
    Aug 2019
    Posts
    11
    In the documentation is specified that bno055's sda and and scl already have a 20k pullup (https://learn.adafruit.com/adafruit-...sensor/pinouts)

  4. #4
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,265
    Quote Originally Posted by morgoth90 View Post
    In the documentation is specified that bno055's sda and and scl already have a 20k pullup (https://learn.adafruit.com/adafruit-...sensor/pinouts)
    Well then I'm out of ideas, other than the general check your connections for connectivity. I've had breadboards where certain slots no longer would pass current and solder connections that came apart.

    Note, the Adafruit documentation says 10K per pin. It isn't additive, so it wouldn't be 20K. 10K is about as high as is recommended for i2c buses. And from what I've read, 10K will mean you might only be able to use the slowest i2c speed.

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,585
    I tested it here with the Wire library scanner example. Here's what I see in the serial monitor.

    Click image for larger version. 

Name:	sc.png 
Views:	21 
Size:	40.6 KB 
ID:	17310

    Here's how I connected the wires. Adafruit's board has the pullup resistors, so you don't need to add any. The ones Adafruit includes on their breakout board work fine.

    Click image for larger version. 

Name:	DSC_0582_web.jpg 
Views:	11 
Size:	146.9 KB 
ID:	17311

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,585
    However, there does seem to be some sort of software issue with Adafruit's library running on Teensy 4.0. It seems to crash or hang in begin(). I tested a Teensy 3.2 and it does indeed work on 3.2.

    I will look into the Adafruit_BNO055 library issue...

    But if you're getting nothing detected by the Wire library Scanner example, then something is wrong with your hardware. The Scanner example does work and does detect this board, as you can see in msg #5.

  7. #7
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,113
    @PaulStoffregen - @morgoth90

    Just hooked up my BNO055 sensor and ran I2CScanner and can confirm what you already documented. But, as you said, its getting stuck in begin() - specifically in this while loop:
    Code:
      delay(30);
      Serial.println(read8(BNO055_CHIP_ID_ADDR), HEX);  //Reading is 0xFF
      while (read8(BNO055_CHIP_ID_ADDR) != BNO055_ID) {
        delay(10);
      }
    This is really strange because early on in T4Beta testing I had tested the BNO055 and it was working - cant remember though if we had to add a delay(1) in Wire transfers - cant remember if that was for the BNO055 or another sensor.

    EDIT: NOPE the issue was with the MPL pressure sensor - see post 6:
    Code:
    issue reading MP3115 pressure sensor with Wire library, #2999, #3006, #3019 (workaround),

  8. #8
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,113
    @PaulStoffregen

    A little further debugging on bno055 begin. As a test, after some other debugging if i comment the reset command
    Code:
      //write8(BNO055_SYS_TRIGGER_ADDR, 0x20);
    it appears to work. This command has been in there for a long time so not sure why its not working anymore.

  9. #9
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,585
    Something is definitely not quite right with this. I've got it all wired up on my bench to the oscilloscope. Will dig into it tomorrow morning.

  10. #10
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,113
    Not a problem Paul - just frustrating since I know it did work on the T4. Had to check before I crashed for the night.

  11. #11
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,113
    Found this - not sure it applies or not or why it works on the T3.2 and not on the T4

    https://community.bosch-sensortec.co...sues/td-p/6192

  12. #12
    Junior Member
    Join Date
    Aug 2019
    Posts
    11
    If i move sda to pin 17, scl to pin16 and use Wire1 into the i2c scanner the board detect it:
    Scanning...
    I2C device found at address 0x28 !
    done
    its possible that pins 19 and 18 are broken or can be a software problem?

    EDIT:
    I've tried this
    Code:
    pinMode(18, OUTPUT);    
    digitalWrite(18, HIGH);
    pinMode(19, OUTPUT);    
    digitalWrite(19, HIGH);
    And measured the voltage on the pins:
    pin18: 1v
    pin19: 3.3v
    Last edited by morgoth90; 08-25-2019 at 08:54 AM.

  13. #13
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,200
    Quote Originally Posted by morgoth90 View Post
    And measured the voltage on the pins:
    pin18: 1v
    pin19: 3.3v
    not good. any chance you at one time had breakout board hooked to 5v? T4 is NOT 5v tolerant, and the onboard pullups could have damaged pin 18. I assume T4 and breakout have soldered connectors (attach a photo?)

  14. #14
    Junior Member
    Join Date
    Aug 2019
    Posts
    11
    Yes, I did that once during the test.
    I ordered a new Teensy 4.0

    By the way, on other pins and commenting the line
    Code:
    //write8(BNO055_SYS_TRIGGER_ADDR, 0x20);
    works for me too

  15. #15
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,113
    @morgoth90

    Commenting that line out was just for debugging purposes. Really need to determine why commenting it out seems to work when it works on the T3.2. More debugging is needed.

  16. #16
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,200
    Quote Originally Posted by mjs513 View Post
    @morgoth90

    Commenting that line out was just for debugging purposes. Really need to determine why commenting it out seems to work when it works on the T3.2. More debugging is needed.
    See discussions in https://forum.pjrc.com/threads/57543...dafruit-BNO055

  17. #17
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,585
    Teensyduino 1.48 has been released, with Kurt's fix for this problem.

    I retested the code from msg #1 just now with the Adafruit sensor. It seems to work fine.

Posting Permissions

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