1
\$\begingroup\$

I am trying to communicate with TCS34725 module with NUCLEO-F401R board. The first I tried is to read out ID register of TCS34725, which should be 0x44, to check the connection. Everything works fine when I have my scope probe (gain is x10) is connected to SCL/SDA Line:

enter image description here

BUT, whenever I disconnect my probes (both or one of them), the HAL_I2C_Mem_Read function call will timeout and readout will be 0 not 0x44. I have no idea on how to fix this, so I am here for help.


Here is my hardware connection:

enter image description here

The TCS34725 Module is a product by DFROBOT, the schematic is (Source):

enter image description here


My code is:

#define TCS34725_ADDRESS          (0x29 << 1)
#define TCS34725_ID               (0x12)
extern I2C_HandleTypeDef hi2c1;

void TCS34725_Read(unsigned char subAddr, unsigned char* dataBuffer, unsigned char bytesNumber) {
  subAddr |= TCS34725_COMMAND_BIT;

  HAL_I2C_Mem_Read(&hi2c1, TCS34725_ADDRESS, subAddr, I2C_MEMADD_SIZE_8BIT, dataBuffer, bytesNumber, 1000);
}

uint8_t TCS34725_Init(void) {
  unsigned char readout;
  TCS34725_Read(TCS34725_ID, &readout, 1);
  return readout;
}

Here is my current hardware setup, I have changed another breadboard and redo my wiring to make sure nothing is loose. But same problem still exists.

enter image description here

\$\endgroup\$
8
  • \$\begingroup\$ That sounds like some parasitic effect that could be quite hard to find remote. Can you show a photo of where exactly you place your probes? Maybe there is some loose contact and by pressing the probe tip against it, it works? \$\endgroup\$ – jusaca Feb 4 at 6:51
  • \$\begingroup\$ All those wires in space. Interconnected by way of that proto board. Kind of a nightmare. That is probably why it doesn't work. A lot of times when a scope probe makes something work, you can achieve the same affect by putting a capacitor where the probe was. Like a 15pF or 22pF. \$\endgroup\$ – mkeith Feb 4 at 8:27
  • 1
    \$\begingroup\$ @jusaca I deliberately suggested resistors at the almost minimum end of the scale to see if it is even about that. It is within I2C specifications and the IO driver specs of the chips. 1k8 or 2k2 should be still strong enough, with less current. \$\endgroup\$ – Justme Feb 4 at 9:11
  • 1
    \$\begingroup\$ If you have to go board-to-board with I2C, and if you are able, it is helpful to use separate grounds for each signal, and twist the wires together. So you twist SDA with one ground wire and twist SCL with another ground wire. It is kind of a "pseudo differential" treatment of the wires. \$\endgroup\$ – mkeith Feb 4 at 9:11
  • 2
    \$\begingroup\$ @mkeith Either that, or twisting VCC with SDA for less wires. Simply deattaching the wires from each other so SDA and SCL have less coupling should work too. Or using the suggestion from I2C specs, i.e. have wiring like SCL-GND-VCC-SDA in the flat cable. \$\endgroup\$ – Justme Feb 4 at 9:30
1
\$\begingroup\$

There is too much capacitive coupling between SDA and SCL due to long wiring and bad selection of pinout on the module, where SDA and SCL are next to each other.

The 10k pull-ups are too weak for this level of stray capacitance between the SDA and SCL.

Make the pull-ups stronger, for example 1.2k pull-ups are much stronger but still within specification for a 3.3V I2C bus.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.