Project #25 - Movement - GPS Receiver - Mk11

Project #25 - Movement - GPS Receiver - Mk11

 

https://www.donluc.com/?p=4312

 

https://youtu.be/pi61krX7bnw

 

#DonLucElectronics #DonLuc #GPS #RTC #EEPROM #Compass #Accelerometer #Movement #ESP32 #Bluetooth #Elecrow #DFRobot #Arduino #Project #Patreon #Electronics #Microcontrollers #IoT #Fritzing #Programming #Consultant

Global Positioning System (GPS)

 

The Global Positioning System (GPS) is a satellite-based radionavigation system owned by the United States and operated by the United States Space Force. It is one of the global navigation satellite systems (GNSS) that provides geolocation and time information to a GPS receiver anywhere on or near the Earth where there is an unobstructed line of sight to four or more GPS satellites. Obstacles such as mountains and buildings block the relatively weak GPS signals.

 

GPS Receiver - GP-20U7

 

The GP-20U7 is a compact GPS receiver with a built-in high performances All-In-One GPS chipset. The GP-20U7 accurately provides position, velocity, and time readings as well possessing high sensitivity and tracking capabilities. Thanks to the low power consumption this receiver requires, the GP-20U7 is ideal for portable applications such as tablet PCs, smart phones, and other devices requiring positioning capability.

 

DL2502Mk03

 

1 x DFRobot FireBeetle 2 ESP32-E
1 x Fermion: 2.0" 320x240 IPS TFT LCD
1 x GDL Line 10 CM
1 x Crowtail - I2C Hub 2.0
1 x GPS Receiver - GP-20U7
1 x Adafruit DS3231 Precision RTC FeatherWing
1 x CR1220 Battery
1 x Crowtail - 3-Axis Digital Compass
1 x Crowtail - 3-Axis Digital Accelerometer
1 x Lithium Ion Battery - 1000mAh
1 x Switch
1 x Bluetooth Serial Terminal
1 x USB 3.1 Cable A to C

 

FireBeetle 2 ESP32-E

 

SCL - 22
SDA - 21
GPR - 0
GPT - 2
DC - D2
CS - D6
RST - D3
RX2 - Bluetooth
TX2 - Bluetooth
VIN - +3.3V
GND - GND

 

DL2502Mk03p

 

DL2502Mk03p.ino

CODE
/****** Don Luc Electronics © ******
Software Version Information
Project #25 - Movement - GPS Receiver - Mk11
25-11
DL2502Mk03p.ino
DL2502Mk03
1 x DFRobot FireBeetle 2 ESP32-E
1 x Fermion: 2.0" 320x240 IPS TFT LCD
1 x GDL Line 10 CM
1 x Crowtail - I2C Hub 2.0
1 x GPS Receiver - GP-20U7
1 x Adafruit DS3231 Precision RTC FeatherWing
1 x CR1220 Battery
1 x Crowtail - 3-Axis Digital Compass
1 x Crowtail - 3-Axis Digital Accelerometer
1 x Lithium Ion Battery - 1000mAh
1 x Switch
1 x Bluetooth Serial Terminal
1 x USB 3.1 Cable A to C
*/

// Include the Library Code
// EEPROM Library to Read and Write EEPROM
// with Unique ID for Unit
#include "EEPROM.h"
// Arduino
#include <Arduino.h>
// Wire
#include <Wire.h>
// DFRobot Display GDL API
#include <DFRobot_GDL.h>
// Bluetooth Serial
#include "BluetoothSerial.h"
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif
// Accelemeter ADXL345
#include <ADXL345.h>
// Compass HMC5883L
#include <HMC5883L.h>
// RTC (Real-Time Clock)
#include "RTClib.h"
// GPS Receiver
#include <TinyGPS++.h>
// ESP32 Hardware Serial
#include <HardwareSerial.h>

// ESP32 HardwareSerial
HardwareSerial tGPS(1);

// GPS Receiver
#define gpsRXPIN 0
// This one is unused and doesnt have a conection
#define gpsTXPIN 2
// The TinyGPS++ object
TinyGPSPlus gps;
// Latitude
float TargetLat;
// Longitude
float TargetLon;
// GPS Date, Time, Speed, Altitude
// GPS Date
String TargetDat;
// GPS Time
String TargetTim;
// GPS Speeds M/S
String TargetSMS;
// GPS Speeds Km/h
String TargetSKH;
// GPS Altitude Meters
String TargetALTM;
// GPS Altitude Feet
String TargetALTF;
// GPS Status
String GPSSt = "";

// RTC (Real-Time Clock)
RTC_DS3231 rtc;
String dateRTC = "";
String timeRTC = "";

// Compass HMC5883L
HMC5883L compass;
// Heading
float heading;
// Heading Degrees
float headingDegrees;

// Variable ADXL345 library
ADXL345 adxl;
// Accelerometer ADXL345
// x, y, z
int x;
int y;
int z;
// Standard Gravity
// xyz
double xyz[3];
double ax;
double ay;
double az;

// FullString
String FullString = "";

// Bluetooth Serial
BluetoothSerial SerialBT;

// Defined ESP32
#define TFT_DC  D2
#define TFT_CS  D6
#define TFT_RST D3

/*dc=*/ /*cs=*/ /*rst=*/
// DFRobot Display 240x320
DFRobot_ST7789_240x320_HW_SPI screen(TFT_DC, TFT_CS, TFT_RST);

// EEPROM Unique ID Information
#define EEPROM_SIZE 64
String uid = "";

// Software Version Information
String sver = "25-11";

void loop() {


  // Accelemeter ADXL345
  isADXL345();

  // Compass HMC5883L
  isHMC5883L();

  // isEEPROM
  isEEPROM();

  // RTC (Real-Time Clock)
  isRTC();

  // isGPS
  isGPS();

  // Accelemeter ADXL345 Compass HMC5883L Display
  isDisplayADXL345HMC5883L();

  // Delay 0.5 Second
  delay( 500 );

}

getAccelemeterADXL345.ino

CODE
// Accelemeter ADXL345
// Setup Accelemeter ADXL345
void isSetupADXL345(){

  // Power On
  adxl.powerOn();

  // Set activity inactivity thresholds (0-255)
  // 62.5mg per increment
  adxl.setActivityThreshold(75);
  // 62.5mg per increment
  adxl.setInactivityThreshold(75);
  // How many seconds of no activity is inactive?
  adxl.setTimeInactivity(10);
 
  //look of activity movement on this axes - 1 == on; 0 == off 
  adxl.setActivityX(1);
  adxl.setActivityY(1);
  adxl.setActivityZ(1);
 
  //look of inactivity movement on this axes - 1 == on; 0 == off
  adxl.setInactivityX(1);
  adxl.setInactivityY(1);
  adxl.setInactivityZ(1);
 
  // Look of tap movement on this axes - 1 == on; 0 == off
  adxl.setTapDetectionOnX(0);
  adxl.setTapDetectionOnY(0);
  adxl.setTapDetectionOnZ(1);
 
  // Set values for what is a tap, and what is a double tap (0-255)
  // 62.5mg per increment
  adxl.setTapThreshold(50);
  // 625us per increment
  adxl.setTapDuration(15);
  // 1.25ms per increment
  adxl.setDoubleTapLatency(80);
  // 1.25ms per increment
  adxl.setDoubleTapWindow(200);
 
  // set values for what is considered freefall (0-255)
  // (5 - 9) recommended - 62.5mg per increment
  adxl.setFreeFallThreshold(7);
  // (20 - 70) recommended - 5ms per increment
  adxl.setFreeFallDuration(45);
 
  // Setting all interrupts to take place on int pin 1
  // I had issues with int pin 2, was unable to reset it
  adxl.setInterruptMapping( ADXL345_INT_SINGLE_TAP_BIT,   ADXL345_INT1_PIN );
  adxl.setInterruptMapping( ADXL345_INT_DOUBLE_TAP_BIT,   ADXL345_INT1_PIN );
  adxl.setInterruptMapping( ADXL345_INT_FREE_FALL_BIT,    ADXL345_INT1_PIN );
  adxl.setInterruptMapping( ADXL345_INT_ACTIVITY_BIT,     ADXL345_INT1_PIN );
  adxl.setInterruptMapping( ADXL345_INT_INACTIVITY_BIT,   ADXL345_INT1_PIN );
 
  // Register interrupt actions - 1 == on; 0 == off  
  adxl.setInterrupt( ADXL345_INT_SINGLE_TAP_BIT, 1);
  adxl.setInterrupt( ADXL345_INT_DOUBLE_TAP_BIT, 1);
  adxl.setInterrupt( ADXL345_INT_FREE_FALL_BIT,  1);
  adxl.setInterrupt( ADXL345_INT_ACTIVITY_BIT,   1);
  adxl.setInterrupt( ADXL345_INT_INACTIVITY_BIT, 1);

}
// Accelemeter ADXL345
void isADXL345(){

  // Read the accelerometer values and store them in variables  x,y,z
  adxl.readXYZ(&x, &y, &z);

  // Output
  // FullString
  // ************
  FullString = "************\r\n";
  // FullString Bluetooth Serial + Serial
  for(int i = 0; i < FullString.length(); i++)
  {
    
    // Bluetooth Serial
    SerialBT.write(FullString.c_str()[i]);
    // Serial
    Serial.write(FullString.c_str()[i]);
       
  }
  
  // FullString
  FullString = "Values of X , Y , Z: " + String(x) + " , " + 
  String(y) + " , " + String(z) + + "\r\n";

  // FullString Bluetooth Serial + Serial
  for(int i = 0; i < FullString.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullString.c_str()[i]);
    // Serial
    Serial.write(FullString.c_str()[i]);
    
  }
  
  // Standard Gravity
  // Acceleration
  adxl.getAcceleration(xyz);

  // Output
  ax = xyz[0];
  ay = xyz[1];
  az = xyz[2];
  
  // FullString
  // ************
  FullString = "************\r\n";
  // FullString Bluetooth Serial + Serial
  for(int i = 0; i < FullString.length(); i++)
  {
    
    // Bluetooth Serial
    SerialBT.write(FullString.c_str()[i]);
    // Serial
    Serial.write(FullString.c_str()[i]);
       
  }

  // FullString
  // xg
  FullString = "X = " + String(ax) + " g" + "\r\n";
  // FullString Bluetooth Serial + Serial
  for(int i = 0; i < FullString.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullString.c_str()[i]);
    // Serial
    Serial.write(FullString.c_str()[i]);
    
  }
  // yg
  FullString = "y = " + String(ay) + " g" + "\r\n";
  // FullString Bluetooth Serial + Serial
  for(int i = 0; i < FullString.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullString.c_str()[i]);
    // Serial
    Serial.write(FullString.c_str()[i]);
    
  }
  // zg
  FullString = "z = " + String(az) + " g" + "\r\n";
  // FullString Bluetooth Serial + Serial
  for(int i = 0; i < FullString.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullString.c_str()[i]);
    // Serial
    Serial.write(FullString.c_str()[i]);
    
  }

}

getCompassHMC5883L.ino

CODE
// HMC5883L Triple Axis Digital Compass
// Setup HMC5883L
void isSetupHMC5883L(){

  // Initialize Initialize HMC5883L
  compass.begin();

  // Set measurement range
  compass.setRange(HMC5883L_RANGE_1_3GA);

  // Set measurement mode
  compass.setMeasurementMode(HMC5883L_CONTINOUS);

  // Set data rate
  compass.setDataRate(HMC5883L_DATARATE_30HZ);

  // Set number of samples averaged
  compass.setSamples(HMC5883L_SAMPLES_8);

  // Set calibration offset
  compass.setOffset(0, 0);
  
}
// Compass HMC5883L
void isHMC5883L(){

  // Vector norm
  Vector norm = compass.readNormalize();

  // Calculate heading
  heading = atan2(norm.YAxis, norm.XAxis);

  // Set declination angle on your location and fix heading
  // You can find your declination on: http://magnetic-declination.com/
  // (+) Positive or (-) for negative
  // Latitude: 32° 39' 7.9" N
  // Longitude: 115° 28' 6.2" W
  // Magnetic Declination: +10° 35'
  // Declination is POSITIVE (EAST)
  // Inclination: 58° 4'
  // Magnetic field strength: 45759.1 nT
  // Formula: (deg + (min / 60.0)) / (180 / M_PI);
  float declinationAngle = (10.0 + (35.0 / 60.0)) / (180 / M_PI);
  heading += declinationAngle;

  // Correct for heading < 0deg and heading > 360deg
  if (heading < 0)
  {
    heading += 2 * PI;
  }

  if (heading > 2 * PI)
  {
    heading -= 2 * PI;
  }

  // Convert to degrees
  headingDegrees = heading * 180/M_PI; 

  // Output
  // FullString
  // ************
  FullString = "************\r\n";
  // FullString Bluetooth Serial + Serial
  for(int i = 0; i < FullString.length(); i++)
  {
    
    // Bluetooth Serial
    SerialBT.write(FullString.c_str()[i]);
    // Serial
    Serial.write(FullString.c_str()[i]);
    
  }

  // FullString
  // Heading
  FullString = "Heading = " + String( heading ) + "\r\n";
  // FullString Bluetooth Serial + Serial
  for(int i = 0; i < FullString.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullString.c_str()[i]);
    // Serial
    Serial.write(FullString.c_str()[i]);
    
  }

  // FullString
  // Degress
  FullString = "Degress = " + String( headingDegrees ) + "\r\n";
  // FullString Bluetooth Serial + Serial
  for(int i = 0; i < FullString.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullString.c_str()[i]);
    // Serial
    Serial.write(FullString.c_str()[i]);
    
  }
  
}

getDisplay.ino

CODE
// DFRobot Display 240x320
// DFRobot Display 240x320 - UID
void isDisplayUID(){

  // DFRobot Display 240x320
  // Text Display
  // Text Wrap
  screen.setTextWrap(false);
  // Rotation
  screen.setRotation(3);
  // Fill Screen => black
  screen.fillScreen(0x0000);
  // Text Color => white
  screen.setTextColor(0xffff);
  // Font => Free Sans Bold 12pt
  screen.setFont(&FreeSansBold12pt7b);
  // TextSize => 1.5
  screen.setTextSize(1.5);
  // Don Luc Electronics
  screen.setCursor(0, 30);
  screen.println("Don Luc Electronics");
  // GPS Receiver
  screen.setCursor(0, 60);
  screen.println("GPS Receiver");
  // Version
  screen.setCursor(0, 90);
  screen.println("Version");
  screen.setCursor(0, 120);
  screen.println( sver );
  // EEPROM
  screen.setCursor(0, 150);
  screen.println("EEPROM");
  screen.setCursor(0, 180);
  screen.println( uid );

}
// Accelemeter and Compass, ADXL345 and HMC5883L
void isDisplayADXL345HMC5883L(){

  // DFRobot Display 240x320
  // Text Display
  // Text Wrap
  screen.setTextWrap(false);
  // Rotation
  screen.setRotation(3);
  // Fill Screen => white
  screen.fillScreen(0xffff);
  // Text Color => blue
  screen.setTextColor(0x001F);
  // Font => Free Sans Bold 12pt
  screen.setFont(&FreeSansBold12pt7b);
  // TextSize => 1.5
  screen.setTextSize(1.5);
  // Accelemeter ADXL345
  screen.setCursor(0, 30);
  screen.println("Accelemeter ADXL345");
  // Accelemeter ADXL345 X
  screen.setCursor(0, 60);
  screen.println("X: ");
  screen.setCursor(40, 60);
  screen.println( x );
  // Accelemeter ADXL345 Y
  screen.setCursor(0, 90);
  screen.println( "Y: " );
  screen.setCursor(40, 90);
  screen.println( y );
  // Accelemeter ADXL345 Z
  screen.setCursor(0, 120);
  screen.println( "Z: " );
  screen.setCursor(40, 120);
  screen.println( z );
  // Compass HMC5883L
  screen.setCursor(0, 150);
  screen.println( "Compass HMC5883L" );
  // Heading
  screen.setCursor(0, 180);
  screen.println( "Heading = " );
  screen.setCursor(130, 180);
  screen.println( heading );
  // Degress
  screen.setCursor(0, 210);
  screen.println( "Degress = " );
  screen.setCursor(130, 210);
  screen.println( headingDegrees );
  
}

getEEPROM.ino

CODE
// EEPROM
// isUID EEPROM Unique ID
void isUID() {
  
  // Is Unit ID
  uid = "";
  for (int x = 0; x < 7; x++)
  {
    uid = uid + char(EEPROM.read(x));
  }
  
}
// isEEPROM
void isEEPROM(){

  // FullString
  // ************
  FullString = "************\r\n";
  // FullString Bluetooth Serial + Serial
  for(int i = 0; i < FullString.length(); i++)
  {
    
    // Bluetooth Serial
    SerialBT.write(FullString.c_str()[i]);
    // Serial
    Serial.write(FullString.c_str()[i]);
    
  }

  // FullString
  // EEPROM
  FullString = "EEPROM = " + String( uid ) + "\r\n";
  // FullString Bluetooth Serial + Serial
  for(int i = 0; i < FullString.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullString.c_str()[i]);
    // Serial
    Serial.write(FullString.c_str()[i]);
    
  }
  
}

getGPS.ino

CODE
// GPS Receiver
// Setup GPS
void isSetupGPS() {

  // Setup GPS
  tGPS.begin(  9600 , SERIAL_8N1 , gpsRXPIN , gpsTXPIN );
  
}
// isGPS
void isGPS(){

  // Receives NEMA data from GPS receiver
  // This sketch displays information every time a new sentence is correctly encoded
  while ( tGPS.available() > 0)
    
    if (gps.encode( tGPS.read() ))
    {
     
       // GPS Vector Pointer Target
       displayInfo();
       // GPS Date, Time, Speed, Altitude
       displayDTS();
       
    }
  
  if (millis() > 5000 && gps.charsProcessed() < 10)
  {
   
     while(true);
    
  }

}
// GPS Vector Pointer Target
void displayInfo(){

  // Location
  if (gps.location.isValid())
  {
    
     // Latitude
     TargetLat = gps.location.lat();
     // Longitude
     TargetLon = gps.location.lng();
     // GPS Status 2
     GPSSt = "Yes";
    
  }
  else
  {

     // GPS Status 0
     GPSSt = "No";
    
  }

  // FullString
  // ************
  FullString = "************\r\n";
  // FullString Bluetooth Serial + Serial
  for(int i = 0; i < FullString.length(); i++)
  {
    
    // Bluetooth Serial
    SerialBT.write(FullString.c_str()[i]);
    // Serial
    Serial.write(FullString.c_str()[i]);
    
  }

  // FullString
  // Latitude
  FullString = "Latitude = " + String( TargetLat ) + "\r\n";
  // FullString Bluetooth Serial + Serial
  for(int i = 0; i < FullString.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullString.c_str()[i]);
    // Serial
    Serial.write(FullString.c_str()[i]);
    
  }

  // FullString
  // Longitude
  FullString = "Longitude = " + String( TargetLon ) + "\r\n";
  // FullString Bluetooth Serial + Serial
  for(int i = 0; i < FullString.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullString.c_str()[i]);
    // Serial
    Serial.write(FullString.c_str()[i]);
    
  }

  // FullString
  // GPS Status
  FullString = "GPS Status = " + String( GPSSt ) + "\r\n";
  // FullString Bluetooth Serial + Serial
  for(int i = 0; i < FullString.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullString.c_str()[i]);
    // Serial
    Serial.write(FullString.c_str()[i]);
    
  }


}
// GPS Date, Time, Speed, Altitude
void displayDTS(){

  // FullString
  // ************
  FullString = "************\r\n";
  // FullString Bluetooth Serial + Serial
  for(int i = 0; i < FullString.length(); i++)
  {
    
    // Bluetooth Serial
    SerialBT.write(FullString.c_str()[i]);
    // Serial
    Serial.write(FullString.c_str()[i]);
    
  }
  
  // Date
  TargetDat = ""; 
  if (gps.date.isValid())
  {
    
     // Date
     // Year
     TargetDat += String(gps.date.year(), DEC);
     TargetDat += "/";
     // Month
     TargetDat += String(gps.date.month(), DEC);
     TargetDat += "/";
     // Day
     TargetDat += String(gps.date.day(), DEC);
    
  }

  // Date
  FullString = "Date = " + String( TargetDat ) + "\r\n";
  // FullString Bluetooth Serial + Serial
  for(int i = 0; i < FullString.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullString.c_str()[i]);
    // Serial
    Serial.write(FullString.c_str()[i]);
    
  }
  
  // Time
  TargetTim = "";
  if (gps.time.isValid())
  {
    
     // Time
     // Hour
     TargetTim += String(gps.time.hour(), DEC);
     TargetTim += ":";
     // Minute
     TargetTim += String(gps.time.minute(), DEC);
     TargetTim += ":";
     // Secound
     TargetTim += String(gps.time.second(), DEC);
    
  }

  // FullString
  // Time
  FullString = "Time = " + String( TargetTim ) + "\r\n";
  // FullString Bluetooth Serial + Serial
  for(int i = 0; i < FullString.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullString.c_str()[i]);
    // Serial
    Serial.write(FullString.c_str()[i]);
    
  }
  
  // Speed
  TargetSMS = "";
  TargetSKH = "";
  if (gps.speed.isValid())
  {
    
     // Speed
     // M/S
     int x = gps.speed.mps();
     TargetSMS = String( x, DEC);
     // Km/h
     int y = gps.speed.kmph();
     TargetSKH = String( y, DEC);

  }

  // FullString
  // GPS Speeds M/S
  FullString = "GPS Speeds M/S = " + String( TargetSMS ) + "\r\n";
  // FullString Bluetooth Serial + Serial
  for(int i = 0; i < FullString.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullString.c_str()[i]);
    // Serial
    Serial.write(FullString.c_str()[i]);
    
  }

  // FullString
  // GPS Speeds Km/h
  FullString = "GPS Speeds Km/h = " + String( TargetSKH ) + "\r\n";
  // FullString Bluetooth Serial + Serial
  for(int i = 0; i < FullString.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullString.c_str()[i]);
    // Serial
    Serial.write(FullString.c_str()[i]);
    
  }
  
  // Altitude
  TargetALTM = "";
  TargetALTF = "";
  if (gps.altitude.isValid())
  {
    
     // Altitude
     // Meters
     int z = gps.altitude.meters();
     TargetALTM = String( z, DEC);
     // Feet
     int zz = gps.altitude.feet();
     TargetALTF = String( zz, DEC);

  }

  // FullString
  //GPS Altitude Meters
  FullString = "GPS Altitude Meters = " + String( TargetALTM ) + "\r\n";
  // FullString Bluetooth Serial + Serial
  for(int i = 0; i < FullString.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullString.c_str()[i]);
    // Serial
    Serial.write(FullString.c_str()[i]);
    
  }

  // FullString
  // GPS Altitude Feet
  FullString = "GPS Altitude Feet = " + String( TargetALTF ) + "\r\n";
  // FullString Bluetooth Serial + Serial
  for(int i = 0; i < FullString.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullString.c_str()[i]);
    // Serial
    Serial.write(FullString.c_str()[i]);
    
  }
  
}

getRTC.ino

CODE
// RTC (Real-Time Clock)
// Setup RTC
void isSetupRTC(){

  // RTC (Real-Time Clock)
  rtc.begin();
  
  // RTC Lost Power
  if (rtc.lostPower()) {
 
    // 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))
    
  }
  
}
// RTC (Real-Time Clock)
void isRTC(){

  // RTC (Real-Time Clock)
  DateTime now = rtc.now();
  
  // Date
  dateRTC = now.year(), DEC; 
  dateRTC = dateRTC + "/";
  dateRTC = dateRTC + now.month(), DEC;
  dateRTC = dateRTC + "/";
  dateRTC = dateRTC + now.day(), DEC;
  
  // Time
  timeRTC = now.hour(), DEC;
  timeRTC = timeRTC + ":";
  timeRTC = timeRTC + now.minute(), DEC;
  timeRTC = timeRTC + ":";
  timeRTC = timeRTC + now.second(), DEC;

  // FullString
  // ************
  FullString = "************\r\n";
  // FullString Bluetooth Serial + Serial
  for(int i = 0; i < FullString.length(); i++)
  {
    
    // Bluetooth Serial
    SerialBT.write(FullString.c_str()[i]);
    // Serial
    Serial.write(FullString.c_str()[i]);
    
  }

  // FullString
  // Date
  FullString = "Date = " + String( timeRTC ) + "\r\n";
  // FullString Bluetooth Serial + Serial
  for(int i = 0; i < FullString.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullString.c_str()[i]);
    // Serial
    Serial.write(FullString.c_str()[i]);
    
  }

  // FullString
  // Time
  FullString = "Time = " + String( dateRTC ) + "\r\n";
  // FullString Bluetooth Serial + Serial
  for(int i = 0; i < FullString.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullString.c_str()[i]);
    // Serial
    Serial.write(FullString.c_str()[i]);
    
  }

  // FullString
  // Temperature
  FullString = "Temperature = " + String( rtc.getTemperature() ) 
  + String( " C" ) + "\r\n";
  // FullString Bluetooth Serial + Serial
  for(int i = 0; i < FullString.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullString.c_str()[i]);
    // Serial
    Serial.write(FullString.c_str()[i]);
    
  }

}

setup.ino

CODE
// Setup
void setup()
{
 
  // Serial Begin
  Serial.begin(115200);
  Serial.println("Starting BLE work!");

  // Bluetooth Serial
  SerialBT.begin("DL2502Mk03");
  Serial.println("Bluetooth Started! Ready to pair...");

  // Delay
  delay( 100 );

  // EEPROM Size
  EEPROM.begin(EEPROM_SIZE);
  
  // EEPROM Unique ID
  isUID();
  
  // Delay
  delay(100);

  // Wire
  Wire.begin();

  // Delay
  delay(100);
  
  // Setup RTC
  isSetupRTC();
  
  // Delay
  delay(100);
  
  // DFRobot Display 240x320
  screen.begin();

  // Delay
  delay(100);

  // Setup Accelemeter ADXL345
  isSetupADXL345();

  // Setup HMC5883L
  isSetupHMC5883L();

  // Delay
  delay( 100 );

  // GPS Receiver
  // Setup GPS
  isSetupGPS();

  // Delay
  delay( 100 );

  // DFRobot Display 240x320 - UID
  // Don Luc Electronics
  // Version
  isDisplayUID();

  // Delay 5 Second
  delay( 5000 );

}

People can contact us: http://www.donluc.com/?page_id=1927

 

Electronics, IoT, Teacher, Instructor, R&D and Consultant

 

-Programming Language
-Microcontrollers (PIC, Arduino, Raspberry Pi, Arm, Silicon Labs, Espressif, Etc...)
-IoT
-Wireless (Radio Frequency, Bluetooth, WiFi, Etc...)
-Robotics
-Automation
-Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
-Unmanned Vehicles Terrestrial and Marine
-Machine Learning
-Artificial Intelligence (AI)
-RTOS
-Sensors, eHealth Sensors, Biosensor, and Biometric
-Research & Development (R & D)
-Consulting
-Etc...

 

Follow Us

 

Luc Paquin – Curriculum Vitae - 2025
https://www.donluc.com/luc/

 

Web: https://www.donluc.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/@thesass2063
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/
Patreon: https://patreon.com/DonLucElectronics59
DFRobot: https://learn.dfrobot.com/user-10186.html
Elecrow: https://www.elecrow.com/share/sharepj/center/no/760816d385ebb1edc0732fd873bfbf13
TikTok: https://www.tiktok.com/@luc.paquin8
Twitch: https://www.twitch.tv/lucpaquin
LinkedIn: https://www.linkedin.com/in/jlucpaquin/

 

Don Luc

icon DL2502Mk03.zip 231KB Download(0)
License
All Rights
Reserved
licensBg
0