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…
  • Andrew J
    Andrew J over 2 years ago in reply to Adam_A

    When you say it wasn’t syncing with your time model what do you mean? It would help if you could show how it is connected, what your serial debug is showing.  The guy in this video has it plugged directly into a Mega, with a UNO I think you have to wire it - where did you get the info for doing that?  If you have updated code that “sort of works” you could post that.  The fact you say it is now displaying digits seems to imply that it may just be a simple coding error, however you are drip-feeding info to us, rather than giving us the full picture of what you have and what you have tried which makes the conversation a lot longer (and more frustrating on this side)

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

    You don't appear to have #included a DS3231 RTC library before attempting to use it.

    Your code:

    image

    YouTube code:

    image

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

    Presumably that is with the LCD shield plugged directly into the UNO and hence which has all the necessary pins connected to the right places?

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

    Your project looks pretty similar to this one:

    https://www.instructables.com/Astronomical-Clock-1/

    which might be of some help.

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

    Thats frustrating! It appears to be resetting and drawing a white background okay, but no text...

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

    imageIn the Smarthab project, I used a TI Stellaris LM4F120 LaunchPad, with a 32-bit CPU, and an EB-LM4F120-L35,  BosterPack. It has a 1/4 SVA LCD with Touch Sence as well and has a huge graphics library. I used the TI CSS (code composer) C compiler, but today I would instead use the Eclipse IDE. BTW you can get the display for $35 at Newark. Right parts for the right job.

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

    I had a bunch of LED clock displays. I gave mine to E14 to give away. - no takers

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • 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
  • Adam_A
    Adam_A over 2 years ago in reply to Adam_A

      javagoza  Was correct about how the connections were actually connecting to the SD card reader not the display, however even if you were to connect the correct wiring for the display but still have the reset pins connected the display would reset it self every time the Arduino wanted to communicate to the RTC. 

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

    (thus the white display and it flicking) 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
<>
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