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

Thread: Can I send data from Teensy with Audio Shield to Arduino?

  1. #1
    Junior Member
    Join Date
    Jan 2022
    Posts
    10

    Can I send data from Teensy with Audio Shield to Arduino?

    I have a Teensy board soldered to an audio shield. I tried connecting wires from pins 18 and 19 to the Arduino Uno pins A4 and A5. respectively. I then run the i2c_scanner code program on Arduino. The scan does not find the Teensy. Will this set up work or is there another means I need to use to communicate with Arduino?

  2. #2
    Senior Member
    Join Date
    Aug 2018
    Location
    Brisbane, Australia
    Posts
    115
    Do you have a common ground between the two boards?

  3. #3
    Junior Member
    Join Date
    Jan 2022
    Posts
    10
    Yes. The Arduino is providing VCC and Ground to the Teensy.

  4. #4
    Senior Member
    Join Date
    Jul 2014
    Posts
    3,438
    please follow the Forum rule
    Always post complete source code & details to reproduce any issue!

  5. #5
    Senior Member
    Join Date
    Apr 2014
    Location
    -
    Posts
    9,756
    Quote Originally Posted by Sheon Banks View Post
    I have a Teensy board soldered to an audio shield. I tried connecting wires from pins 18 and 19 to the Arduino Uno pins A4 and A5. respectively. I then run the i2c_scanner code program on Arduino. The scan does not find the Teensy. Will this set up work or is there another means I need to use to communicate with Arduino?
    That will not work. Teensy is a master. I2c supports only one master.

    Either configure the uno as client or just use Serial - which is much easier to handle anyway.
    Hopefully the Uno runs with 3.3 Volt - not 5V

  6. #6
    Senior Member
    Join Date
    Jul 2014
    Posts
    3,438
    Quote Originally Posted by Frank B View Post
    That will not work. Teensy is a master. I2c supports only one master.
    Could he not run a program on teensy that configures teensy as a slave?
    That's why my reference to the forum rule.

  7. #7
    Senior Member
    Join Date
    Apr 2014
    Location
    -
    Posts
    9,756
    What should it do with the audio shield then?
    But of course you can do everything. I think when someone asks this question in that case the next answer is the question How?.. so prepare to answer that esp how to init the shield from another slave.

    Have fun.

  8. #8
    Junior Member
    Join Date
    Jan 2022
    Posts
    10
    From the Arduino, I am running the out of the box i2c_scanner program.

    // --------------------------------------
    // i2c_scanner
    //
    // Version 1
    // This program (or code that looks like it)
    // can be found in many places.
    // For example on the Arduino.cc forum.
    // The original author is not known.
    // Version 2, Juni 2012, Using Arduino 1.0.1
    // Adapted to be as simple as possible by Arduino.cc user Krodal
    // Version 3, Feb 26 2013
    // V3 by louarnold
    // Version 4, March 3, 2013, Using Arduino 1.0.3
    // by Arduino.cc user Krodal.
    // Changes by louarnold removed.
    // Scanning addresses changed from 0...127 to 1...119,
    // according to the i2c scanner by Nick Gammon
    // http://www.gammon.com.au/forum/?id=10896
    // Version 5, March 28, 2013
    // As version 4, but address scans now to 127.
    // A sensor seems to use address 120.
    //
    //
    // This sketch tests the standard 7-bit addresses
    // Devices with higher bit address might not be seen properly.
    //

    #include <Wire.h>


    void setup()
    {
    Wire.begin();

    Serial.begin(9600);
    Serial.println("\nI2C Scanner");
    }


    void loop()
    {
    byte error, address;
    int nDevices;

    Serial.println("Scanning...");

    nDevices = 0;
    for(address = 1; address < 127; address++ )
    {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    Wire.beginTransmission(address);
    error = Wire.endTransmission();

    if (error == 0)
    {
    Serial.print("I2C device found at address 0x");
    if (address<16)
    Serial.print("0");
    Serial.print(address,HEX);
    Serial.println(" !");

    nDevices++;
    }
    else if (error==4)
    {
    Serial.print("Unknow error at address 0x");
    if (address<16)
    Serial.print("0");
    Serial.println(address,HEX);
    }
    }
    if (nDevices == 0)
    Serial.println("No I2C devices found\n");
    else
    Serial.println("done\n");

    delay(5000); // wait 5 seconds for next scan
    }

  9. #9
    Senior Member
    Join Date
    Jul 2014
    Posts
    3,438
    and on teensy?
    what's the output?
    (please use the CODE wrap)

  10. #10
    Junior Member
    Join Date
    Jan 2022
    Posts
    10
    The code is run on the Arduino.
    The output is "No I2C devices found"
    (I don't know what "CODE wrap" means)

  11. #11
    Senior Member BriComp's Avatar
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    705
    Code:
    // --------------------------------------
    // --------------------------------------
    // i2c_scanner
    //
    // Version 1
    // This program (or code that looks like it)
    // can be found in many places.
    // For example on the Arduino.cc forum.
    // The original author is not known.
    // Version 2, Juni 2012, Using Arduino 1.0.1
    // Adapted to be as simple as possible by Arduino.cc user Krodal
    // Version 3, Feb 26 2013
    // V3 by louarnold
    // Version 4, March 3, 2013, Using Arduino 1.0.3
    // by Arduino.cc user Krodal.
    // Changes by louarnold removed.
    // Scanning addresses changed from 0...127 to 1...119,
    // according to the i2c scanner by Nick Gammon
    // http://www.gammon.com.au/forum/?id=10896
    // Version 5, March 28, 2013
    // As version 4, but address scans now to 127.
    // A sensor seems to use address 120.
    //
    //
    // This sketch tests the standard 7-bit addresses
    // Devices with higher bit address might not be seen properly.
    //
    
    #include <Wire.h>
    
    
    void setup()
    {
    	Wire.begin();
    
    	Serial.begin(9600);
    	Serial.println("\nI2C Scanner");
    }
    
    
    void loop()
    {
    	byte error, address;
    	int nDevices;
    
    	Serial.println("Scanning...");
    
    	nDevices = 0;
    	for (address = 1; address < 127; address++)
    	{
    		// The i2c_scanner uses the return value of
    		// the Write.endTransmisstion to see if
    		// a device did acknowledge to the address.
    		Wire.beginTransmission(address);
    		error = Wire.endTransmission();
    
    		if (error == 0)
    		{
    			Serial.print("I2C device found at address 0x");
    			if (address < 16)
    				Serial.print("0");
    			Serial.print(address, HEX);
    			Serial.println(" !");
    
    			nDevices++;
    		}
    		else if (error == 4)
    		{
    			Serial.print("Unknow error at address 0x");
    			if (address < 16)
    				Serial.print("0");
    			Serial.println(address, HEX);
    		}
    	}
    	if (nDevices == 0)
    		Serial.println("No I2C devices found\n");
    	else
    		Serial.println("done\n");
    
    	delay(5000); // wait 5 seconds for next scan
    }
    Code Wrap makes included software look like above.
    To use press the # key when creating answer.
    Add this line to your setup
    Code:
    While (!Serial && Millis<=4000){}

  12. #12
    Senior Member
    Join Date
    Apr 2014
    Location
    -
    Posts
    9,756
    Regardless of the used scanner... they will never find other masters

  13. #13
    Junior Member
    Join Date
    Jan 2022
    Posts
    10
    When I uploaded the I2C_Scanner code to the teensy and connected it to the Arduino(SCL and SDA, since I am using Uno R3). It still does not work. No Connection found.
    Click image for larger version. 

Name:	20220115_081056.jpg 
Views:	10 
Size:	169.2 KB 
ID:	27222Click image for larger version. 

Name:	20220115_081143.jpg 
Views:	14 
Size:	112.0 KB 
ID:	27223

  14. #14
    Senior Member BriComp's Avatar
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    705
    Is the Uni a Master or Slave? I suspect the former.

  15. #15
    Junior Member
    Join Date
    Jan 2022
    Posts
    10
    I am not sure. I am running the code from the Teensy.

  16. #16
    Senior Member BriComp's Avatar
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    705
    Regardless of the used scanner... they will never find other masters
    See Frank's note above

  17. #17
    Junior Member
    Join Date
    Jan 2022
    Posts
    10
    ok. It seems serial is working for me.

  18. #18
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    26,213
    I see the audio shield in your photo. Please be aware the audio shield will not respond to I2C without MCLK. The chip remains in a low power mode and simply can not work at all until it has a clock signal. To get it to answer, you need to include the audio library I2S output which turns on the MCLK signal, or you can use analogWriteFrequency() and analogWrite() to create a fake MCLK signal (even just a few MHz is enough).

  19. #19
    Senior Member
    Join Date
    Apr 2014
    Location
    -
    Posts
    9,756
    Paul, the issue was that both, Uno and Teensy were used as I2C Masters. Yes that the shield was not found too is normal - but not the problem here.

Posting Permissions

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