I2c communication issue between teensy 4.1 master and slave

Status
Not open for further replies.

khoadley

Member
Greetings,

I am new to I2C communication but am trying to use a teensy 4.1 as a master device. The teensy would then communicate with another teensy 4.1 which would function as the slave device. They are both connected via pins 16 and 17. I have downloaded the Teensy4 I2C library from Richard Gemmell's github account. At this point I am simply trying to get his example codes to work (wire/master_reader uploaded to the master teensy4.1; and wire/slave_sender uploaded to the slave teensy4.1). Unfortunately, I am having no luck establishing any communication.

In other devices, it looks like the SDA and SCL are connected to a Vcc through a resistor? I have not done this as I am getting conflicting information as to whether or not this is required on the teensy. Could this be my issue? Links to the example code are below. Thanks in advance for your help!

https://github.com/Richard-Gemmell/...r/examples/wire/slave_sender/slave_sender.ino
https://github.com/Richard-Gemmell/...examples/wire/master_reader/master_reader.ino

Kind Regards,

Kenneth D. Hoadley
 
> They are both connected via pins 16 and 17

Looks like the Master code expects 18 and 19. Or switch it to Wire1.
 
... someone double check - but not sure T_4.x i2c SLAVE mode yet been completed.

Might confirm MASTER function with that code if there is a T_3.x or T_LC handy to act as slave.
 
Thanks for the replies! jonr, I did try pins 18 and 19 on the master as well, but no luck. defroster, I will try on a teensy 3.6 or arduino UNO next. For either of these, do I need to apply a vcc to the I2C cables or can I simply connect them directly from device to device? To better illustrate what I mean, I have attached this illustration from howtomechatronics.com which shows a 5v power supply to both the SDA and SCL lines. Is this required in my setup as well?

How-I2C-Communication-Bus-Works.jpg
 
RE post #4::

All devices common to a T_4.1 should be at 3.3V for safety. And only ONE device needs to supply powered PullUps to the common SDA and SCL lines, and each device is individually powered but with common GND.

defroster - no problem :) - Paul did it the other day too. I didn't realize typing that would be such a chore - and that I'd post so much when I joined here and picked that defragster name which is easy for me to type.
 
... someone double check - but not sure T_4.x i2c SLAVE mode yet been completed.

Might confirm MASTER function with that code if there is a T_3.x or T_LC handy to act as slave.

Hi, I'm curious about this. Is it still uncertain if the Slaev functionality was completed?

I am trying to send data from a Teensy 4.1 as am I2C slave. Here is an image from a logic analyzer of what I am sending to it:

I2C_M4_logic.jpgI2C_M4_logic.jpg

And I am using the basic example (just modifying the slave address):

Code:
#include <Arduino.h>
#include <i2c_driver.h>
#include <i2c_driver_wire.h>

void requestEvent();

int led = LED_BUILTIN;

void setup()
{
  pinMode(led, OUTPUT);
  Wire.begin(0x22);
  Wire.onRequest(requestEvent); // register event
}

void loop()
{
  delay(100);
}

// function that executes whenever data is requested by master
// this function is registered as an event, see setup()
void requestEvent()
{
  digitalWrite(led, HIGH);      // briefly flash the LED
  Wire.write(0xFF);
  digitalWrite(led, LOW);
}

I am using pins 16 and 17 as a slave I2C in the teensy. It seems that requestEvent() never kicks in though.

Thanks!
 
Status
Not open for further replies.
Back
Top