Teensy 4.0 Adafruit_BNO055 cant find i2c device

Status
Not open for further replies.

morgoth90

Member
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.
 
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.
 
In the documentation is specified that bno055's sda and and scl already have a 20k pullup (https://learn.adafruit.com/adafruit-bno055-absolute-orientation-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.
 
I tested it here with the Wire library scanner example. Here's what I see in the serial monitor.

sc.png

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.

DSC_0582_web.jpg
 
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.
 
@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);  [COLOR="#FF0000"]//Reading is 0xFF[/COLOR]
  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),
 
@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.
 
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.
 
Not a problem Paul - just frustrating since I know it did work on the T4. Had to check before I crashed for the night.
 
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:
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?)
 
Yes, I did that once during the test.
I ordered a new Teensy 4.0 :p

By the way, on other pins and commenting the line
Code:
//write8(BNO055_SYS_TRIGGER_ADDR, 0x20);
works for me too
 
@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.
 
Status
Not open for further replies.
Back
Top