ESP32 TFT can't find RTC

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Post Reply
User avatar
ershler
 
Posts: 30
Joined: Fri Dec 06, 2013 6:38 pm

ESP32 TFT can't find RTC

Post by ershler »

I have a Feather ESP32-S2 TFT connected to a DS3231 with an I2C connection. The I2C_Scan sketch produces

Adafruit I2C Scanner
Default port (Wire) I2C scan: 0x0, 0xB, 0x68,
Default port (Wire) I2C scan: 0x0, 0xB, 0x68,
Default port (Wire) I2C scan: 0x0, 0xB, 0x68,
...
The docs on the DS3231 indicates that the RTC I2C address is fixed at 0x68 and cannot be changed.

Yet the DS3231 example just reports
Couldn't find RTC

I am running the Arduino IDE Version: 2.0.0-rc9 and the the latest version of the DS3231 1.1.0
and here's the code. Why can't the RTC be found?

Code: Select all

// Date and time functions using a DS3231 RTC connected via I2C and Wire lib
#include "RTClib.h"

RTC_DS3231 rtc;

char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

void setup () {
  Serial.begin(57600);

#ifndef ESP8266
  while (!Serial); // wait for serial port to connect. Needed for native USB
#endif

  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    Serial.flush();
    while (1) delay(10);
  }

  if (rtc.lostPower()) {
    Serial.println("RTC lost power, let's set the time!");
    // When time needs to be set on a new device, or after a power loss, the
    // following line sets the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    // This line sets the RTC with an explicit date & time, for example to set
    // January 21, 2014 at 3am you would call:
    // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
  }

  // When time needs to be re-set on a previously configured device, the
  // following line sets the RTC to the date & time this sketch was compiled
  // rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  // This line sets the RTC with an explicit date & time, for example to set
  // January 21, 2014 at 3am you would call:
  // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
}

void loop () {
    DateTime now = rtc.now();

    Serial.print(now.year(), DEC);
    Serial.print('/');
    Serial.print(now.month(), DEC);
    Serial.print('/');
    Serial.print(now.day(), DEC);
    Serial.print(" (");
    Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
    Serial.print(") ");
    Serial.print(now.hour(), DEC);
    Serial.print(':');
    Serial.print(now.minute(), DEC);
    Serial.print(':');
    Serial.print(now.second(), DEC);
    Serial.println();

    Serial.print(" since midnight 1/1/1970 = ");
    Serial.print(now.unixtime());
    Serial.print("s = ");
    Serial.print(now.unixtime() / 86400L);
    Serial.println("d");

    // calculate a date which is 7 days, 12 hours, 30 minutes, 6 seconds into the future
    DateTime future (now + TimeSpan(7,12,30,6));

    Serial.print(" now + 7d + 12h + 30m + 6s: ");
    Serial.print(future.year(), DEC);
    Serial.print('/');
    Serial.print(future.month(), DEC);
    Serial.print('/');
    Serial.print(future.day(), DEC);
    Serial.print(' ');
    Serial.print(future.hour(), DEC);
    Serial.print(':');
    Serial.print(future.minute(), DEC);
    Serial.print(':');
    Serial.print(future.second(), DEC);
    Serial.println();

    Serial.print("Temperature: ");
    Serial.print(rtc.getTemperature());
    Serial.println(" C");

    Serial.println();
    delay(3000);
}


User avatar
mikeysklar
 
Posts: 8427
Joined: Mon Aug 01, 2016 8:10 pm

Re: ESP32 TFT can't find RTC

Post by mikeysklar »

It is a good sign that you are getting the address showing up in the i2c scan.

Have you tried the Adafruit recommended adafruit/RTClib (v2.0.3) is current.

https://github.com/adafruit/RTClib

Are you using a Stemma QT cable between the ESP32-S2 TFT Feather and the DS3231 RTC breakout or another way to connect? Is it an Adafruit cable?

User avatar
ershler
 
Posts: 30
Joined: Fri Dec 06, 2013 6:38 pm

Re: ESP32 TFT can't find RTC

Post by ershler »

Thanks for the reply. I am using the most recent version of the RTClib. I have the older version of the RTC breakout that does not have the STEMMA connectors on it. But I am using an Adafruit I2C cable that I cut in half. So it plugs into the feather and is soldered into the RTC. I thought I might try some of the other RTC examples to see if that makes any difference. I have left the “reset” pin on the RTC open, given that the docs say it has an internal 50K pull up. Perhaps I should try an external 10K or so.

User avatar
mikeysklar
 
Posts: 8427
Joined: Mon Aug 01, 2016 8:10 pm

Re: ESP32 TFT can't find RTC

Post by mikeysklar »

I'll need you to confirm for me that you are using the Adafruit RTClib since our latest version numbers were not matching earlier in this thread.

Can you post some photos (800x600 is fine) of how you have wired and soldered the stemma cable to RTC breakout board? I'd like to confirm the soldering is adequate. You must have a fairly good connection established if you are getting an address out of the i2cscan() code. The most common mistake is using 5v when everything needs to be 3v3.

There are 10k pullups on the DS3231 so you should be covered there.

User avatar
ershler
 
Posts: 30
Joined: Fri Dec 06, 2013 6:38 pm

Re: ESP32 TFT can't find RTC

Post by ershler »

OK, here is the info on the RTClib

RTClib by Adafruit
Version 2.0.3
INSTALLED
Works with DS1307, DS3231,
PCF8523, PCF8563 on multiple
architectures
A fork of Jeelab's fantastic RTC
library
More info

and here is a picture of the solder connections



Unfortunately, I damaged the USB C connector and now the feather is not working.
I have ordered some replacements, but in the mean time, Im going to swap in
another board to continue the testing.
Thanks
Attachments
IMG_1357.jpeg
IMG_1357.jpeg (237.37 KiB) Viewed 79 times

User avatar
mikeysklar
 
Posts: 8427
Joined: Mon Aug 01, 2016 8:10 pm

Re: ESP32 TFT can't find RTC

Post by mikeysklar »

Okay, let us know when you get power to the Feather worked out or a replacement.

The red wire connected to Vin on the RTC what is that connected to on the ESP32-S2?

The i2c cut cable could probably use a bit more solder on each wire connecting to the perma proto board to fill the vias completely.

User avatar
ershler
 
Posts: 30
Joined: Fri Dec 06, 2013 6:38 pm

Re: ESP32 TFT can't find RTC

Post by ershler »

Actually, I was depending the I2C cable for power and ground. Perhaps that’s not a good idea. Looking at the vias from the bottom with the wires sticking slightly out, the soldering looks pretty good.

User avatar
ershler
 
Posts: 30
Joined: Fri Dec 06, 2013 6:38 pm

Re: ESP32 TFT can't find RTC

Post by ershler »

OK,
Tonight I found the problem. The I2C Scanner contains the following piece of code.

Code: Select all

#if defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S2_TFT)
  pinMode(TFT_I2C_POWER, OUTPUT);
  digitalWrite(TFT_I2C_POWER, HIGH);
#endif
These lines of code do not exist in the DS3231. As soon as I added this code, everything works fine. The ESP32 Feather requires the I2C power to be enabled before I2C system will function properly.

User avatar
mikeysklar
 
Posts: 8427
Joined: Mon Aug 01, 2016 8:10 pm

Re: ESP32 TFT can't find RTC

Post by mikeysklar »

Good find. Thank you for the follow up.

Post Reply
Please be positive and constructive with your questions and comments.

Return to “Arduino”