Printing Date on a TFT Display - Problem

code:

#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_TFTLCD.h> // Hardware-specific library
#include <Wire.h>
#include "RTClib.h"

#define LCD_CS A3 // Chip Select goes to Analog 3
#define LCD_CD A2 // Command/Data goes to Analog 2
#define LCD_WR A1 // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0
#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin

// Assign human-readable names to some common 16-bit color values:
#define  BLACK   0x0000
#define BLUE    0x001F
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF

Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
RTC_DS3231 rtc;
char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

void setup() {
 
 tft.reset();
 uint16_t identifier = tft.readID();
 tft.begin(identifier);
 tft.setRotation(1);
 tft.fillScreen(WHITE);

 tft.setCursor(18,20);
 tft.setTextColor(RED);
 tft.setTextSize(3);
 tft.print("Garden Irrigation Control");
 tft.fillRect (0,50,500,3,BLACK);
 
}

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

  tft.setCursor(75,55);
  tft.print (daysOfTheWeek[now.dayOfTheWeek()]);
  tft.print (" ");
  tft.print (now.month());
  tft.print (", ");
  tft.print (now.day());
  
  delay(1000);

}

Problem:

It is printing "Sunday 165 165" when I would like it to say "Sunday Mar 25"

I have also, on another sketch, returned random Characters on the Serial Monitor

Any Thoughts?

Lindenrulz:
165 165

Inadequate power?

What do you get if you try this?

#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_TFTLCD.h> // Hardware-specific library
#include <Wire.h>

#define LCD_CS A3 // Chip Select goes to Analog 3
#define LCD_CD A2 // Command/Data goes to Analog 2
#define LCD_WR A1 // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0
#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin

// Assign human-readable names to some common 16-bit color values:
#define  BLACK   0x0000
#define BLUE    0x001F
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF

uint8_t ss=0, mi=0, hh=0, wd=6, dd=1, mo=1, yy=0;

Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);

void setup() {
 
  tft.reset();
  uint16_t identifier = tft.readID();
  tft.begin(identifier);
  tft.setRotation(1);
  tft.fillScreen(WHITE);
 
}

void loop() {

  tft.fillRect (0,10,500,30,WHITE);
  tft.setCursor(18,20);
  tft.setTextColor(BLUE);

  // ask RTC for the time
  // send request to receive data starting at register 0
  Wire.beginTransmission(0x68); // 0x68 is DS3231 device address
  Wire.write((uint8_t)0); // start at register 0
  Wire.endTransmission();
  Wire.requestFrom(0x68, 7); // request seven bytes (ss, mi, hh, wd, dd, mo, yy)
  // check for a reply from the RTC, and use it if we can
  if (Wire.available() >= 7) {
    // if we're here, we got a reply and it is long enough
    // so now we read the time
    ss = bcd2bin(Wire.read()); // get seconds
    mi = bcd2bin(Wire.read()); // get minutes
    hh = bcd2bin(Wire.read()); // get hours
    wd = bcd2bin(Wire.read());
    dd = bcd2bin(Wire.read());
    mo = bcd2bin(Wire.read());
    yy = bcd2bin(Wire.read());
    // show that we successfully got the time
    tft.print("Got the time: ");
    tft.print ("\'");
    if (yy<10) tft.print("0");
    tft.print(yy);
    tft.print("-");
    if (mo<10) tft.print("0");
    tft.print(mo);
    tft.print("-");
    if (dd<10) tft.print("0");
    tft.print(dd);
    tft.print("(");
    switch (wd) {
      case 1: tft.print("Mon"); break;
      case 2: tft.print("Tue"); break;
      case 3: tft.print("Wed"); break;
      case 4: tft.print("Thu"); break;
      case 5: tft.print("Fri"); break;
      case 6: tft.print("Sat"); break;
      case 7: tft.print("Sun"); break;
      default: tft.print("Bad"); 
    }
    tft.print(") ");
    if (hh<10) tft.print("0");
    tft.print(hh);
    tft.print(":");
    if (mi<10) tft.print("0");
    tft.print(mi);
    tft.print(":");
    if (ss<10) tft.print("0");
    tft.print(ss);
  }
  else {
    // if we're here, that means we were unable to read the time
    tft.print("Unable to read time from RTC");
  }
  delay(800);
}

uint8_t bcd2bin(uint8_t x) {
  // converts from binary-coded decimal to a "regular" binary number
  return ((((x >> 4) & 0xF) * 10) + (x & 0xF)) ;
}

It is displaying "Unable to read RTC" message. As for the Nick_Pyner comment, voltage measured at Vcc and GND Pins on the RTC is 4.7V.

My comment was actually about power.

Ok, I hooked up a 4.5V DC Power Supply directly to the RTC to negate any power issues. I am still receiving the "Unable to Read RTC" message.

Lindenrulz:
4.5V DC Power Supply directly to the RTC to negate any power issues

OK, I have no idea of what you are doing, but I'm betting you don't either, and there is a power problem still down there somewhere. This is an Arduino forum, so you might try powering the RTC from Arduino like everybody else does and addressing any power problem there. You don't actually mention any hardware you are using so now might be a good time to do so but, at a rough guess, the RTC probably has a battery on board and therefore should not have any power issues itself, any such issues are likely to be found elsewhere, and you haven't negated anything.

Receiving the "Unable to Read RTC" message suggests there is nothing wrong with the code.

Hardware used:

Arduino Mega 2560
3.5" Touchscreen Breakout from Adafruit
DS3231 Precision RTC from Adafruit cw Battery Backup

Well, at least we know that the DS3231 is probably quite normal, I guess on a ZS-040 board, and very likely innocent.

Still no mention of how you are powering that stuff then?

I mostly power it through the USB to a computer but I have also tried a 12VDC 20W adapter

FWIW. the first and last time I saw 165s was when I swapped out the motherboard in the PC, which taught me a bit about USB sockets. You are probably aware that the 12v is not a comfortable choice, but I imagine it is adequate for this purpose.