I2C problem

Status
Not open for further replies.
Hi,
I have a problem with I2C. I am running default Wire.h slave sender master reciever codes but the slave wont answer to master. and I am using 2K resistors.
IMG_20190313_122353.jpg
 

Attachments

  • IMG_20190313_122357.jpg
    IMG_20190313_122357.jpg
    99.5 KB · Views: 198
Oh my.. you really should practice soldering..
maybe a connection problem.
edit: connections on 18/19 on the left teensy do not look good. mabe it works, maybe not.

Please post the programs for both, Master and slave.
 
To move forward on this, I'd suggest putting an LED on each of those 4 pins and try running the LED blink example. That can help you figure out if the pins really are connected.

If you do find 1 or more pins need to be re-soldered, here's a couple ideas that might help...

Solder has a chemical added called "flux". It's essential to getting good results. A common novice mistake looks like applying the solder to your iron, then with a ball of molten solder hanging off the tip of the iron, touching it to the pad and pin to be soldered. All the flux chemical ends up only on your iron, where it can't have the cleaning & whetting action on the pad & pin.

Put the tip of your iron onto the existing solder and let it get fully molten. Then apply a little more solder, hopefully touching or coming as close as practical to the pad. This will add more solder, which isn't really what you want... the thing you *really* need is some of the flux chemical to get into the molten mix. It will really help the new and old solder to flow.

Always leave the iron in contact for at least half a second after you withdraw the solder. Letting all 3 metals (the solder, the pin, and the pad) fully heat to the same temperature is important. Then they all cool together. That's essential for forming a good bond between the metals.
 
Thanks for the ideas, the connection between the pins and teensy is good. The program suddenly started working I dont know what I have done, but now it works.

However I have another problem. I am playing with TCA 8418. But as soon as I try to end transmission the program wont contiunue.
Code:
#include <Wire.h>
#include <WireKinetis.h>

#define adress 0x34

void setup() {
  
  Serial.begin(9600);
  Serial.println("setup begin");
  Wire.beginTransmission(adress);
            Serial.println("setup");
  Wire.write(0x01);
             Serial.println("setup");
  Wire.write(0xFF);   //initial setup of the chip
            Serial.println("setup");
  Wire.endTransmission();

 
Serial.println("setup");

   Wire.beginTransmission(adress);
   Wire.write(0x1E);    
   Wire.write(00000001); // set row 1
   Wire.endTransmission();
Serial.println("setup");
    Wire.beginTransmission(adress);
    Wire.write(0x1E);
    Wire.write(00001111); //set colum 1-4
     Wire.endTransmission();
     Serial.println("setup done");
    
}
byte REG;
void loop() {
  Wire.beginTransmission(adress);
    Wire.write(0x04);
    Wire.endTransmission();
    Wire.requestFrom(adress, 1);        // request 1 byte(s) from slave device.  
    while(Wire.available())             // slave may send less than requested.  
    { 
      REG = Wire.read();  
      Serial.println(REG); 
    } 

}

This is the output of the code
setup begin
setup
setup
setup

I dont know what to do, and I sadly dont have osciloscope
 
Hi, I resoldered the pins. Teensy can find the chip and start a transmission, but it hangs when I end the transmission. Do you have any ideas what icould caus the hang?
 
Do you have any ideas what icould caus the hang?

Could be a hardware issue, like one or both pins stuck low.

Could be something wrong on the software side.

Since we can't see your new hardware connection, and we don't know what you're doing for the code, how could anyone help? You need to show us what you're doing, ideally with enough info that anyone could reproduce the problem if they have the right hardware.
 
Thanks for the advice. Now it is not hanging on the endTransmission, but it is returning 2 and that means NACK on adress, but I am sure that the adress is right.
 
Thanks for the advices. Now it is working well, bur I have different problem. the problem is that whenever I press a button that is in the key matrix the chip wont respond to any messeges. the wire.endTransmission returns 2.
Code:
#include <Wire.h>

#include <WireKinetis.h>

#include "Wire.h"

#define adress 0x34
#define row 0x07
#define col 0x0F

void setup() {
pinMode(11, INPUT_PULLUP);
pinMode(13, OUTPUT);
  Serial.begin(9600);
  delay(1000);
  Serial.println("setup begin");
  Wire.begin();
  
  Wire.beginTransmission(0x34);
            Serial.println("setup");
  Wire.write(0x01);
             Serial.println("setup");
  Wire.write(0x01);   //initial setup of the chip
            Serial.println("setup");
int n = Wire.endTransmission();

Serial.println(n);

Serial.println("setup");

   Wire.beginTransmission(adress);
   Wire.write(0x1D);    
   Wire.write(row); // set row 1
  n = Wire.endTransmission();
  Serial.println(n);
Serial.println("setup");
    Wire.beginTransmission(adress);
    Wire.write(0x1E);
    Wire.write(col); //set colum 1-4
    n = Wire.endTransmission();

      Wire.beginTransmission(adress);
   Wire.write(0x29);    
   Wire.write(row); // set debounce for row 1
  n = Wire.endTransmission();
  Serial.println(n);

    Wire.beginTransmission(adress);
   Wire.write(0x2A);    
   Wire.write(col); // set row 1
  n = Wire.endTransmission();
  Serial.println(n);
  
     Serial.println("setup done");
    Serial.println(n);
}
byte REG;
void loop() {

  int INTERUPPT = digitalRead(11);
  if(INTERUPPT == LOW)
  {
     digitalWrite(13, HIGH);
  }
  
  delay(1000);
  
  
    Wire.beginTransmission(0x34);
    Wire.write(0x1E);
    Serial.print("prenos: ");
   int m = Wire.endTransmission();
   Serial.println(m);
    Wire.requestFrom(0x34, 1);        // request 1 byte(s) from slave device.  
    while(Wire.available())             // slave may send less than requested.  
     {
      
      
      REG = Wire.read();  
      Serial.print("reg: ");
      Serial.println(REG);
      
     }
  
 // delay(1000);


}
 
Status
Not open for further replies.
Back
Top