Need Help for GPS Time Output in P10 Display (Dot Matrix Display)

I have a code for GPS Clock with U-Blox Neo 6m GPS Module and Output in 16x2 LCD.
I Changed the code for showing the GPS time in DMD P10 Display with DMD2 Library.

After transferring the code to UNO P10 not showing anything. I didn't find anything wrong in the code. :frowning:

Please experts see the code and tell me where i did mistake in code.

Thanks in advance.

Original Code: (GPS Module with LCD Display)

#include<LiquidCrystal.h>
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
#include <SoftwareSerial.h>
SoftwareSerial Serial1(10, 11); // RX, TX
char str[70];
char *test="$GPRMC";
int temp,i;
void setup() 
{
  lcd.begin(16,2);
  Serial1.begin(9600);
  lcd.setCursor(0,0);
  lcd.print("GPS Clock");
  lcd.setCursor(0,1);
  lcd.print(" By PULSER ");
  delay(300);
}
void loop()
{
  serial1Event();
  if (temp) 
  {
    lcd.clear();
    int str_lenth=i;
    int x=0,comma=0;
    String UTC_hour="";
    String UTC_minut="";
    String UTC_second="";
    String UTC_date="";
    String UTC_month="";
    String UTC_year="";
    String str1="";
    while(x<str_lenth)
    {
     if(str[x]==',')
     comma++;
      if(comma==1)
      {
        x++;
        UTC_hour+=str[x++];
        UTC_hour+=str[x++];
        UTC_minut+=str[x++];
        UTC_minut+=str[x++];
        UTC_second+=str[x++];
        UTC_second+=str[x];
        comma=2;
      }
      if(comma==10)
      {
        x++;
          UTC_date+=str[x++];
          UTC_date+=str[x++];
          UTC_month+=str[x++];
          UTC_month+=str[x++];
          UTC_year+=str[x++];
          UTC_year+=str[x];
      }  
      x++;
    }
    int UTC_hourDec=UTC_hour.toInt();
    int UTC_minutDec=UTC_minut.toInt();
    int Second=UTC_second.toInt();
    int Date=UTC_date.toInt();
    int Month=UTC_month.toInt();
    int Year=UTC_year.toInt();
    int Hour=UTC_hourDec+6;
    if(Hour>23)
    {
     Hour-=24;
     Date+=1;
    }
    int Minut=UTC_minutDec+00;
    if(Minut>59)
    Minut-=60;
    
    
   // UTC_ind_zone_time
    lcd.clear();
    lcd.print("Date: ");
    lcd.print(Date);
    lcd.print("/");
    lcd.print(Month);
    lcd.print("/");
    lcd.print("20");
    lcd.print(Year);
     
     lcd.setCursor(0,1);
     lcd.print("Time: ");
     lcd.print(Hour);
    lcd.print(":");
    lcd.print(Minut);
    lcd.print(":");
    lcd.print(Second);
  //  delay(100);
    temp=0;
//    j=0;
    i=0;
    x=0;
    str_lenth=0;
//    k=0;
  }
 // delay(1000);
}
void serial1Event()
{
  while(1)
  {
   while (Serial1.available())            //checking serial data from GPS
   {
    char inChar = (char)Serial1.read();
     str[i]= inChar;                    //store data from GPS into str[]
     i++;
     if (i < 7)                      
     {
      if(str[i-1] != test[i-1])         //checking for $GPRMC sentence
      {
        i=0;
      }
     }
    if(i>65)
    {
     temp=1;
     break;
    }
  }
   if(temp)
    break;
  }
}

New Code Made by me: (GPS Module with DMD P10 Display)

// Inserting File Library
#include <SPI.h>
#include <DMD2.h>
#include <fonts/Arial_Black_16.h>
#include <SoftwareSerial.h>
SoftwareSerial Serial1(3, 4); // RX, TX
char str[70];
char *test="$GPRMC";
int temp,i;

// Defining Function
#define Length 2                        
#define Width 1 
                        
// Declaration Function 
SoftDMD dmd(Length, Width);                  // Length x Width

// Declaration Variable
int Hour ;
int Minut ;
int Second ;
char dmdBuff[10];

void setup() 
{
  dmd.setBrightness(255);
  dmd.selectFont(Arial_Black_16);
  dmd.begin();
  dmd.clearScreen();
  Serial1.begin(9600);
}
void loop()
{
  serial1Event();
  if (temp) 
  {
    int str_lenth=i;
    int x=0,comma=0;
    String UTC_hour="";
    String UTC_minut="";
    String UTC_second="";
    String UTC_date="";
    String UTC_month="";
    String UTC_year="";
    String str1="";
    while(x<str_lenth)
    {
     if(str[x]==',')
     comma++;
      if(comma==1)
      {
        x++;
        UTC_hour+=str[x++];
        UTC_hour+=str[x++];
        UTC_minut+=str[x++];
        UTC_minut+=str[x++];
        UTC_second+=str[x++];
        UTC_second+=str[x];
        comma=2;
      }
      if(comma==10)
      {
        x++;
          UTC_date+=str[x++];
          UTC_date+=str[x++];
          UTC_month+=str[x++];
          UTC_month+=str[x++];
          UTC_year+=str[x++];
          UTC_year+=str[x];
      }  
      x++;
    }
    int UTC_hourDec=UTC_hour.toInt();
    int UTC_minutDec=UTC_minut.toInt();
    int Second=UTC_second.toInt();
    int Date=UTC_date.toInt();
    int Month=UTC_month.toInt();
    int Year=UTC_year.toInt();
    int Hour=UTC_hourDec+6;
    if(Hour>23)
    {
     Hour-=24;
     Date+=1;
    }
    int Minut=UTC_minutDec+00;
    if(Minut>59)
    Minut-=60;


   // UTC_ind_zone_time    
    sprintf(dmdBuff,"%2d:%2d:%2d",Hour,Minut,Second);
    dmd.drawString(0,1,dmdBuff);
    
  //  delay(100);
    temp=0;
//    j=0;
    i=0;
    x=0;
    str_lenth=0;
//    k=0;
  }
 // delay(1000);
}

void serial1Event()
{
  while(1)
  {
   while (Serial1.available())            //checking serial data from GPS
   {
    char inChar = (char)Serial1.read();
     str[i]= inChar;                    //store data from GPS into str[]
     i++;
     if (i < 7)                      
     {
      if(str[i-1] != test[i-1])         //checking for $GPRMC sentence
      {
        i=0;
      }
     }
    if(i>65)
    {
     temp=1;
     break;
    }
  }
   if(temp)
    break;
  }
}

Are there any examples with the DMD2 library ?
If so, do they work ?

UKHeliBob:
Are there any examples with the DMD2 library ?
If so, do they work ?

I made the code by seeing DMD2 library example.
but i can't find the reason why Output don't show in P10 Display.

Sisir_Raihan:
I made the code by seeing DMD2 library example.
but i can't find the reason why Output don't show in P10 Display.

You didn't answer the question. Did you try running the unmodified library examples?

aarg:
You didn't answer the question. Did you try running the unmodified library examples?

Unmodified DMD2 library works. But DMD2 Library don't have any Clock Readout Demo or Clock Demo!

Presumably the examples output variables to the screen and that is all you want to do, so what have you done differently to the examples ?

I can't see a problem with your sketch, but the DMD2 Countdown example is a good place to start. It uses a DMS_TextBox to output the countdown value with print statements. I'm not sure about the X-Y coordinates for drawString:

    dmd.drawString(0,1,dmdBuff);

I wonder if that shouldn't be at (0,0) instead:

    dmd.drawString(0,0,dmdBuff);

Don't name the software serial port "Serial1":

    SoftwareSerial Serial1(3, 4); // RX, TX

That is a reserved variable name on other Arduino boards. Call it something meaningful, like "gpsPort".

And you really should avoid the String class. Lots of reasons here, required reading here.

Here's a way to do it without using the String class, and by using my NeoGPS library:

// Inserting File Library
#include <SPI.h>
#include <DMD2.h>
#include <NMEAGPS.h>
#include <fonts/Arial_Black_16.h>

// PICK ONE OF THESE PORT ALTERNATIVES
//
// BEST: connect GPS to pins 0 & 1, since you're not using Serial.
//             Requires disconnecting pin 0 to upload new sketch over USB.
#define gpsPort Serial // just an alias for Serial

// 2nd BEST: connect GPS to pins 8 & 9 (on an UNO)
//#include <AltSoftSerial.h>
//AltSoftSerial gpsPort

// 3rd BEST:
//#include <NeoSWSerial.h>
//NeoSWSerial gpsPort(3, 4); // RX, TX

// WORST: SoftwareSerial NOT RECOMMENDED

// Defining Constants
#define Length 2
#define Width 1

// Declaration Variable
SoftDMD dmd(Length, Width);                  // Length x Width

NMEAGPS gps; // parser

void setup()
{
  dmd.setBrightness(255);
  dmd.selectFont(Arial_Black_16);
  dmd.begin();
  dmd.clearScreen();

  gpsPort.begin(9600);
}

void loop()
{
  if (gps.available( gpsPort )) {
    gps_fix fix = gps.read();

    if (fix.valid.time) {
      // UTC_ind_zone_time
      char dmdBuff[10];

      sprintf_P( dmdBuff, PSTR("%02d:%02d:%02d"),
                 fix.dateTime.hours, fix.dateTime.minutes, fix.dateTime.seconds );
      dmd.drawString(0,1,dmdBuff);
    }
  }
}

Your original program uses 12406 bytes of program space and 321 bytes of RAM.
The NeoGPS version uses 11584 bytes of program space and 270 bytes of RAM (Optimized. Standard config uses 14106/337).

The NeoGPS library also has methods for shifting the GPS date/time into your local timezone. See NMEAtimezone.ino.

If you want to try it, NeoGPS is available from the Arduino IDE Library Manager, under the menu Sketch -> Include Library -> Manage Libraries. Even if you don't use it, there is lots of information on the Installation and Troubleshooting pages. Be sure to read the section on choosing a serial port.

Cheers,
/dev

UKHeliBob:
Presumably the examples output variables to the screen and that is all you want to do, so what have you done differently to the examples ?

I was done same as examples output variable. But couldn't find the reason why output didn't came. :frowning:

Please post one of the simple examples here that you know works OK then we can compare it with the code where you have done the same as the example.

-dev:

// Inserting File Library

#include <SPI.h>
#include <DMD2.h>
#include <NMEAGPS.h>
#include <fonts/Arial_Black_16.h>

// PICK ONE OF THESE PORT ALTERNATIVES
//
// BEST: connect GPS to pins 0 & 1, since you're not using Serial.
//             Requires disconnecting pin 0 to upload new sketch over USB.
#define gpsPort Serial // just an alias for Serial

// 2nd BEST: connect GPS to pins 8 & 9 (on an UNO)
//#include <AltSoftSerial.h>
//AltSoftSerial gpsPort

// 3rd BEST:
//#include <NeoSWSerial.h>
//NeoSWSerial gpsPort(3, 4); // RX, TX

// WORST: SoftwareSerial NOT RECOMMENDED

// Defining Constants
#define Length 2
#define Width 1

// Declaration Variable
SoftDMD dmd(Length, Width);                  // Length x Width

NMEAGPS gps; // parser

void setup()
{
 dmd.setBrightness(255);
 dmd.selectFont(Arial_Black_16);
 dmd.begin();
 dmd.clearScreen();

gpsPort.begin(9600);
}

void loop()
{
 if (gps.available( gpsPort )) {
   gps_fix fix = gps.read();

if (fix.valid.time) {
     // UTC_ind_zone_time
     char dmdBuff[10];

sprintf_P( dmdBuff, PSTR("%02d:%02d:%02d"),
                fix.dateTime.hours, fix.dateTime.minutes, fix.dateTime.seconds );
     dmd.drawString(0,1,dmdBuff);
   }
 }
}



Your original program uses 12406 bytes of program space and 321 bytes of RAM.
The NeoGPS version uses 11584 bytes of program space and 270 bytes of RAM (Optimized. Standard config uses 14106/337).

The NeoGPS library also has methods for shifting the GPS date/time into your local timezone. See NMEAtimezone.ino.

If you want to try it, NeoGPS is available from the Arduino IDE Library Manager, under the menu **Sketch -> Include Library -> Manage Libraries**. Even if you don't use it, there is lots of information on the Installation and Troubleshooting pages. Be sure to read the section on [choosing a serial port](https://github.com/SlashDevin/NeoGPS/blob/master/extras/doc/Installing.md#2-choose-a-serial-port).

Cheers,
/dev

Thank you So Much for your Information. NeoGPS Library and your codes works like a Charm. :smiley:
Ouput shows when GPS detect. :slight_smile:
It shows UTC Time Zone. I need to show my time zone UTC+06:00.

Another Thing is About Clock font, I used Arial_Black_16 for Clock but it's not adjusting in Length 02 x Width 01 P10 Dipslay. I need a numeric font or a another font which Height 16 x Width 8. But i couldn't find it for DMD Library. :frowning:

-dev:

// Inserting File Library

#include <SPI.h>
#include <DMD2.h>
#include <NMEAGPS.h>
#include <fonts/Arial_Black_16.h>

// PICK ONE OF THESE PORT ALTERNATIVES
//
// BEST: connect GPS to pins 0 & 1, since you're not using Serial.
//            Requires disconnecting pin 0 to upload new sketch over USB.
#define gpsPort Serial // just an alias for Serial

// 2nd BEST: connect GPS to pins 8 & 9 (on an UNO)
//#include <AltSoftSerial.h>
//AltSoftSerial gpsPort

// 3rd BEST:
//#include <NeoSWSerial.h>
//NeoSWSerial gpsPort(3, 4); // RX, TX

// WORST: SoftwareSerial NOT RECOMMENDED

// Defining Constants
#define Length 2
#define Width 1

// Declaration Variable
SoftDMD dmd(Length, Width);                  // Length x Width

NMEAGPS gps; // parser

void setup()
{
  dmd.setBrightness(255);
  dmd.selectFont(Arial_Black_16);
  dmd.begin();
  dmd.clearScreen();

gpsPort.begin(9600);
}

void loop()
{
  if (gps.available( gpsPort )) {
    gps_fix fix = gps.read();

if (fix.valid.time) {
      // UTC_ind_zone_time
      char dmdBuff[10];

sprintf_P( dmdBuff, PSTR("%02d:%02d:%02d"),
                fix.dateTime.hours, fix.dateTime.minutes, fix.dateTime.seconds );
      dmd.drawString(0,1,dmdBuff);
    }
  }
}



Your original program uses 12406 bytes of program space and 321 bytes of RAM.
The NeoGPS version uses 11584 bytes of program space and 270 bytes of RAM (Optimized. Standard config uses 14106/337).

The NeoGPS library also has methods for shifting the GPS date/time into your local timezone. See NMEAtimezone.ino.

If you want to try it, NeoGPS is available from the Arduino IDE Library Manager, under the menu **Sketch -> Include Library -> Manage Libraries**. Even if you don't use it, there is lots of information on the Installation and Troubleshooting pages. Be sure to read the section on [choosing a serial port](https://github.com/SlashDevin/NeoGPS/blob/master/extras/doc/Installing.md#2-choose-a-serial-port).

Cheers,
/dev

Hello. :slight_smile:
With NeoGPS Library I made a GPS Clock and It's working like a Charm Till Now. Thanks a lot for NeoGPS Library.

GPS Clock Output is Digital Clock. Now i want to make a Analog Clock.
Can i do that with NeoGPS Library?

GPS Clock Output is Digital Clock. Now i want to make a Analog Clock.
Can i do that with NeoGPS Library?

The NeoGPS library has nothing to do with how you display the data, that is up to you.

Given the current hour, minute and second you can work out how many degrees each clock hand is around the 360 degree clockface and you know where the centre is and how long/which colour you want each hand to be so can draw them

Can i do that with NeoGPS Library?

Certainly.

UKHeliBob:
The NeoGPS library has nothing to do with how you display the data, that is up to you.

Given the current hour, minute and second you can work out how many degrees each clock hand is around the 360 degree clockface and you know where the centre is and how long/which colour you want each hand to be so can draw them

How i do that? Can you explain me it in details.

PaulS:
Certainly.

What should i do for it? I'm stuck on it. :frowning:

Now i want to make a Analog Clock.

What display device are you using ?

Can you draw a line between 2 points on the display ?

UKHeliBob:
What display device are you using ?

I'm using same display DMD P10 Display.

UKHeliBob:
Can you draw a line between 2 points on the display ?

No. :frowning:

Not in the same length and width before.

In Previous Program Length was 2, Width was 1.

Now Length will be 4, Width will be 4. It will be a Square Analog Clock.

In Previous Program Length was 2, Width was 1.

That's a very short line