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

Thread: Can't find other device with i2c

  1. #1
    Junior Member
    Join Date
    Jul 2020
    Posts
    4

    Can't find other device with i2c

    Hi! I've tried connecting an Adafruit Feather Huzzah to the Teensy 3.6 by i2c connecion. The connection is: (teensy -> huzzah)
    GND -> GND
    3.3V -> 3V
    SCL0 -> SCL -> 4.7 ohm -> 3.3V
    SDA0 -> SDA -> 4.7 ohm -> 3.3V

    The Teensy is soldered on the backside.

    I've used a scanner to look for connections, but neither device could find one. I've also tried 2* 1k ohm per connection, which also didn't work. I've connected the Adafruit MPR121 to both devices without any resistor, which worked out fine and the scanner found that connection.

    Does anyone know what went wrong? I'd very much appreciate any help!

    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 know.
        // 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
        //    https://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.
        // Version 6, November 27, 2015.
        //    Added waiting for the Leonardo serial communication.
        //
        //
        // 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);
          while (!Serial);             // Leonardo: wait for serial monitor
          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("Unknown 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
        }
    Click image for larger version. 

Name:	photo_2020-07-17_19-12-25.jpg 
Views:	42 
Size:	211.8 KB 
ID:	21020

  2. #2
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    8,464
    I might be missing something, but what is running on the Huzzah - that is in order for one processor to see the other processor, one of them needs to be running some form of I2C slave code
    For example our Wire library has sketches like slave_receiver which set up the board as s slave I2C device that than the other should see.

  3. #3
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,544
    When you solder the Teensy header on the bottom of the board, you will have used the shorter end of the header pin, which is then shortened even more by the solder. This will prevent the pins making good electrical contact with the breadboard sockets. So, you may have a rather flaky 3v3 and Gnd connection from the Teensy to the other parts, particularly the Huzzah.
    Try connecting the Teensy's 3v3 and ground to the breadboard using male/female jumper wires like you did with SCL and SDA.

    Pete

  4. #4
    Junior Member
    Join Date
    Jul 2020
    Posts
    4
    Thank you for the quick responces!

    I tried hooking up the Teensy with all male/female wires, but sadly that didn't change anything.

    I loaded the slave_recieve on the Huzzah.When I run master_write on the Teensy, neither devices give me any output on the serial. When I run the scanner code from above, I get this:

    Code:
    Scanning...
    
    Unknown error at address 0x0D
    
    Unknown error at address 0x1A
    
    Unknown error at address 0x1C
    
    Unknown error at address 0x24
    
    Unknown error at address 0x29
    
    Unknown error at address 0x2D
    
    Unknown error at address 0x35
    
    Unknown error at address 0x37
    
    Unknown error at address 0x3C
    
    Unknown error at address 0x3E
    
    Unknown error at address 0x4D
    
    Unknown error at address 0x4F
    
    Unknown error at address 0x53
    
    Unknown error at address 0x57
    
    Unknown error at address 0x5F
    
    Unknown error at address 0x6D
    
    Unknown error at address 0x71
    
    Unknown error at address 0x73
    
    Unknown error at address 0x75
    
    No I2C devices found

  5. #5
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    8,464
    Looking at your picture, It does not look like your breadboards pins are soldered to the teensy? Friction connections typically do not work.
    So it is hard to say if you SCL/SDA pins are working likewise for Gnd and 3.3v...

  6. #6
    Junior Member
    Join Date
    Jul 2020
    Posts
    4
    The Teensy is soldered on the backside, like this:
    Click image for larger version. 

Name:	photo_2020-07-17_21-06-55.jpg 
Views:	22 
Size:	135.1 KB 
ID:	21021

    I was able to connect the Adafruit MPR121 to the Teensy, which requires connections to 3.3V, GND, SDA and SCL, so I dont think the soldering is the problem.

  7. #7
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,544
    Those are longer pins than the ones I thought you had used. They look good.

    Pete

  8. #8
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    8,464
    Sorry I don't think I have any of the Adafruit Huzzah boards, so not sure how much I can help debug here.

    Also did a quick search for Adafruit ESP8266 I2C Slave, and ran into this open Issue: https://github.com/esp8266/Arduino/issues/5762
    Which sounds like others have issues trying to get the ESP8266 to work in Slave mode.

    Edit: You might also want to ask up on Adafruit forum to see if someone there has seen this and/or has solution.

  9. #9
    Junior Member
    Join Date
    Jul 2020
    Posts
    4
    It works when the devices swap roles, with the Teensy as slave and the Huzzah as master. The scanner works as well when it runs on the Huzzah and the Teensy has the slave code running.

    Thank you very much for your help!

  10. #10
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,737
    Maybe check the resistors with a multimeter? Normally you should use between 1K to 4.7K for I2C pullups.

    Your first message says 4.7 ohm! But the colors in the photo look like 470 ohms.

    Also agree with Kurt about ESP. It might not really support slave mode. Try the scanner example with a "normal" I2C chip to make sure your Teensy 3.6 really is working.


    EDIT: Ah, I see you posted at the same moment. Looks like maybe ESP8266 just doesn't work in I2C slave mode?

  11. #11
    Senior Member
    Join Date
    Jul 2020
    Posts
    689
    yellow-purple-red = 472 = 4700 ohms. Pretty sure its red, not brown or orange.

  12. #12
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,737
    Kinda looks like yellow-purple-brown, at least on my monitor. But maybe that is actually red.

  13. #13
    Member
    Join Date
    Apr 2020
    Location
    Germany, NRW
    Posts
    86
    On the Adafruit product page it is mentioned, that they use bit banging for i2c on that board. On the thread Kurt posted are people which mention that the 80Mhz of the huzzah might be too slow for slave mode. If it works with swapped roles the setup is likely ok.

    I also just tried with a Teensy 4.0 and a Huzzah with no success.

  14. #14
    Member
    Join Date
    Apr 2020
    Location
    Germany, NRW
    Posts
    86
    I think i have proof, that it is Huzzah related.

    As i mostly use Adafruit Feathers it is very easy to swap boards around, as the pinout is the same.

    So i took the non working huzzah code and changed the board type in platformio.ini to FeatherM4 and swapped the huzzah physically with a FeatherM4. Flashed unchanged software => Works.

    Click image for larger version. 

Name:	IMG_4861.JPG 
Views:	16 
Size:	240.5 KB 
ID:	21023

  15. #15
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,737
    Quote Originally Posted by mstiller View Post
    I also just tried with a Teensy 4.0 and a Huzzah with no success.
    Wire lib on Teensy 4.x does not yet support I2C slave mode.

  16. #16
    Member
    Join Date
    Apr 2020
    Location
    Germany, NRW
    Posts
    86
    Teensy 4.x as master and the other board as slave. Huzzah 8266 not working, Feather M4 working.

Posting Permissions

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