i2c_scanner can't see 9250 chip on Teensy 4.0, works on Uno.

weensy

Active member
Hi,


I want to connect to a giro/mag MEMS device form Teensy 4.0 but it does not seem to work.


I have two examples of Chinese allegedly GY6500/9250 9 axis mems boards.


My Teensy code does not seem to find them so I ran the standard i2c_scanner sketch from an Arduino Uno and it was fine. One device replies to 0x68 the other on 0x69. Both work when fed from either 5V or 3.3V rails.


Now I edited the scanner code to use the Teensy 4.0 pin-out, first on primary i2c (18,19) then on secondary (17,16). Both versions reported not finding anything on i2c.


I get the feeling I'm just being dumb and over looking the obvious.
Can you put me straight?


TIA




Code:
#include <Wire.h>

void setup() {
// teensy 4.0 pinout
//  Wire.setSDA(17);  //18: sda0, 17: sda1
//  Wire.setSCL(16);  //19: scl0, 16: scl1
  Wire.setSDA(18);  //18: sda0, 17: sda1
  Wire.setSCL(19);  //19: scl0, 16: scl1
  Wire.begin(); //
  Serial.begin(9600);
  while (!Serial); // Leonardo: wait for serial monitor
  Serial.println("\nI2C Scanner (Teensy 4.0)");
}
 
Now I edited the scanner code to use the Teensy 4.0 pin-out, first on primary i2c (18,19) then on secondary (17,16). Both versions reported not finding anything on i2c.

That's incorrect for Teensy 4.0. Those pins are Wire1 on Teensy 4.0.

On the older Teensy 3.x boards, those pins were alternates for Wire. Use of Wire.setSDA(18) and Wire.setSCL(19) only works on those older boards.

In Teensyduino 1.59 the Wire library Scanner example was improved to scan all Wire ports. Rather than fiddle with the old code, I'd recommend just updating to 1.59. If using the new Arduino IDE, you can use Boards Manager to install 1.59.0. Then just re-open the Scanner example and you'll see it's new code that scans all the Wire ports.
 
thanks, I was going from the official pinout, what did I get wrong?

I'm currently on v1.57

Update from IDE fails:
Code:
java.lang.RuntimeException: java.io.IOException: Archive format not supported.
    at cc.arduino.contributions.packages.ui.ContributionManagerUI.lambda$onInstallPressed$2(ContributionManagerUI.java:179)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: Archive format not supported.
    at cc.arduino.utils.ArchiveExtractor.extract(ArchiveExtractor.java:107)
    at cc.arduino.utils.ArchiveExtractor.extract(ArchiveExtractor.java:82)
    at cc.arduino.contributions.packages.ContributionInstaller.install(ContributionInstaller.java:141)
    at cc.arduino.contributions.packages.ui.ContributionManagerUI.lambda$onInstallPressed$2(ContributionManagerUI.java:172)
    ... 1 more

How about some error trapping before half installing something and borking the Teensyduino???
 
Last edited:
Cool. Now I no longer have a Teensy board at all.

Not the usual Teensy 3 and Teensy 4 entries in the port menu.
I do get get ACM0 port but if I try to upload to it, it disappears.

I can't believe the time I'm wasting on this just to get a basic connection.
 
For Arduino IDE 1.8.19 you must run the special installer. Boards Manager in Arduino IDE 1.8.19 is not enough for Teensy. This is the reason for a special installer. Download the installer here: (scroll down to "Arduino 1.8.x Software Development")


Arduino IDE 2.0.4 is the oldest version where Boards Manager can properly install Teensy.
 
Last edited:
How about some error trapping before half installing something and borking the Teensyduino???

This is a question for Arduino! They created Boards Manager. If you have not run PJRC's installer, we have way to influence this flawed install process.

The special PJRC installer exists because the old Arduino IDE versions have limited capability.
 
Yes the Arduino ide sucks.
I installed the new one and after it had tried to steal my proprietory code and export it some unknown "cloud" location without so much as a thank you , I had to cut the network. Looks like I'll have to run it in a sandbox or go back to the old junk.

I connected by "9250" to pins 16,17 ; built the standard "Scanner" sketch and downloaded it to the Teensy.

Code:
No I2C devices found

Scanning...
No I2C devices found

Scanning...
No I2C devices found

Scanning...
No I2C devices found

Scanning...
No I2C devices found

Scanning...
No I2C devices found

Back to where I was.

I'll try to follow your instructions to get the old IDE working with Teensy. I can't have this fickin spyware on this box :(

What pins should I connect and how to configure. I don't what you said was wrong last time according to your pinout image.
 
Last edited:
That's not the new Scanner from 1.59. :(

You can download Arduino 1.8.19 installer and Teensyduino 1.59 installer. Both are stand alone and work without any internet access. Fine to download both, then unplug from the internet.

Before running both installers, look in your hidden AppData folder (if using Windows) or Library folder if using MacOS or ~/.Arduino15 folder if Linux. Find the "packages/teensy" folder. Delete that folder and all its contents, so you're not working with a prior bad install.

You MUST use the Teensyduino installer to get a proper working Teensyduino setup in Arduino 1.8.19.
 
When you get a proper clean Arduino 1.8.19 and Teensyduino 1.59, you will see the Wire Scanner prints "Scanning Wire...", then "Scanning Wire1...", then "Scanning Wire2...".

If it prints only "Scanning...", you aren't using the 1.59 version.
 
OK, I reinstalled from your installer on my 1.59 IDE. Looks to returned to sanity.


Code:
Scanning Wire...
No I2C devices found

Scanning Wire1...
Device found at address 0x69  (MPU6050,MPU9050,MPU9250,ITG3701,L3G4200D)
done

Scanning Wire2...
No I2C devices found

Thanks for the support, that's got me moving at least.

Can you explain what the other ports Wire[0] and Wire2 are connected to. I still do not see anything on pins 18,19. :?
 
Last edited:
The pin connections are documented on the pinout reference card. It should have come with your Teensy.

You can also view it and download PDF on the Teensy 4.0 product page.


This link should take you direct to the "Pins" section. But if your browser loads from the top, scroll down to "Pins" to see the docs.
 
That seems to be the what I have already posted here twice myself.

It shows SDA0=18, SCL0=19 . That is where I started and you told me it was wrong .
 
It shows SDA0=18, SCL0=19 . That is where I started and you told me it was wrong .

You connected the wires to pins 16 and 17. On Teensy 4.0, those are accessed with Wire1. Hopefully that's apparent from the Scanner example?

If you were using Teensy 3.x, then Wire.setSDA(17) and Wire.setSCL(16) would be appropriate. If you wish to dig deeper, look at the pinout reference cards for those boards those boards and compare to the pinout card for Teensy 4.0.
 
You connected the wires to pins 16 and 17. On Teensy 4.0, those are accessed with Wire1.
How is that different from the code I posted originally, where I showed 19: scl0, 16: scl1 ?

Code:
void setup() {
// teensy 4.0 pinout
//  Wire.setSDA(17);  //18: sda0, 17: sda1
//  Wire.setSCL(16);  //19: scl0, 16: scl1
  Wire.setSDA(18);  //18: sda0, 17: sda1
  Wire.setSCL(19);  //19: scl0, 16: scl1
  Wire.begin(); //
  Serial.begin(9600);
  while (!Serial); // Leonardo: wait for serial monitor
  Serial.println("\nI2C Scanner (Teensy 4.0)");
}

I wrote:
I edited the scanner code to use the Teensy 4.0 pin-out, first on primary i2c (18,19) then on secondary (17,16).

ie I tried both Wire and Wire1. Neither of those ports were working at that point.

Now it seems Wire1 works but Wire[0] is still not connecting under your new Scanner sketch.

To be clear, having got pins 16,17 working , unplugged the 9250 and connected it to 19,18 noting the connections are the other way numerically. This port is not connecting.

Am I misunderstanding something here?

[EDIT]

Use of Wire.setSDA(18) and Wire.setSCL(19) only works on those older boards.

Ah, so I can NEVER change the pin assigments on Teensy 4.x , that is what I was not understanding.

So it looks like pins 18,19 are borked on this board, since the new Scanner sketch never connects to them.
 
Last edited:
Back
Top