Just Getting Started with Teensy, looking for background docs

RonGee

New member
Hi,

I am new to Teensy, and I'd like to get a better understanding of the hardware. Is there any documentation the describes all of the pins on a Teensy 4.1 and what they are used for? Or, are there multiple sources from which something like that could be put together? I have the diagram, of course, but beyond a few of the fairly obvious pin IDs, I'm unclear about what the rest are. I'm happy to do the legwork, but unsure about where to start. I've been able to, for example, attach a magnetometer to the Teensy, provide power to it, and read from it using the SDA and SCL pins using a small program to do so, but beyond those few, it's kind of a mystery.

Thanks for any guidance that you can provide.

Ron
 
The pinout reference card that comes with Teensy 4.1 tries to give a quick overview of the pins & their capabilities. If you don't have the physical printed card yet, you can see it here:

https://www.pjrc.com/store/teensy41.html#pins

The card has limited space. Kurt made this more detailed version should all the less-used options on every pin.

https://forum.pjrc.com/threads/6614...-use-third-SPI?p=268934&viewfull=1#post268934

Of course that doesn't describe what those pins really do, in terms of features, only just a short label for each function, because also limited space!

The Teensy 4.1 product has many sections with many lists which try to give a quick summary of the many features and hardware capabilities and a little info about some of the software involved. Those descriptions have many links to places where you can find more detailed info, since even just a quick summary of each feature adds up to a huge page for a board like Teensy 4.1 loaded with so many features.

There is also a huge reference manual for the chip. You can find the PDF in the tech info section at the end of the product page. There are also documents for the processor. This type of reference material is thousands of pages of dense technical detail.

As for where to start, if you explain what you'd like to accomplish, we could probably give you some advise about how to get going. Usually it's best to focus on learning a relatively small part of the whole and expand your reach as needed. This sort of hardware is so loaded with features and some very advanced hardware that trying to learn about everyone all at once can be pretty overwhelming.
 
Hi Paul,

That is amazingly helpful. Thanks for that. As to the project I'm fooling around with right now, sure, let me explain a bit.....

We're trying to create an array of magnetometers, or at least, see if it can even be done.

The specific magnetometer we're using right now is the MLX90393 from Adafruit. It apparently has 2 addressing pins that can be used to create up to 4 unique addresses *(by shorting out the pins in the right combination). I haven't figured out how that works yet in the software, or if there's way to use more than 4 in some way.

So far, I've gotten 1 magnetometer to work using an Adafruit Feather, using the power pins and the SDA and SCL pins to get the data, using some modified sample software.

I then took that same magnetometer and connected it to a Teensy 4.1, using the same pins, and migrating over the software, which all worked fine.

Now, I'm trying to extend that to more than one magnetometer. I thought that by understanding more about the Teensy 4.1, I might discover the best ways to do that if there is more than one way, or if I should use a different magnetometer, or whatever. I can't say that we've got a particular practical application in mind; right now we're mostly interested in seeing if we can get it to work.

I hope that helps. In the bigger picture, tho, I'd like to understand more about the Teensy, and what you've provided so far gives me a great path to wander down.

Thanks.

Ron
 
With one working that is a great start!

The product page links to learn.adafruit.com/mlx90393-wide-range-3-axis-magnetometer?view=all
Code:
 if (! sensor.begin_I2C()) {          // hardware I2C mode, can pass in address & alt Wire

That doesn't show the 'Primary' address - it just seems to use the 'default' without specifying, and the added notes don't explain what it will be when A0, or A1, or both are soldered closed.

Using the Wire i2c Scanner example with the device connected the address as found will be displayed. The same if three more were attached with A0, A1, or both A0 and A1 closed uniquely on each.

Then those addresses could be provided to the .begin_I2C() indicated above.

That also suggests that an 'alt Wire' i2c bus can be specified, so additional units (up to 12 total) could be other i2c pins the T_4.1 provides.
Wire pins: 18&19
Wire1 pins 17&16
Wire2 pins: 25&24

An example of that use is not shown on the above 'learn' page, perhaps the device library provides examples that give more details, or looking at the function prototypes in the library header.

The 'library' is not installed here, but that .h header file probably has the 'default' address shown to provide when one is not passed in.

Given the addresses in use found with the Wire Scanner example it should be something like:
sensor.begin_I2C( 'Address' )
sensor1.begin_I2C( 'Address'+1 )
and perhaps:
sensor.begin_I2C( 'Address' , &Wire1 )
sensor1.begin_I2C( 'Address'+1, &Wire1)
 
Last edited:
Clicking github from posted link:
#define MLX90393_DEFAULT_ADDR (0x0C) /* Can also be 0x18, depending on IC */

And here for passing Address and Alt Wire: github.com/adafruit/Adafruit_MLX90393_Library/blob/master/Adafruit_MLX90393.h#L174
Code:
  bool begin_I2C(uint8_t i2c_addr = MLX90393_DEFAULT_ADDR,
                 TwoWire *wire = &Wire);

Gives an idea of the expected address with A0 and A1 left open/unsoldered. And as indicated in p#6 passing of alternate Wire/i2c pin sets.
 
Your first step should probably be with the Scanner example. In Arduino, with Teensy selected from Tools > Boards (so the software updates its menus for Teensy) click File > Examples > Wire > Scanner.

Connect 2 sensors to the normal SDA & SCL (pins 18 & 19) and connect the A0 & A1 pins on each sensor to GND or 3.3V. The Scanner example will show you in the Arduino Serial Monitor which addresses are actually found. This is how you know you've correctly connected the A0 & A1 pins for each sensor to have a unique address. Looks like Adafruit's circuit board has little pads you just solder together.

Then to actually use them, follow the Adafruit examples which demonstrate use of 1 sensor. To expand, you create an instance for each, like this:

Code:
Adafruit_MLX90393 sensor1 = Adafruit_MLX90393();
Adafruit_MLX90393 sensor2 = Adafruit_MLX90393();
Adafruit_MLX90393 sensor3 = Adafruit_MLX90393();
Adafruit_MLX90393 sensor4 = Adafruit_MLX90393();
Adafruit_MLX90393 sensor5 = Adafruit_MLX90393();

This creates the ability to talk with 5 separate sensors. Maybe give them more interesting or distinctive names than just sensor1, sensor2, etc. If each one as a particular purpose, distinctive names can make your code much easier to read and troubleshoot later.

Then inside setup(), you will use the begin_I2C() function for each sensor. This is where you tell each Adafruit_MLX90393 library instance which address and which physical I2C port on Teensy to use for communication.

Code:
sensor1.begin(0x0C, &Wire);
sensor2.begin(0x0C, &Wire1);
sensor3.begin(0x0E, &Wire1);
sensor4.begin(0x0C, &Wire2);
sensor5.begin(0x0F, &Wire2);

To use each sensor, just copy the example code for each instance you created. Because each had different begin_I2C() parameters, as you use each instance it will communicate with each specific sensor.

If you get stuck or the hardware seems to be not connected, remember to use the Wire library Scanner example for troubleshooting.
 
Back
Top