element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Displaying time on an Arduino TFT display using a RTC 3231
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 28 replies
  • Subscribers 390 subscribers
  • Views 3957 views
  • Users 0 members are here
  • arduino uno
  • tft display
  • learning
  • DS3231 clock module
Related

Displaying time on an Arduino TFT display using a RTC 3231

Adam_A
Adam_A over 2 years ago

Hi, I was recently working on a new project which displayed time from a real time module to a Arduino TFT display using an Arduino UNO as the main board, however I'm still having trouble with it displaying anything on the screen as when I wire everything up and power the Arduino it just displays a white blank screen,

For the wiring I've made this diagram, (all parts in this diagram represent what I have):

image

And for the code I've added this: 
I have double checked that the library's do work with my display. 

#include <Wire.h>
RTC_DS3231 rtc;
char t[32];
#include "Adafruit_GFX.h"
#include "MCUFRIEND_kbv.h"
MCUFRIEND_kbv tft;

#include "Fonts/FreeSans9pt7b.h"
#include "Fonts/FreeSans12pt7b.h"
#include "Fonts/FreeSerif12pt7b.h"
#include "FreeDefaultFonts.h"

#define PI 3.1415926535897932384626433832795
#define WHITE 0xFFFF

int col[8];

void showmsgXY(int x, int y, int sz, const GFXfont *f, const char *msg)
{
  int16_t x1, y1;
  uint16_t wid, ht;


  tft.setFont(f);
  tft.setCursor(x, y);
  tft.setTextColor(0x0000);
  tft.setTextSize(sz);
  tft.print(msg);
}
void setup()
{
  Serial.begin(9600);
  Wire.begin();
  rtc.begin();
  rtc.adjust(DateTime(F(__DATE__),F(__TIME__)));
  //rtc.adjust(DateTime(2019, 1, 21, 5, 0, 0));
   tft.reset();
  uint16_t ID = tft.readID();
  tft.begin(ID);
  tft.setRotation(1);
  tft.invertDisplay(true);
  tft.fillScreen(0xffff);
}
void loop()
{
  DateTime now = rtc.now();
  sprintf(t, "%02d:%02d:%02d %02d/%02d/%02d", now.hour(), now.minute(), now.second(), now.day(), now.month(), now.year());  
  Serial.print(F("Date/Time: "));
  Serial.println(t);
  showmsgXY(170, 250, 2, &FreeSans9pt7b, t);
  delay(1000);
}


I personally think that the issue is with the wiring however again I'm not sure if it is the code or wiring which I'm messing up, as when I wire everything up it just displays a blank screen like this:

image

Final goal target to be displayed on the screen:

image

If anyone has worked with such displays and knows what's the issue any help would be highly apricated, thanks! 


  • Sign in to reply
  • Cancel

Top Replies

  • dougw
    dougw over 2 years ago in reply to Adam_A +2
    I presume the text libraries only overwrite the character pixels so previous pixels do not get blanked. I always write a blank before the update but it can flicker as the character momemtarily goes blank…
  • Andrew J
    Andrew J over 2 years ago in reply to shabaz +2
    Once you’ve got it working in the simplest, easiest case you could look at getting more complex: only print what changes. The date only changes as midnight; the hour once every 60 mins etc. So print the…
  • javagoza
    javagoza over 2 years ago +1
    There are many such modules. If you can add a reference to the spec sheet or where you bought it they may help you better. I have used several of these modules as in this project Arduino UNO Chess Clock…
Parents
  • Adam_A
    Adam_A over 2 years ago

    I have finally figured out the issue, it turns out it wasn't because of the code.. it's because the display wiring is incorrect, as it turns out I was connecting the reset display pins to the arduino which meant each time the Arduino wanted to communicate with the RTC it resets the display alongside, after removing the reset connections of the display (reset, lcd_rst, lcd_d3) it's now working. 

    However one issue remains, when the time updates it writes on top of the Arduino so im not sure on what to do now.
    (as you can see after the 22: digit)
    image

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • shabaz
    shabaz over 2 years ago in reply to Adam_A

    Now I see how the serial interface was possible.. it's correct that the display driver chip is parallel only, but it looks like the board has a couple of other chips on it, presumably they are serial-to-parallel or something. Anyway, glad it's working.

    You probably need to find a function to draw a rectangle, and just draw a filled rectangle of the background color, just prior to printing the time.

    You'll have to experiment a bit (perhaps also look at Adafruit tutorials), it's not hard, but you will need to start looking at the code, and getting an understanding of the graphics commands (like text, lines, rectangles) that you now have at your control.

    For instance, by looking at your own code, you can see a "tft.fillscreen" function being used. You could just reuse that. It clears the entire screen, giving you a fresh canvas for your text etc.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Adam_A
    Adam_A over 2 years ago in reply to shabaz

    Yesterday I spent hours trying to do that however nothing of what I was doing worked, I tried to also change the text color to no avail. 

    If anyone is able to change the text without it overwriting the old text please add that in the code I posted in the original post. 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • shabaz
    shabaz over 2 years ago in reply to Adam_A

    You have it right there in the code!

    It is the line 

    tft.fillScreen(0xffff);

    It is setting the entire screen to color 0xffff, which is white.

    You merely need to copy-and-paste that line before the line where you print the time, i.e. before the line which states:

    showmsgXY(170, 250, 2, &FreeSans9pt7b, t);

    That function, if you don't understand it, prints the text in the variable t at co-ordinates (170 250).

    This is very trivial, please try to follow the code.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • Andrew J
    Andrew J over 2 years ago in reply to shabaz

    Once you’ve got it working in the simplest, easiest case you could look at getting more complex: only print what changes.  The date only changes as midnight; the hour once every 60 mins etc.  So print the elements separately when needed.  Do this along logic:

    • change text colour to background
    • print old value
    • chsnge text colour to foreground colour
    • print new value

    when secs ticks over to zero, print minutes; when minutes ticks over to zero, print hour etc.  You need to track x and y coordinates (or at least offsets) for each printable element.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • Andrew J
    Andrew J over 2 years ago in reply to shabaz

    Once you’ve got it working in the simplest, easiest case you could look at getting more complex: only print what changes.  The date only changes as midnight; the hour once every 60 mins etc.  So print the elements separately when needed.  Do this along logic:

    • change text colour to background
    • print old value
    • chsnge text colour to foreground colour
    • print new value

    when secs ticks over to zero, print minutes; when minutes ticks over to zero, print hour etc.  You need to track x and y coordinates (or at least offsets) for each printable element.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube