2
\$\begingroup\$

I am trying my hand at building a smart watch from scratch. I just got the latest PCBs delivered and upon soldering everything I found that the TTGO micro-32, essentially an ESP32, cannot detect any of the sensors over I2C. (The linked datasheet is the most detailed one I can find). I currently have 4.7 kΩ pull-up resistors tying SCL and SDA to 3.3 V which is also the operating voltage of the TTGO.

However, I initially tried 1 kΩ pull-up resistors with no success either. I also tried removing the pull-up resistors completely because I figured the TTGO probably had internal pull-ups like the ESP32, but that did not work.

The sensors I am using are the BME680, MCP79402T-I/MS (RTC), and ADXL345BCCZ-RL7 (Accelerometer).

Below is the schematic for the design:

schematic

I found the TTGO cannot detect the sensors by running this I2C scanner code within the Arduino compiler:

#include <Arduino.h>
#include <Wire.h>

void setup()
{
  Wire.begin(21, 22);
  Serial.begin(115200);
  while (!Serial);             
  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
}

Here is where it gets confusing though. Before I designed this board, I created a breakout board for the TTGO micro-32 and wired a 128x64 OLED module to it via I2C.

I ran the same code on the breakout board to find the I2C address of the screen and it worked. For reference, on the breakout I did not use any pull-up resistor because from the best I can tell the screen has 4.7 kΩ pull-ups on it already. I have no idea what the problem could be since from the best I can tell my schematic matches the datasheets and it isn't a software issue.

\$\endgroup\$
5
  • \$\begingroup\$ There seems to be two versions of the TTGO module. Have you verified which one you have, in order to match the hardware pins correctly, and also the pin numbers in software? Have you scoped or used a logic analyzer on the I2C pins? Or even verified with a multimeter that you can toggle the pins - or rather pull them low as outputs, or let them float as inputs so the resistor pull the pins high? If the problem is with some chip, it's difficult to debug which chip it is, as there are no series resistors between chips and bus. \$\endgroup\$
    – Justme
    Aug 17, 2022 at 5:15
  • 1
    \$\begingroup\$ I don't know how often you're doing I2C bus transfers but aren't these low-value resistors like 4K7 going to drain your battery harder than it needs to be? I'd have expected very low currents everywhere in a power-conscious design like a smartwatch. I2C will work fine if run much slower with higher pull-ups. \$\endgroup\$
    – TonyM
    Aug 17, 2022 at 8:38
  • \$\begingroup\$ Yes, everything seems to be in order. I have the right module, and I can toggle the pins. @Justme \$\endgroup\$ Aug 17, 2022 at 23:36
  • \$\begingroup\$ Did you check your link for the ESP32 why the pins 21 and 22 may be problematic and it might be better to use other pins? \$\endgroup\$
    – Justme
    Aug 17, 2022 at 23:47
  • \$\begingroup\$ Can you provide us with an image, or more, so we can check connections? \$\endgroup\$
    – RemyHx
    Aug 23, 2022 at 14:06

1 Answer 1

0
\$\begingroup\$

one can find I2C devices on an ESP32 using the code below:

  void I2Cscanner() {
  Serial.println ();
  Serial.println ("I2C scanner. Scanning ...");
  byte count = 0;

  Wire.begin();
  for (byte i = 8; i < 120; i++)
  {
    Wire.beginTransmission (i);          // Begin I2C transmission Address (i)
    if (Wire.endTransmission () == 0)  // Receive 0 = success (ACK response) 
    {
      Serial.print ("Found address: ");
      Serial.print (i, DEC);
      Serial.print (" (0x");
      Serial.print (i, HEX);     // PCF8574 7 bit address
      Serial.println (")");
      count++;
    }
  }
  Serial.print ("Found ");      
  Serial.print (count, DEC);        // numbers of devices
  Serial.println (" device(s).");
}
\$\endgroup\$
2
  • \$\begingroup\$ Is there a reason this function only scans the address range 0x08 to 0x77? \$\endgroup\$
    – Velvel
    Sep 27, 2022 at 10:30
  • 3
    \$\begingroup\$ @Seir Addresses 0-7 and 0x78-0x7F are reserved for special uses. \$\endgroup\$
    – TypeIA
    Sep 27, 2022 at 10:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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