The Alpha Geek – Geeking Out

Arduino

Arduino

Project #15: Environment – Serial Camera – Mk29

——

#DonLucElectronics #DonLuc #Arduino #Camera #SD #RTC #EEPROM #Display #Elecrow #Project #Patreon #Electronics #Microcontrollers #IoT #Fritzing #Programming #Consultant

——

Serial Camera

——

Serial Camera

——

Serial Camera

——

Crowtail – Serial Camera

The Crowtail Serial Camera is a JPEG color camera module easy for PC and MCU use. It has integrated image processing DSP to generate 320 x 240 or 640 x 480 JPEG images without thumbnail information, captured pictures will be stored in the internal buffer and transferred via UART port. The UART Can be configured to TTL or CMOS by hardware.

  • -Crowtail interface
  • -Default baud rate of the serial port is 38400
  • -640 x 480 or 320 x 240 resolution
  • -JPEG compressed image without Thumbnail Information
  • -5 Volt power supply

DL2503Mk02

1 x Crowduino Uno – SD
1 x Crowtail – Base Shield
1 x Crowtail – Serial Camera
1 x Crowtail – Button 2.0
1 x MicroSD Card 4 Gb
1 x Crowtail – RTC 2.0
1 x CR1220 Battery
1 x Crowtail – LED(Green)
1 x USB Battery Pack
1 x USB Mini-B Cable

Crowduino Uno – SD

SCL – A5
SDA – A4
SCK – 12
MISO – 11
MOSI – 10
CS – 4
BUT – 9
LEDG – 6
VIN – +5V
GND – GND

DL2503Mk02p

DL2503Mk02p.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
/****** Don Luc Electronics © ******
Software Version Information
Project #15: Environment – Serial Camera – Mk29
DL2503Mk02p.ino
DL2503Mk02
1 x Crowduino Uno - SD
1 x Crowtail - Base Shield
1 x Crowtail - Serial Camera
1 x Crowtail - Button 2.0
1 x MicroSD Card 4 Gb
1 x Crowtail - RTC 2.0
1 x CR1220 Battery
1 x Crowtail - LED(Green)
1 x USB Battery Pack
1 x USB Mini-B Cable
*/
// Include the Library Code
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>
// Wire
#include <Wire.h>
// Liquid Crystal
#include "LiquidCrystal.h"
// RTC (Real-Time Clock)
#include "RTClib.h"
// Secure Digital (SD Card)
#include <SD.h>
#include <SPI.h>
// Serial Camera
#include <Adafruit_VC0706.h>
// Software Serial
#include <SoftwareSerial.h>
// Camera TX connected to pin 2
// Camera RX to pin 3:
SoftwareSerial cameraconnection = SoftwareSerial(2, 3);
// Serial Camera
Adafruit_VC0706 cam = Adafruit_VC0706(&cameraconnection);
// Create an image with the name DLEPxxx.JPG
char filename[13];
// Secure Digital (SD Card)
const int chipSelect = 4;
String zzzzzz = "";
// Button
int iButton = 9;
// Variable for reading the Button status
int iButtonState = 0;
// RTC (Real-Time Clock)
RTC_DS1307 RTC;
String dateRTC = "";
String timeRTC = "";
// Liquid Crystal
// Connect via i2c
LiquidCrystal lcd(0);
// LED Green
int iLEDGreen = 6;
// EEPROM Unique ID Information
String uid = "";
// Software Version Information
String sver = "15-29";
void loop() {
// RTC (Real-Time Clock)
isRTC();
// Display RTC
isDisplayRTC();
// Read the state of the Switch value
iButtonState = digitalRead(iButton);
// The Button is HIGH:
if (iButtonState == HIGH) {
// LED Green HIGH
digitalWrite(iLEDGreen, HIGH);
// Camera
isCamera();
// MicroSD Card
isSD();
// LED Green LOW
digitalWrite(iLEDGreen, LOW);
} else {
// LED Green LOW
digitalWrite(iLEDGreen, LOW);
}
// Delay
delay( 500 );
}
/****** Don Luc Electronics © ****** Software Version Information Project #15: Environment – Serial Camera – Mk29 DL2503Mk02p.ino DL2503Mk02 1 x Crowduino Uno - SD 1 x Crowtail - Base Shield 1 x Crowtail - Serial Camera 1 x Crowtail - Button 2.0 1 x MicroSD Card 4 Gb 1 x Crowtail - RTC 2.0 1 x CR1220 Battery 1 x Crowtail - LED(Green) 1 x USB Battery Pack 1 x USB Mini-B Cable */ // Include the Library Code // EEPROM library to read and write EEPROM with unique ID for unit #include <EEPROM.h> // Wire #include <Wire.h> // Liquid Crystal #include "LiquidCrystal.h" // RTC (Real-Time Clock) #include "RTClib.h" // Secure Digital (SD Card) #include <SD.h> #include <SPI.h> // Serial Camera #include <Adafruit_VC0706.h> // Software Serial #include <SoftwareSerial.h> // Camera TX connected to pin 2 // Camera RX to pin 3: SoftwareSerial cameraconnection = SoftwareSerial(2, 3); // Serial Camera Adafruit_VC0706 cam = Adafruit_VC0706(&cameraconnection); // Create an image with the name DLEPxxx.JPG char filename[13]; // Secure Digital (SD Card) const int chipSelect = 4; String zzzzzz = ""; // Button int iButton = 9; // Variable for reading the Button status int iButtonState = 0; // RTC (Real-Time Clock) RTC_DS1307 RTC; String dateRTC = ""; String timeRTC = ""; // Liquid Crystal // Connect via i2c LiquidCrystal lcd(0); // LED Green int iLEDGreen = 6; // EEPROM Unique ID Information String uid = ""; // Software Version Information String sver = "15-29"; void loop() { // RTC (Real-Time Clock) isRTC(); // Display RTC isDisplayRTC(); // Read the state of the Switch value iButtonState = digitalRead(iButton); // The Button is HIGH: if (iButtonState == HIGH) { // LED Green HIGH digitalWrite(iLEDGreen, HIGH); // Camera isCamera(); // MicroSD Card isSD(); // LED Green LOW digitalWrite(iLEDGreen, LOW); } else { // LED Green LOW digitalWrite(iLEDGreen, LOW); } // Delay delay( 500 ); }
/****** Don Luc Electronics © ******
Software Version Information
Project #15: Environment – Serial Camera – Mk29
DL2503Mk02p.ino
DL2503Mk02
1 x Crowduino Uno - SD
1 x Crowtail - Base Shield
1 x Crowtail - Serial Camera
1 x Crowtail - Button 2.0
1 x MicroSD Card 4 Gb
1 x Crowtail - RTC 2.0
1 x CR1220 Battery
1 x Crowtail - LED(Green)
1 x USB Battery Pack
1 x USB Mini-B Cable
*/

// Include the Library Code
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>
// Wire
#include <Wire.h>
// Liquid Crystal
#include "LiquidCrystal.h"
// RTC (Real-Time Clock)
#include "RTClib.h"
// Secure Digital (SD Card)
#include <SD.h>
#include <SPI.h>
// Serial Camera
#include <Adafruit_VC0706.h>
// Software Serial
#include <SoftwareSerial.h>

// Camera TX connected to pin 2
// Camera RX to pin 3:
SoftwareSerial cameraconnection = SoftwareSerial(2, 3);

// Serial Camera
Adafruit_VC0706 cam = Adafruit_VC0706(&cameraconnection);

// Create an image with the name DLEPxxx.JPG
char filename[13];

// Secure Digital (SD Card)
const int chipSelect = 4;
String zzzzzz = "";

// Button
int iButton = 9;
// Variable for reading the Button status
int iButtonState = 0;

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

// Liquid Crystal
// Connect via i2c
LiquidCrystal lcd(0);

// LED Green
int iLEDGreen = 6;

// EEPROM Unique ID Information
String uid = "";

// Software Version Information
String sver = "15-29";

void loop() {

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

  // Display RTC
  isDisplayRTC();

  // Read the state of the Switch value
  iButtonState = digitalRead(iButton);

  // The Button is HIGH:
  if (iButtonState == HIGH) {

    // LED Green HIGH
    digitalWrite(iLEDGreen, HIGH);

    // Camera
    isCamera();
    
    // MicroSD Card
    isSD();

    // LED Green LOW
    digitalWrite(iLEDGreen, LOW);

  } else {

    // LED Green LOW
    digitalWrite(iLEDGreen, LOW);

  }

  // Delay
  delay( 500 );

}

getCamera.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// Camera
// Setup Camera
void isSetupCamera(){
// Setup Camera
cam.begin();
// Biggest
cam.setImageSize(VC0706_640x480);
}
// is Camera
void isCamera(){
// Camera Snap
cam.takePicture();
// File Name
strcpy(filename, "DLEP000.JPG");
for (int i = 0; i < 1000; i++) {
filename[4] = '0' + i/10;
filename[5] = '0' + i/10;
filename[6] = '0' + i%10;
// create if does not exist, do not open existing, write, sync after write
if (! SD.exists(filename)) {
break;
}
}
// Open the file for writing
File imgFile = SD.open(filename, FILE_WRITE);
// Get the size of the image (frame) taken
uint16_t jpglen = cam.frameLength();
// Time
int32_t time = millis();
pinMode(8, OUTPUT);
// Read all the data up to # bytes!
byte wCount = 0; // For counting # of writes
while (jpglen > 0) {
// read 32 bytes at a time;
uint8_t *buffer;
uint8_t bytesToRead = min(32, jpglen); // change 32 to 64 for a speedup but may not work with all setups!
buffer = cam.readPicture(bytesToRead);
imgFile.write(buffer, bytesToRead);
if(++wCount >= 64) { // Every 2K, give a little feedback so it doesn't appear locked up
//Serial.print('.');
wCount = 0;
}
//Serial.print("Read "); Serial.print(bytesToRead, DEC); Serial.println(" bytes");
jpglen -= bytesToRead;
}
// Close
imgFile.close();
}
// Camera // Setup Camera void isSetupCamera(){ // Setup Camera cam.begin(); // Biggest cam.setImageSize(VC0706_640x480); } // is Camera void isCamera(){ // Camera Snap cam.takePicture(); // File Name strcpy(filename, "DLEP000.JPG"); for (int i = 0; i < 1000; i++) { filename[4] = '0' + i/10; filename[5] = '0' + i/10; filename[6] = '0' + i%10; // create if does not exist, do not open existing, write, sync after write if (! SD.exists(filename)) { break; } } // Open the file for writing File imgFile = SD.open(filename, FILE_WRITE); // Get the size of the image (frame) taken uint16_t jpglen = cam.frameLength(); // Time int32_t time = millis(); pinMode(8, OUTPUT); // Read all the data up to # bytes! byte wCount = 0; // For counting # of writes while (jpglen > 0) { // read 32 bytes at a time; uint8_t *buffer; uint8_t bytesToRead = min(32, jpglen); // change 32 to 64 for a speedup but may not work with all setups! buffer = cam.readPicture(bytesToRead); imgFile.write(buffer, bytesToRead); if(++wCount >= 64) { // Every 2K, give a little feedback so it doesn't appear locked up //Serial.print('.'); wCount = 0; } //Serial.print("Read "); Serial.print(bytesToRead, DEC); Serial.println(" bytes"); jpglen -= bytesToRead; } // Close imgFile.close(); }
// Camera
// Setup Camera
void isSetupCamera(){

  // Setup Camera
  cam.begin();
  // Biggest
  cam.setImageSize(VC0706_640x480);
  
}
// is Camera
void isCamera(){

  // Camera Snap
  cam.takePicture();

  // File Name
  strcpy(filename, "DLEP000.JPG");
  for (int i = 0; i < 1000; i++) {
    
    filename[4] = '0' + i/10;
    filename[5] = '0' + i/10;
    filename[6] = '0' + i%10;
    
    // create if does not exist, do not open existing, write, sync after write
    if (! SD.exists(filename)) {
      break;
    }
    
  }
  
  // Open the file for writing
  File imgFile = SD.open(filename, FILE_WRITE);

  // Get the size of the image (frame) taken  
  uint16_t jpglen = cam.frameLength();

  // Time
  int32_t time = millis();
  pinMode(8, OUTPUT);
  
  // Read all the data up to # bytes!
  byte wCount = 0; // For counting # of writes
  while (jpglen > 0) {
    
    // read 32 bytes at a time;
    uint8_t *buffer;
    uint8_t bytesToRead = min(32, jpglen); // change 32 to 64 for a speedup but may not work with all setups!
    buffer = cam.readPicture(bytesToRead);
    imgFile.write(buffer, bytesToRead);
    if(++wCount >= 64) { // Every 2K, give a little feedback so it doesn't appear locked up
      //Serial.print('.');
      wCount = 0;
    }
    //Serial.print("Read ");  Serial.print(bytesToRead, DEC); Serial.println(" bytes");
    jpglen -= bytesToRead;
    
  }

  // Close
  imgFile.close();

}

getDisplay.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// getDisplay
// Crowbits - OLED 128X64 UID
// Display UID
void isDisplayUID(){
// Set up the LCD's number of rows and columns:
lcd.begin(16, 2);
// Print a message to the LCD.
// Cursor
lcd.setCursor(0, 0);
lcd.print("Don Luc Electron");
// Cursor
lcd.setCursor(0, 1);
// Print a message to the LCD.
lcd.print( sver );
}
// Display RTC
void isDisplayRTC(){
// Clear
lcd.clear();
// Set the cursor to column 0, line 0
lcd.setCursor(0, 0);
lcd.print( dateRTC );
// Set the cursor to column 0, line 1
lcd.setCursor(0, 1);
lcd.print( timeRTC );
}
// getDisplay // Crowbits - OLED 128X64 UID // Display UID void isDisplayUID(){ // Set up the LCD's number of rows and columns: lcd.begin(16, 2); // Print a message to the LCD. // Cursor lcd.setCursor(0, 0); lcd.print("Don Luc Electron"); // Cursor lcd.setCursor(0, 1); // Print a message to the LCD. lcd.print( sver ); } // Display RTC void isDisplayRTC(){ // Clear lcd.clear(); // Set the cursor to column 0, line 0 lcd.setCursor(0, 0); lcd.print( dateRTC ); // Set the cursor to column 0, line 1 lcd.setCursor(0, 1); lcd.print( timeRTC ); }
// getDisplay
// Crowbits - OLED 128X64 UID
// Display UID
void isDisplayUID(){

  // Set up the LCD's number of rows and columns: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  // Cursor
  lcd.setCursor(0, 0);
  lcd.print("Don Luc Electron");
  // Cursor
  lcd.setCursor(0, 1);
  // Print a message to the LCD.
  lcd.print( sver );

}
// Display RTC
void isDisplayRTC(){

  // Clear
  lcd.clear();
  // Set the cursor to column 0, line 0
  lcd.setCursor(0, 0);
  lcd.print( dateRTC );
  // Set the cursor to column 0, line 1
  lcd.setCursor(0, 1);
  lcd.print( timeRTC );
  
}

getEEPROM.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// EEPROM
// isUID EEPROM Unique ID
void isUID() {
// Is Unit ID
uid = "";
for (int x = 0; x < 7; x++)
{
uid = uid + char(EEPROM.read(x));
}
}
// EEPROM // isUID EEPROM Unique ID void isUID() { // Is Unit ID uid = ""; for (int x = 0; x < 7; x++) { uid = uid + char(EEPROM.read(x)); } }
// EEPROM
// isUID EEPROM Unique ID
void isUID() {
  
  // Is Unit ID
  uid = "";
  for (int x = 0; x < 7; x++)
  {
    uid = uid + char(EEPROM.read(x));
  }
  
}

getRTC.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// RTC (Real-Time Clock)
// Setup RTC
void isSetupRTC(){
// RTC (Real-Time Clock)
RTC.begin();
// RTC Running
if (! RTC.isrunning()) {
// following line sets the RTC to the date & time
//this sketch was compiled
RTC.adjust(DateTime(__DATE__, __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;
}
// RTC (Real-Time Clock) // Setup RTC void isSetupRTC(){ // RTC (Real-Time Clock) RTC.begin(); // RTC Running if (! RTC.isrunning()) { // following line sets the RTC to the date & time //this sketch was compiled RTC.adjust(DateTime(__DATE__, __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; }
// RTC (Real-Time Clock)
// Setup RTC
void isSetupRTC(){

  // RTC (Real-Time Clock)
  RTC.begin();

  // RTC Running
  if (! RTC.isrunning()) {
    
    // following line sets the RTC to the date & time
    //this sketch was compiled
    RTC.adjust(DateTime(__DATE__, __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;

}

getSD.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// MicroSD Card
// MicroSD Setup
void isSetupSD() {
// MicroSD Card
// See if the card is present and can be initialized:
if (!SD.begin(chipSelect)) {
// Don't do anything more:
while (1);
}
}
// MicroSD Card
void isSD() {
zzzzzz = "";
//DLE|EEPROM Unique ID|Version|Date|Time|filename|
zzzzzz = "DLE|" + uid + "|" + sver + "|" + String( dateRTC ) + "|"
+ String( timeRTC ) + "|" + filename + "|";
// Open the file. Note that only one file can be open at a time,
// so you have to close this one before opening another.
File dataFile = SD.open("dledata.txt", FILE_WRITE);
// If the file is available, write to it:
if (dataFile) {
// Write
dataFile.println( zzzzzz );
dataFile.close();
}
}
// MicroSD Card // MicroSD Setup void isSetupSD() { // MicroSD Card // See if the card is present and can be initialized: if (!SD.begin(chipSelect)) { // Don't do anything more: while (1); } } // MicroSD Card void isSD() { zzzzzz = ""; //DLE|EEPROM Unique ID|Version|Date|Time|filename| zzzzzz = "DLE|" + uid + "|" + sver + "|" + String( dateRTC ) + "|" + String( timeRTC ) + "|" + filename + "|"; // Open the file. Note that only one file can be open at a time, // so you have to close this one before opening another. File dataFile = SD.open("dledata.txt", FILE_WRITE); // If the file is available, write to it: if (dataFile) { // Write dataFile.println( zzzzzz ); dataFile.close(); } }
// MicroSD Card
// MicroSD Setup
void isSetupSD() {

    // MicroSD Card
   // See if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {

    // Don't do anything more:
    while (1);
    
  }

}
// MicroSD Card
void isSD() {

  zzzzzz = "";

  //DLE|EEPROM Unique ID|Version|Date|Time|filename|
  zzzzzz = "DLE|" + uid + "|" + sver + "|" + String( dateRTC ) + "|" 
  + String( timeRTC ) + "|" + filename + "|";

  // Open the file. Note that only one file can be open at a time,
  // so you have to close this one before opening another.
  File dataFile = SD.open("dledata.txt", FILE_WRITE);

  // If the file is available, write to it:
  if (dataFile) {
    
    // Write
    dataFile.println( zzzzzz );
    dataFile.close();

  }

}

setup.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// Setup
void setup()
{
// Delay
delay(100);
// isUID EEPROM Unique ID
isUID();
// Delay
delay(100);
// Initialize the LED LED Green
pinMode(iLEDGreen, OUTPUT);
// LED Green
digitalWrite(iLEDGreen, LOW);
// Delay
delay(100);
// Setup RTC
isSetupRTC();
// Delay
delay(100);
// MicroSD Card
isSetupSD();
// Delay
delay(100);
// Button
pinMode(iButton,INPUT);
// Delay
delay( 100 );
// Setup Camera
isSetupCamera();
// Delay
delay( 100 );
// Display UID
isDisplayUID();
// Delay 5 Second
delay( 5000 );
}
// Setup void setup() { // Delay delay(100); // isUID EEPROM Unique ID isUID(); // Delay delay(100); // Initialize the LED LED Green pinMode(iLEDGreen, OUTPUT); // LED Green digitalWrite(iLEDGreen, LOW); // Delay delay(100); // Setup RTC isSetupRTC(); // Delay delay(100); // MicroSD Card isSetupSD(); // Delay delay(100); // Button pinMode(iButton,INPUT); // Delay delay( 100 ); // Setup Camera isSetupCamera(); // Delay delay( 100 ); // Display UID isDisplayUID(); // Delay 5 Second delay( 5000 ); }
// Setup
void setup()
{
 
  // Delay
  delay(100);
  
  // isUID EEPROM Unique ID
  isUID();
  
  // Delay
  delay(100);

  // Initialize the LED LED Green
  pinMode(iLEDGreen, OUTPUT);
  // LED Green
  digitalWrite(iLEDGreen, LOW);

  // Delay
  delay(100);
  
  // Setup RTC
  isSetupRTC();
  
  // Delay
  delay(100);

  // MicroSD Card
  isSetupSD();
  
  // Delay
  delay(100);

  // Button
  pinMode(iButton,INPUT);

  // Delay
  delay( 100 );

  // Setup Camera
  isSetupCamera();

  // Delay
  delay( 100 );

  // Display UID
  isDisplayUID();
  
  // Delay 5 Second
  delay( 5000 );

}

——

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

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

  • Programming Language
  • Single-Board 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

Follow Us

Luc Paquin – Curriculum Vitae – 2024
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
Hackster.io: https://www.hackster.io/neosteam-labs
Elecrow: https://www.elecrow.com/share/sharepj/center/no/760816d385ebb1edc0732fd873bfbf13
TikTok: https://www.tiktok.com/@luc.paquin8
Twitch: https://www.twitch.tv/lucpaquin
Hackster: https://www.hackster.io/luc-paquin
LinkedIn: https://www.linkedin.com/in/jlucpaquin/

Don Luc

Project #15: Environment – SD – Mk28

——

#DonLucElectronics #DonLuc #Arduino #SD #RTC #EEPROM #DHT11 #ASM #Display #Elecrow #Project #Patreon #Electronics #Microcontrollers #IoT #Fritzing #Programming #Consultant

——

SD

——

SD

——

SD

——

Crowduino Uno – SD – SD Cards

There is a SD card slot on the Crowduino Uno – SD – SD Card board, with which you can easily use SD Card to record and thus to read data on the SD Card. The SD Card uses the SPI interface (D10/D11/D12) plus a CS Pin (D3 or D4) to cominicate with the main microcontroller Atmega328. First, Select the CS Pin you want to use with jumper. To make your project more flexible, you can select either the D3 or D4 pin as your CS pin for SD card. The default is D4. If your D4 have been applied for other modules, you can select the D3, but notice to modify related files in your program, which we will discuss later.

DL2502Mk06

1 x Crowduino Uno – SD
1 x Crowtail – Base Shield
1 x Crowtail – LED(Red)
1 x Crowtail – Button 2.0
1 x MicroSD Card 4 Gb
1 x Crowtail – RTC 2.0
1 x CR1220 Battery
1 x Crowtail – Temperature and Humidity Sensor 2.0
1 x Crowtail – Rotary Angle Sensor 2.0
1 x Crowtail – Moisture Sensor 2.0
1 x Crowtail – I2C LCD
1 x Crowtail – LED(Green)
1 x Crowtail – LED(Yellow)
1 x USB Battery Pack
1 x USB Mini-B Cable

Crowduino Uno – SD

SCL – A5
SDA – A4
POT – A1
ASM – A0
SCK – 12
MISO – 11
MOSI – 10
CS – 4
BUT – 9
LEDR – 8
LEDY – 7
LEDG – 6
ITH – 5
VIN – +5V
GND – GND

DL2502Mk06p

DL2502Mk06p.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
/****** Don Luc Electronics © ******
Software Version Information
Project #15: Environment – SD – Mk28
DL2502Mk06p.ino
DL2502Mk06
1 x Crowduino Uno - SD
1 x Crowtail - Base Shield
1 x Crowtail - LED(Red)
1 x Crowtail - Button 2.0
1 x MicroSD Card 4 Gb
1 x Crowtail - RTC 2.0
1 x CR1220 Battery
1 x Crowtail - Temperature and Humidity Sensor 2.0
1 x Crowtail - Rotary Angle Sensor 2.0
1 x Crowtail - Moisture Sensor 2.0
1 x Crowtail - I2C LCD
1 x Crowtail - LED(Green)
1 x Crowtail - LED(Yellow)
1 x USB Battery Pack
1 x USB Mini-B Cable
*/
// Include the Library Code
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>
// Wire
#include <Wire.h>
// Liquid Crystal
#include "LiquidCrystal.h"
// Temperature and Humidity Sensor
#include "DHT.h"
// RTC (Real-Time Clock)
#include "RTClib.h"
// Secure Digital (SD Card)
#include <SD.h>
#include <SPI.h>
// Secure Digital (SD Card)
const int chipSelect = 4;
String zzzzzz = "";
// Define LED Red
int iLED = 8;
// Button
int iButton = 9;
// Variable for reading the Button status
int iButtonState = 0;
// RTC (Real-Time Clock)
RTC_DS1307 RTC;
String dateRTC = "";
String timeRTC = "";
// Temperature and Humidity Sensor
#define DHTPIN 5
// DHT 11
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
// Temperature and Humidity Sensor
float h = 0;
float t = 0;
// Potentiometer
int iPotentiometer = A1;
// Change Your Threshold Here
int Threshold = 0;
int zz = 0;
// Liquid Crystal
// Connect via i2c
LiquidCrystal lcd(0);
// Crowtail Moisture Sensor
int iSoilMoisture = A0;
int iSoilMoistureVal = 0;
// LED Yellow
int iLEDYellow = 7;
// LED Green
int iLEDGreen = 6;
// EEPROM Unique ID Information
String uid = "";
// Software Version Information
String sver = "15-28";
void loop() {
// Crowtail Moisture Sensor
isSoilMoisture();
// Temperature and Humidity Sensor
isTH();
// RTC (Real-Time Clock)
isRTC();
// Read the state of the Switch value
iButtonState = digitalRead(iButton);
// The Button is HIGH:
if (iButtonState == HIGH) {
// LED Red HIGH
digitalWrite(iLED, HIGH);
// MicroSD Card
isSD();
} else {
// LED Red LOW
digitalWrite(iLED, LOW);
}
// Delay 0.5 Second
delay( 500 );
}
/****** Don Luc Electronics © ****** Software Version Information Project #15: Environment – SD – Mk28 DL2502Mk06p.ino DL2502Mk06 1 x Crowduino Uno - SD 1 x Crowtail - Base Shield 1 x Crowtail - LED(Red) 1 x Crowtail - Button 2.0 1 x MicroSD Card 4 Gb 1 x Crowtail - RTC 2.0 1 x CR1220 Battery 1 x Crowtail - Temperature and Humidity Sensor 2.0 1 x Crowtail - Rotary Angle Sensor 2.0 1 x Crowtail - Moisture Sensor 2.0 1 x Crowtail - I2C LCD 1 x Crowtail - LED(Green) 1 x Crowtail - LED(Yellow) 1 x USB Battery Pack 1 x USB Mini-B Cable */ // Include the Library Code // EEPROM library to read and write EEPROM with unique ID for unit #include <EEPROM.h> // Wire #include <Wire.h> // Liquid Crystal #include "LiquidCrystal.h" // Temperature and Humidity Sensor #include "DHT.h" // RTC (Real-Time Clock) #include "RTClib.h" // Secure Digital (SD Card) #include <SD.h> #include <SPI.h> // Secure Digital (SD Card) const int chipSelect = 4; String zzzzzz = ""; // Define LED Red int iLED = 8; // Button int iButton = 9; // Variable for reading the Button status int iButtonState = 0; // RTC (Real-Time Clock) RTC_DS1307 RTC; String dateRTC = ""; String timeRTC = ""; // Temperature and Humidity Sensor #define DHTPIN 5 // DHT 11 #define DHTTYPE DHT11 DHT dht(DHTPIN, DHTTYPE); // Temperature and Humidity Sensor float h = 0; float t = 0; // Potentiometer int iPotentiometer = A1; // Change Your Threshold Here int Threshold = 0; int zz = 0; // Liquid Crystal // Connect via i2c LiquidCrystal lcd(0); // Crowtail Moisture Sensor int iSoilMoisture = A0; int iSoilMoistureVal = 0; // LED Yellow int iLEDYellow = 7; // LED Green int iLEDGreen = 6; // EEPROM Unique ID Information String uid = ""; // Software Version Information String sver = "15-28"; void loop() { // Crowtail Moisture Sensor isSoilMoisture(); // Temperature and Humidity Sensor isTH(); // RTC (Real-Time Clock) isRTC(); // Read the state of the Switch value iButtonState = digitalRead(iButton); // The Button is HIGH: if (iButtonState == HIGH) { // LED Red HIGH digitalWrite(iLED, HIGH); // MicroSD Card isSD(); } else { // LED Red LOW digitalWrite(iLED, LOW); } // Delay 0.5 Second delay( 500 ); }
/****** Don Luc Electronics © ******
Software Version Information
Project #15: Environment – SD – Mk28
DL2502Mk06p.ino
DL2502Mk06
1 x Crowduino Uno - SD
1 x Crowtail - Base Shield
1 x Crowtail - LED(Red)
1 x Crowtail - Button 2.0
1 x MicroSD Card 4 Gb
1 x Crowtail - RTC 2.0
1 x CR1220 Battery
1 x Crowtail - Temperature and Humidity Sensor 2.0
1 x Crowtail - Rotary Angle Sensor 2.0
1 x Crowtail - Moisture Sensor 2.0
1 x Crowtail - I2C LCD
1 x Crowtail - LED(Green)
1 x Crowtail - LED(Yellow)
1 x USB Battery Pack
1 x USB Mini-B Cable
*/

// Include the Library Code
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>
// Wire
#include <Wire.h>
// Liquid Crystal
#include "LiquidCrystal.h"
// Temperature and Humidity Sensor
#include "DHT.h"
// RTC (Real-Time Clock)
#include "RTClib.h"
// Secure Digital (SD Card)
#include <SD.h>
#include <SPI.h>

// Secure Digital (SD Card)
const int chipSelect = 4;
String zzzzzz = "";

// Define LED Red
int iLED = 8;

// Button
int iButton = 9;
// Variable for reading the Button status
int iButtonState = 0;

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

// Temperature and Humidity Sensor
#define DHTPIN 5
// DHT 11
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
// Temperature and Humidity Sensor
float h = 0;
float t = 0;

// Potentiometer
int iPotentiometer = A1;
// Change Your Threshold Here
int Threshold = 0;
int zz = 0;

// Liquid Crystal
// Connect via i2c
LiquidCrystal lcd(0);

// Crowtail Moisture Sensor
int iSoilMoisture = A0;
int iSoilMoistureVal = 0;

// LED Yellow
int iLEDYellow = 7;

// LED Green
int iLEDGreen = 6;

// EEPROM Unique ID Information
String uid = "";

// Software Version Information
String sver = "15-28";

void loop() {

  // Crowtail Moisture Sensor
  isSoilMoisture();

  // Temperature and Humidity Sensor
  isTH();

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

  // Read the state of the Switch value
  iButtonState = digitalRead(iButton);

  // The Button is HIGH:
  if (iButtonState == HIGH) {

    // LED Red HIGH
    digitalWrite(iLED, HIGH);

    // MicroSD Card
    isSD();

  } else {

    // LED Red LOW
    digitalWrite(iLED, LOW);

  }

  // Delay 0.5 Second
  delay( 500 );

}

getDisplay.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// getDisplay
// Crowbits - OLED 128X64 UID
void isDisplayUID(){
// Set up the LCD's number of rows and columns:
lcd.begin(16, 2);
// Print a message to the LCD.
// Cursor
lcd.setCursor(0, 0);
lcd.print("Don Luc Electron");
// Cursor
lcd.setCursor(0, 1);
// Print a message to the LCD.
lcd.print( sver );
}
// isDisplay Green
void isDisplayG(){
// Print a message to the LCD
// Clear
lcd.clear();
// Cursor
lcd.setCursor(0, 0);
lcd.print("Humid Soil");
// Cursor
lcd.setCursor(0, 1);
// Print a message to the LCD
lcd.print( iSoilMoistureVal );
}
// isDisplay Yellow
void isDisplayY(){
// Print a message to the LCD
// Clear
lcd.clear();
// Cursor
lcd.setCursor(0, 0);
lcd.print("Dry Soil");
// Cursor
lcd.setCursor(0, 1);
// Print a message to the LCD
lcd.print( iSoilMoistureVal );
}
// getDisplay // Crowbits - OLED 128X64 UID void isDisplayUID(){ // Set up the LCD's number of rows and columns: lcd.begin(16, 2); // Print a message to the LCD. // Cursor lcd.setCursor(0, 0); lcd.print("Don Luc Electron"); // Cursor lcd.setCursor(0, 1); // Print a message to the LCD. lcd.print( sver ); } // isDisplay Green void isDisplayG(){ // Print a message to the LCD // Clear lcd.clear(); // Cursor lcd.setCursor(0, 0); lcd.print("Humid Soil"); // Cursor lcd.setCursor(0, 1); // Print a message to the LCD lcd.print( iSoilMoistureVal ); } // isDisplay Yellow void isDisplayY(){ // Print a message to the LCD // Clear lcd.clear(); // Cursor lcd.setCursor(0, 0); lcd.print("Dry Soil"); // Cursor lcd.setCursor(0, 1); // Print a message to the LCD lcd.print( iSoilMoistureVal ); }
// getDisplay
// Crowbits - OLED 128X64 UID
void isDisplayUID(){

  // Set up the LCD's number of rows and columns: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  // Cursor
  lcd.setCursor(0, 0);
  lcd.print("Don Luc Electron");
  // Cursor
  lcd.setCursor(0, 1);
  // Print a message to the LCD.
  lcd.print( sver );

}
// isDisplay Green
void isDisplayG(){

  // Print a message to the LCD
  // Clear
  lcd.clear();
  // Cursor
  lcd.setCursor(0, 0);
  lcd.print("Humid Soil");
  // Cursor
  lcd.setCursor(0, 1);
  // Print a message to the LCD
  lcd.print( iSoilMoistureVal );
  
}
// isDisplay Yellow
void isDisplayY(){

  // Print a message to the LCD
  // Clear
  lcd.clear();
  // Cursor
  lcd.setCursor(0, 0);
  lcd.print("Dry Soil");
  // Cursor
  lcd.setCursor(0, 1);
  // Print a message to the LCD
  lcd.print( iSoilMoistureVal );
  
}

getEEPROM.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// EEPROM
// isUID EEPROM Unique ID
void isUID() {
// Is Unit ID
uid = "";
for (int x = 0; x < 7; x++)
{
uid = uid + char(EEPROM.read(x));
}
}
// EEPROM // isUID EEPROM Unique ID void isUID() { // Is Unit ID uid = ""; for (int x = 0; x < 7; x++) { uid = uid + char(EEPROM.read(x)); } }
// EEPROM
// isUID EEPROM Unique ID
void isUID() {
  
  // Is Unit ID
  uid = "";
  for (int x = 0; x < 7; x++)
  {
    uid = uid + char(EEPROM.read(x));
  }
  
}

getRTC.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// RTC (Real-Time Clock)
// Setup RTC
void isSetupRTC(){
// RTC (Real-Time Clock)
RTC.begin();
// RTC Running
if (! RTC.isrunning()) {
// following line sets the RTC to the date & time
//this sketch was compiled
RTC.adjust(DateTime(__DATE__, __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;
}
// RTC (Real-Time Clock) // Setup RTC void isSetupRTC(){ // RTC (Real-Time Clock) RTC.begin(); // RTC Running if (! RTC.isrunning()) { // following line sets the RTC to the date & time //this sketch was compiled RTC.adjust(DateTime(__DATE__, __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; }
// RTC (Real-Time Clock)
// Setup RTC
void isSetupRTC(){

  // RTC (Real-Time Clock)
  RTC.begin();

  // RTC Running
  if (! RTC.isrunning()) {
    
    // following line sets the RTC to the date & time
    //this sketch was compiled
    RTC.adjust(DateTime(__DATE__, __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;

}

getSD.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// MicroSD Card
// MicroSD Setup
void isSetupSD() {
// MicroSD Card
// See if the card is present and can be initialized:
if (!SD.begin(chipSelect)) {
// Don't do anything more:
while (1);
}
}
// MicroSD Card
void isSD() {
zzzzzz = "";
//DLE|EEPROM Unique ID|Version|Date|Time|
//Temperature|Humidity|Soil Moisture|
zzzzzz = "DLE|" + uid + "|" + sver + "|" + String( dateRTC ) + "|"
+ String( timeRTC ) + "|" + String(t) + "|" + String(h) + "|"
+ String(iSoilMoistureVal) + "|";
// Open the file. Note that only one file can be open at a time,
// so you have to close this one before opening another.
File dataFile = SD.open("dledata.txt", FILE_WRITE);
// If the file is available, write to it:
if (dataFile) {
// Write
dataFile.println( zzzzzz );
dataFile.close();
}
}
// MicroSD Card // MicroSD Setup void isSetupSD() { // MicroSD Card // See if the card is present and can be initialized: if (!SD.begin(chipSelect)) { // Don't do anything more: while (1); } } // MicroSD Card void isSD() { zzzzzz = ""; //DLE|EEPROM Unique ID|Version|Date|Time| //Temperature|Humidity|Soil Moisture| zzzzzz = "DLE|" + uid + "|" + sver + "|" + String( dateRTC ) + "|" + String( timeRTC ) + "|" + String(t) + "|" + String(h) + "|" + String(iSoilMoistureVal) + "|"; // Open the file. Note that only one file can be open at a time, // so you have to close this one before opening another. File dataFile = SD.open("dledata.txt", FILE_WRITE); // If the file is available, write to it: if (dataFile) { // Write dataFile.println( zzzzzz ); dataFile.close(); } }
// MicroSD Card
// MicroSD Setup
void isSetupSD() {

    // MicroSD Card
   // See if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {

    // Don't do anything more:
    while (1);
    
  }

}
// MicroSD Card
void isSD() {

  zzzzzz = "";

  //DLE|EEPROM Unique ID|Version|Date|Time|
  //Temperature|Humidity|Soil Moisture|
  zzzzzz = "DLE|" + uid + "|" + sver + "|" + String( dateRTC ) + "|" 
  + String( timeRTC ) + "|" + String(t) + "|" + String(h) + "|" 
  + String(iSoilMoistureVal) + "|";

  // Open the file. Note that only one file can be open at a time,
  // so you have to close this one before opening another.
  File dataFile = SD.open("dledata.txt", FILE_WRITE);

  // If the file is available, write to it:
  if (dataFile) {
    
    // Write
    dataFile.println( zzzzzz );
    dataFile.close();

  }

}

getSoilMoisture.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// Crowtail Moisture Sensor
// Soil Moisture
void isSoilMoisture(){
// Connect Soil Moisture Sensor to Analog 0
// iSoilMoistureVal => 0~700 Soil Moisture
iSoilMoistureVal = analogRead( iSoilMoisture );
// Threshold => 200~500
zz = analogRead( iPotentiometer );
Threshold = map( zz, 0, 1024, 200, 500);
// Threshold
if (iSoilMoistureVal > Threshold) {
// 300~700 - Humid Soil
// LED Yellow
digitalWrite(iLEDYellow, LOW);
// Display Green
isDisplayG();
// LED Green
digitalWrite(iLEDGreen, HIGH);
}
else {
// 0-300 Dry Soil
// LED Green
digitalWrite(iLEDGreen, LOW);
// Display Yellow
isDisplayY();
digitalWrite(iLEDYellow, HIGH);
}
}
// Crowtail Moisture Sensor // Soil Moisture void isSoilMoisture(){ // Connect Soil Moisture Sensor to Analog 0 // iSoilMoistureVal => 0~700 Soil Moisture iSoilMoistureVal = analogRead( iSoilMoisture ); // Threshold => 200~500 zz = analogRead( iPotentiometer ); Threshold = map( zz, 0, 1024, 200, 500); // Threshold if (iSoilMoistureVal > Threshold) { // 300~700 - Humid Soil // LED Yellow digitalWrite(iLEDYellow, LOW); // Display Green isDisplayG(); // LED Green digitalWrite(iLEDGreen, HIGH); } else { // 0-300 Dry Soil // LED Green digitalWrite(iLEDGreen, LOW); // Display Yellow isDisplayY(); digitalWrite(iLEDYellow, HIGH); } }
// Crowtail Moisture Sensor
// Soil Moisture
void isSoilMoisture(){

  // Connect Soil Moisture Sensor to Analog 0
  // iSoilMoistureVal => 0~700 Soil Moisture
  iSoilMoistureVal = analogRead( iSoilMoisture );

  // Threshold => 200~500
  zz = analogRead( iPotentiometer );
  Threshold = map( zz, 0, 1024, 200, 500);

  // Threshold
  if (iSoilMoistureVal > Threshold) {

    // 300~700 - Humid Soil
    // LED Yellow
    digitalWrite(iLEDYellow, LOW);
    // Display Green
    isDisplayG();
    // LED Green
    digitalWrite(iLEDGreen, HIGH);
    
  }
  else {
    
    // 0-300 Dry Soil
    // LED Green
    digitalWrite(iLEDGreen, LOW);
    // Display Yellow
    isDisplayY();
    digitalWrite(iLEDYellow, HIGH);
    
  }

}

getTH.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// Temperature and Humidity Sensor
void isTH(){
// Temperature
t = dht.readTemperature();
// Humidity
h = dht.readHumidity();
}
// Temperature and Humidity Sensor void isTH(){ // Temperature t = dht.readTemperature(); // Humidity h = dht.readHumidity(); }
// Temperature and Humidity Sensor
void isTH(){

  // Temperature
  t = dht.readTemperature();
  // Humidity
  h = dht.readHumidity();
  
}

setup.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// Setup
void setup()
{
// Delay
delay(100);
// isUID EEPROM Unique ID
isUID();
// Delay
delay(100);
// Initialize the LED iLED Yellow
pinMode(iLEDYellow, OUTPUT);
// Initialize the LED LED Green
pinMode(iLEDGreen, OUTPUT);
// Temperature and Humidity Sensor
dht.begin();
// Delay
delay(100);
// Setup RTC
isSetupRTC();
// Delay
delay(100);
// MicroSD Card
isSetupSD();
// Delay
delay(100);
// iLED Red
pinMode(iLED, OUTPUT);
// LED Red LOW
digitalWrite(iLED, LOW);
// Delay
delay( 100 );
// Button
pinMode(iButton,INPUT);
// Delay
delay( 100 );
// Display UID
isDisplayUID();
// Delay 5 Second
delay( 5000 );
}
// Setup void setup() { // Delay delay(100); // isUID EEPROM Unique ID isUID(); // Delay delay(100); // Initialize the LED iLED Yellow pinMode(iLEDYellow, OUTPUT); // Initialize the LED LED Green pinMode(iLEDGreen, OUTPUT); // Temperature and Humidity Sensor dht.begin(); // Delay delay(100); // Setup RTC isSetupRTC(); // Delay delay(100); // MicroSD Card isSetupSD(); // Delay delay(100); // iLED Red pinMode(iLED, OUTPUT); // LED Red LOW digitalWrite(iLED, LOW); // Delay delay( 100 ); // Button pinMode(iButton,INPUT); // Delay delay( 100 ); // Display UID isDisplayUID(); // Delay 5 Second delay( 5000 ); }
// Setup
void setup()
{
 
  // Delay
  delay(100);
  
  // isUID EEPROM Unique ID
  isUID();
  
  // Delay
  delay(100);

  // Initialize the LED iLED Yellow
  pinMode(iLEDYellow, OUTPUT);

  // Initialize the LED LED Green
  pinMode(iLEDGreen, OUTPUT);

  // Temperature and Humidity Sensor
  dht.begin();

  // Delay
  delay(100);
  
  // Setup RTC
  isSetupRTC();
  
  // Delay
  delay(100);

  // MicroSD Card
  isSetupSD();
  
  // Delay
  delay(100);

  // iLED Red
  pinMode(iLED, OUTPUT);

  // LED Red LOW
  digitalWrite(iLED, LOW);

  // Delay
  delay( 100 );

  // Button
  pinMode(iButton,INPUT);

  // Delay
  delay( 100 );

  // Display UID
  isDisplayUID();
  
  // Delay 5 Second
  delay( 5000 );

}

——

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

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

  • Programming Language
  • Single-Board 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

Follow Us

Luc Paquin – Curriculum Vitae – 2024
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
Hackster.io: https://www.hackster.io/neosteam-labs
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

Project #25 – Movement – SD – Mk12

——

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

——

SD

——

SD

——

SD

——

MicroSD Card Module

There are different microSD card modules compatible with the ESP32. We’re using the microSD card module it communicates using SPI communication protocol. You can use any other microSD card module with an SPI interface. This microSD card module is also compatible with other microcontrollers like the Arduino boards. To learn how to use the microSD card module with the Arduino. You can connect it to the ESP32 using the default SPI pins.

DL2502Mk05

1 x DFRobot FireBeetle 2 ESP32-E
1 x Fermion: 2.0″ 320×240 IPS TFT LCD
1 x GDL Line 10 CM
1 x Crowtail – I2C Hub 2.0
1 x Crowtail – Switch 2.0
1 x Adafruit MicroSD card breakout board+
1 x MicroSD 4 GB
1 x Crowtail – LED(Red)
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
SCK – 18
MOSI – 23
MISO – 19
CS – 4
POT – 16
LED – 17
GPR – 0
GPT – 2
DC – D2
CS – D6
RST – D3
RX2 – Bluetooth
TX2 – Bluetooth
VIN – +3.3V
GND – GND

DL2502Mk05p

DL2502Mk05p.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
/****** Don Luc Electronics © ******
Software Version Information
Project #25 - Movement - SD - Mk12
25-12
DL2502Mk05p.ino
DL2502Mk05
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 Crowtail - Switch 2.0
1 x Adafruit MicroSD card breakout board+
1 x MicroSD 4 GB
1 x Crowtail - LED(Red)
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>
// SD Card
#include "FS.h"
#include "SD.h"
#include "SPI.h"
// Define LED Red
int iLED = 17;
// Switch
int iSwitch = 16;
// Variable for reading the Switch status
int iSwitchState = 0;
// MicroSD Card
const int chipSelect = 4;
String zzzzzz = "";
// 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 = "";
String tempRTC = "";
// 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-12";
void loop() {
// Accelemeter ADXL345
isADXL345();
// Compass HMC5883L
isHMC5883L();
// RTC (Real-Time Clock)
isRTC();
// isGPS
isGPS();
// Accelemeter ADXL345 Compass HMC5883L Display
isDisplayADXL345HMC5883L();
// Read the state of the Switch value
iSwitchState = digitalRead(iSwitch);
// The Switch is HIGH:
if (iSwitchState == HIGH) {
// LED Red HIGH
digitalWrite(iLED, HIGH);
// MicroSD Card
isSD();
} else {
// LED Red LOW
digitalWrite(iLED, LOW);
}
// Delay 0.5 Second
delay( 500 );
}
/****** Don Luc Electronics © ****** Software Version Information Project #25 - Movement - SD - Mk12 25-12 DL2502Mk05p.ino DL2502Mk05 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 Crowtail - Switch 2.0 1 x Adafruit MicroSD card breakout board+ 1 x MicroSD 4 GB 1 x Crowtail - LED(Red) 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> // SD Card #include "FS.h" #include "SD.h" #include "SPI.h" // Define LED Red int iLED = 17; // Switch int iSwitch = 16; // Variable for reading the Switch status int iSwitchState = 0; // MicroSD Card const int chipSelect = 4; String zzzzzz = ""; // 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 = ""; String tempRTC = ""; // 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-12"; void loop() { // Accelemeter ADXL345 isADXL345(); // Compass HMC5883L isHMC5883L(); // RTC (Real-Time Clock) isRTC(); // isGPS isGPS(); // Accelemeter ADXL345 Compass HMC5883L Display isDisplayADXL345HMC5883L(); // Read the state of the Switch value iSwitchState = digitalRead(iSwitch); // The Switch is HIGH: if (iSwitchState == HIGH) { // LED Red HIGH digitalWrite(iLED, HIGH); // MicroSD Card isSD(); } else { // LED Red LOW digitalWrite(iLED, LOW); } // Delay 0.5 Second delay( 500 ); }
/****** Don Luc Electronics © ******
  Software Version Information
  Project #25 - Movement - SD - Mk12
  25-12
  DL2502Mk05p.ino
  DL2502Mk05
  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 Crowtail - Switch 2.0
  1 x Adafruit MicroSD card breakout board+
  1 x MicroSD 4 GB
  1 x Crowtail - LED(Red)
  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>
// SD Card
#include "FS.h"
#include "SD.h"
#include "SPI.h"

// Define LED Red
int iLED = 17;

// Switch
int iSwitch = 16;
// Variable for reading the Switch status
int iSwitchState = 0;

// MicroSD Card
const int chipSelect = 4;
String zzzzzz = "";

// 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 = "";
String tempRTC = "";

// 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-12";

void loop() {

  // Accelemeter ADXL345
  isADXL345();

  // Compass HMC5883L
  isHMC5883L();

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

  // isGPS
  isGPS();

  // Accelemeter ADXL345 Compass HMC5883L Display
  isDisplayADXL345HMC5883L();

  // Read the state of the Switch value
  iSwitchState = digitalRead(iSwitch);

  // The Switch is HIGH:
  if (iSwitchState == HIGH) {

    // LED Red HIGH
    digitalWrite(iLED, HIGH);

    // MicroSD Card
    isSD();

  } else {

    // LED Red LOW
    digitalWrite(iLED, LOW);

  }

  // Delay 0.5 Second
  delay( 500 );

}

getAccelemeterADXL345.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// 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);
// Standard Gravity
// Acceleration
adxl.getAcceleration(xyz);
// Output
ax = xyz[0];
ay = xyz[1];
az = xyz[2];
}
// 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); // Standard Gravity // Acceleration adxl.getAcceleration(xyz); // Output ax = xyz[0]; ay = xyz[1]; az = xyz[2]; }
// 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);

  // Standard Gravity
  // Acceleration
  adxl.getAcceleration(xyz);

  // Output
  ax = xyz[0];
  ay = xyz[1];
  az = xyz[2];
  
}

getCompassHMC5883L.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// 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;
}
// 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; }
// 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; 

}

getDisplay.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// 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");
// SD
screen.setCursor(0, 60);
screen.println("SD");
// 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 );
}
// 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"); // SD screen.setCursor(0, 60); screen.println("SD"); // 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 ); }
// 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");
  // SD
  screen.setCursor(0, 60);
  screen.println("SD");
  // 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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// EEPROM
// isUID EEPROM Unique ID
void isUID() {
// Is Unit ID
uid = "";
for (int x = 0; x < 7; x++)
{
uid = uid + char(EEPROM.read(x));
}
}
// EEPROM // isUID EEPROM Unique ID void isUID() { // Is Unit ID uid = ""; for (int x = 0; x < 7; x++) { uid = uid + char(EEPROM.read(x)); } }
// EEPROM
// isUID EEPROM Unique ID
void isUID() {
  
  // Is Unit ID
  uid = "";
  for (int x = 0; x < 7; x++)
  {
    uid = uid + char(EEPROM.read(x));
  }
  
}

getGPS.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// 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";
}
}
// GPS Date, Time, Speed, Altitude
void displayDTS(){
// 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);
}
// 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);
}
// 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);
}
// 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);
}
}
// 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"; } } // GPS Date, Time, Speed, Altitude void displayDTS(){ // 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); } // 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); } // 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); } // 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); } }
// 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";
    
  }

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

  // 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);
    
  }

  // 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);
    
  }

  // 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);

  }

  // 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);

  }

}

getRTC.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// 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;
// Temperature
tempRTC = rtc.getTemperature();
}
// 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; // Temperature tempRTC = rtc.getTemperature(); }
// 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;

  // Temperature
  tempRTC = rtc.getTemperature();

}

getSD.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// MicroSD Card
// MicroSD Setup
void isSetupSD() {
// MicroSD Card
pinMode( chipSelect , OUTPUT );
if(!SD.begin( chipSelect )){
;
return;
}
uint8_t cardType = SD.cardType();
// CARD NONE
if(cardType == CARD_NONE){
;
return;
}
// SD Card Type
if(cardType == CARD_MMC){
;
} else if(cardType == CARD_SD){
;
} else if(cardType == CARD_SDHC){
;
} else {
;
}
// Size
uint64_t cardSize = SD.cardSize() / (1024 * 1024);
}
// MicroSD Card
void isSD() {
zzzzzz = "";
//DLE|EEPROM Unique ID|Version|Date|Time|Temperature|
//Accelerometer X|Accelerometer Y|Accelerometer Z|
//Accelerometer X|Accelerometer Y|Accelerometer Z|
//Compass Heading|Compass Degress|
//GPS|Latitude|Longitude|GPS Date|GPS Time|
//GPS Speed M/S|GPS Speed Km/h|
//GPS Altitude Feet|GPS Altitude Meters|*\r
zzzzzz = "DLE|" + uid + "|" + sver + "|" + String( dateRTC ) + "|"
+ String( timeRTC ) + "|" + String( tempRTC ) + "|"
+ String(x) + "|" + String(y) + "|" + String(z) + "|"
+ String(ax) + "|" + String(ay) + "|" + String(az) + "|"
+ String( heading ) + "|" + String( headingDegrees ) + "|"
+ String(GPSSt) + "|" + String(TargetLat) + "|" + String(TargetLon) + "|"
+ String(TargetDat) + "|" + String(TargetTim) + "|"
+ String(TargetSMS) + "|" + String(TargetSKH) + "|"
+ String(TargetALTF) + "|" + String(TargetALTM)+ "|*\r";
// msg + 1
char msg[zzzzzz.length() + 1];
zzzzzz.toCharArray(msg, zzzzzz.length() + 1);
// Append File
appendFile(SD, "/dledata.txt", msg );
// 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
// zzzzzz
FullString = zzzzzz;
// 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]);
}
}
// List Dir
void listDir(fs::FS &fs, const char * dirname, uint8_t levels){
// List Dir
dirname;
File root = fs.open(dirname);
if(!root){
return;
}
if(!root.isDirectory()){
return;
}
File file = root.openNextFile();
while(file){
if(file.isDirectory()){
file.name();
if(levels){
listDir(fs, file.name(), levels -1);
}
} else {
file.name();
file.size();
}
file = root.openNextFile();
}
}
// Write File
void writeFile(fs::FS &fs, const char * path, const char * message){
// Write File
path;
File file = fs.open(path, FILE_WRITE);
if(!file){
return;
}
if(file.print(message)){
;
} else {
;
}
file.close();
}
// Append File
void appendFile(fs::FS &fs, const char * path, const char * message){
// Append File
path;
File file = fs.open(path, FILE_APPEND);
if(!file){
return;
}
if(file.print(message)){
;
} else {
;
}
file.close();
}
// MicroSD Card // MicroSD Setup void isSetupSD() { // MicroSD Card pinMode( chipSelect , OUTPUT ); if(!SD.begin( chipSelect )){ ; return; } uint8_t cardType = SD.cardType(); // CARD NONE if(cardType == CARD_NONE){ ; return; } // SD Card Type if(cardType == CARD_MMC){ ; } else if(cardType == CARD_SD){ ; } else if(cardType == CARD_SDHC){ ; } else { ; } // Size uint64_t cardSize = SD.cardSize() / (1024 * 1024); } // MicroSD Card void isSD() { zzzzzz = ""; //DLE|EEPROM Unique ID|Version|Date|Time|Temperature| //Accelerometer X|Accelerometer Y|Accelerometer Z| //Accelerometer X|Accelerometer Y|Accelerometer Z| //Compass Heading|Compass Degress| //GPS|Latitude|Longitude|GPS Date|GPS Time| //GPS Speed M/S|GPS Speed Km/h| //GPS Altitude Feet|GPS Altitude Meters|*\r zzzzzz = "DLE|" + uid + "|" + sver + "|" + String( dateRTC ) + "|" + String( timeRTC ) + "|" + String( tempRTC ) + "|" + String(x) + "|" + String(y) + "|" + String(z) + "|" + String(ax) + "|" + String(ay) + "|" + String(az) + "|" + String( heading ) + "|" + String( headingDegrees ) + "|" + String(GPSSt) + "|" + String(TargetLat) + "|" + String(TargetLon) + "|" + String(TargetDat) + "|" + String(TargetTim) + "|" + String(TargetSMS) + "|" + String(TargetSKH) + "|" + String(TargetALTF) + "|" + String(TargetALTM)+ "|*\r"; // msg + 1 char msg[zzzzzz.length() + 1]; zzzzzz.toCharArray(msg, zzzzzz.length() + 1); // Append File appendFile(SD, "/dledata.txt", msg ); // 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 // zzzzzz FullString = zzzzzz; // 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]); } } // List Dir void listDir(fs::FS &fs, const char * dirname, uint8_t levels){ // List Dir dirname; File root = fs.open(dirname); if(!root){ return; } if(!root.isDirectory()){ return; } File file = root.openNextFile(); while(file){ if(file.isDirectory()){ file.name(); if(levels){ listDir(fs, file.name(), levels -1); } } else { file.name(); file.size(); } file = root.openNextFile(); } } // Write File void writeFile(fs::FS &fs, const char * path, const char * message){ // Write File path; File file = fs.open(path, FILE_WRITE); if(!file){ return; } if(file.print(message)){ ; } else { ; } file.close(); } // Append File void appendFile(fs::FS &fs, const char * path, const char * message){ // Append File path; File file = fs.open(path, FILE_APPEND); if(!file){ return; } if(file.print(message)){ ; } else { ; } file.close(); }
// MicroSD Card
// MicroSD Setup
void isSetupSD() {

    // MicroSD Card
    pinMode( chipSelect , OUTPUT );
    if(!SD.begin( chipSelect )){
        ;  
        return;
    }
    
    uint8_t cardType = SD.cardType();

    // CARD NONE
    if(cardType == CARD_NONE){
        ; 
        return;
    }

    // SD Card Type
    if(cardType == CARD_MMC){
        ; 
    } else if(cardType == CARD_SD){
        ; 
    } else if(cardType == CARD_SDHC){
        ; 
    } else {
        ; 
    } 

    // Size
    uint64_t cardSize = SD.cardSize() / (1024 * 1024);
 
}
// MicroSD Card
void isSD() {

  zzzzzz = "";

  //DLE|EEPROM Unique ID|Version|Date|Time|Temperature|
  //Accelerometer X|Accelerometer Y|Accelerometer Z|
  //Accelerometer X|Accelerometer Y|Accelerometer Z|
  //Compass Heading|Compass Degress|
  //GPS|Latitude|Longitude|GPS Date|GPS Time|
  //GPS Speed M/S|GPS Speed Km/h|
  //GPS Altitude Feet|GPS Altitude Meters|*\r
  zzzzzz = "DLE|" + uid + "|" + sver + "|" + String( dateRTC ) + "|" 
  + String( timeRTC ) + "|" + String( tempRTC ) + "|" 
  + String(x) + "|" + String(y) + "|" + String(z) + "|" 
  + String(ax) + "|" + String(ay) + "|" + String(az) + "|"
  + String( heading ) + "|" + String( headingDegrees ) + "|" 
  + String(GPSSt) + "|" + String(TargetLat) + "|" + String(TargetLon) + "|"
  + String(TargetDat) + "|" + String(TargetTim) + "|" 
  + String(TargetSMS) + "|" + String(TargetSKH) + "|"
  + String(TargetALTF) + "|" + String(TargetALTM)+ "|*\r";

  // msg + 1
  char msg[zzzzzz.length() + 1];

  zzzzzz.toCharArray(msg, zzzzzz.length() + 1);

  // Append File
  appendFile(SD, "/dledata.txt", msg );

  // 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
  // zzzzzz
  FullString = zzzzzz;
  // 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]);
    
  }

  
}
// List Dir
void listDir(fs::FS &fs, const char * dirname, uint8_t levels){
    
    // List Dir
    dirname;
    
    File root = fs.open(dirname);
    
    if(!root){
        return;
    }
    
    if(!root.isDirectory()){
        return;
    }

    File file = root.openNextFile();
    
    while(file){
        if(file.isDirectory()){
            file.name();
            if(levels){
                listDir(fs, file.name(), levels -1);
            }
        } else {
            file.name();
            file.size();
        }
        file = root.openNextFile();
    }
    
}
// Write File
void writeFile(fs::FS &fs, const char * path, const char * message){
    
    // Write File
    path;
    
    File file = fs.open(path, FILE_WRITE);
    
    if(!file){
        return;
    }
    
    if(file.print(message)){
        ;  
    } else {
        ;  
    }
    
    file.close();
    
}
// Append File
void appendFile(fs::FS &fs, const char * path, const char * message){
    
    // Append File
    path;
    
    File file = fs.open(path, FILE_APPEND);
    
    if(!file){
        return;
    }
    
    if(file.print(message)){
        ;  
    } else {
        ;  
    }
    
    file.close();
    
}

setup.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// Setup
void setup()
{
// Serial Begin
Serial.begin(115200);
Serial.println("Starting BLE work!");
// Bluetooth Serial
SerialBT.begin("DL2502Mk05");
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);
//MicroSD Card
isSetupSD();
// 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 );
// iLED Red
pinMode(iLED, OUTPUT);
// LED Red LOW
digitalWrite(iLED, LOW);
// Delay
delay( 100 );
// Switch
pinMode(iSwitch,INPUT);
// Delay
delay( 100 );
// DFRobot Display 240x320 - UID
// Don Luc Electronics
// Version
isDisplayUID();
// Delay 5 Second
delay( 5000 );
}
// Setup void setup() { // Serial Begin Serial.begin(115200); Serial.println("Starting BLE work!"); // Bluetooth Serial SerialBT.begin("DL2502Mk05"); 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); //MicroSD Card isSetupSD(); // 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 ); // iLED Red pinMode(iLED, OUTPUT); // LED Red LOW digitalWrite(iLED, LOW); // Delay delay( 100 ); // Switch pinMode(iSwitch,INPUT); // Delay delay( 100 ); // DFRobot Display 240x320 - UID // Don Luc Electronics // Version isDisplayUID(); // Delay 5 Second delay( 5000 ); }
// Setup
void setup()
{
 
  // Serial Begin
  Serial.begin(115200);
  Serial.println("Starting BLE work!");

  // Bluetooth Serial
  SerialBT.begin("DL2502Mk05");
  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);

  //MicroSD Card
  isSetupSD();

  // 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 );

  // iLED Red
  pinMode(iLED, OUTPUT);

  // LED Red LOW
  digitalWrite(iLED, LOW);

  // Delay
  delay( 100 );

  // Switch
  pinMode(iSwitch,INPUT);

  // Delay
  delay( 100 );

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

  // Delay 5 Second
  delay( 5000 );

}

——

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

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

  • Programming Language
  • Single-Board 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

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
Hackster.io: https://www.hackster.io/neosteam-labs
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

Project #15: Environment – GPS – Mk27

——

#DonLucElectronics #DonLuc #Arduino #RTC #EEPROM #DHT11 #ASM #Display #Elecrow #Project #Patreon #Electronics #Microcontrollers #IoT #Fritzing #Programming #Consultant

——

GPS

——

GPS

——

GPS

——

Crowtail – GPS

This Crowtail – GPS module is a cost-efficient and field-programmable gadget armed with a NEO-6M-0-001 and serial communication configuration. It features 55 channels, and a GPS L1 C/A code receiver. The sensitivity of tracking and acquisition both reach up to -161dBm, making it a great choice for personal navigation projects and location services, as well as an outstanding one among products of the same price class.

  • -Input Voltage: 5 Volt
  • -Supports NMEA and U-Blox Binary
  • -Low power consumption
  • -Baud rates configurable

DL2502Mk04

1 x Crowduino Uno – SD
1 x Crowtail – Base Shield
1 x Crowtail – GPS
1 x Crowtail – RTC 2.0
1 x Crowtail – Temperature and Humidity Sensor 2.0
1 x Crowtail – Rotary Angle Sensor 2.0
1 x Crowtail – Moisture Sensor 2.0
1 x Crowtail – I2C LCD
1 x Crowtail – LED(Green)
1 x Crowtail – LED(Yellow)
1 x USB Battery Pack
1 x USB Mini-B Cable

Crowduino Uno – SD

SCL – A5
SDA – A4
POT – A1
ASM – A0
LEDY – 7
LEDG – 6
ITH – 5
GPR – 2
GPT – 3
VIN – +5V
GND – GND

DL2502Mk04p

DL2502Mk04p.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
/****** Don Luc Electronics © ******
Software Version Information
Project #15: Environment – GPS – Mk27
DL2502Mk04p.ino
DL2502Mk04
1 x Crowduino Uno - SD
1 x Crowtail - Base Shield
1 x Crowtail - GPS
1 x Crowtail - RTC 2.0
1 x Crowtail - Temperature and Humidity Sensor 2.0
1 x Crowtail - Rotary Angle Sensor 2.0
1 x Crowtail - Moisture Sensor 2.0
1 x Crowtail - I2C LCD
1 x Crowtail - LED(Green)
1 x Crowtail - LED(Yellow)
1 x USB Battery Pack
1 x USB Mini-B Cable
*/
// Include the Library Code
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>
// Wire
#include <Wire.h>
// Liquid Crystal
#include "LiquidCrystal.h"
// Temperature and Humidity Sensor
#include "DHT.h"
// RTC (Real-Time Clock)
#include "RTClib.h"
// GPS Receiver
#include <TinyGPS++.h>
// Software Serial
#include <SoftwareSerial.h>
// GPS Receiver
static const int RXPin = 2;
// This one is unused and doesnt have a conection
static const int TXPin = 3;
// GPS Baud
static const uint32_t GPSBaud = 9600;
// The TinyGPS++ object
TinyGPSPlus gps;
// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);
// Latitude
float TargetLat;
// Longitude
float TargetLon;
// GPS Status
String GPSSt = "";
// RTC (Real-Time Clock)
RTC_DS1307 RTC;
String dateRTC = "";
String timeRTC = "";
// Temperature and Humidity Sensor
#define DHTPIN 5
// DHT 11
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
// Temperature and Humidity Sensor
float h = 0;
float t = 0;
// Potentiometer
int iPotentiometer = A1;
// Change Your Threshold Here
int Threshold = 0;
int zz = 0;
// Liquid Crystal
// Connect via i2c
LiquidCrystal lcd(0);
// Crowtail Moisture Sensor
int iSoilMoisture = A0;
int iSoilMoistureVal = 0;
// LED Yellow
int iLEDYellow = 7;
// LED Green
int iLEDGreen = 6;
// EEPROM Unique ID Information
String uid = "";
// Software Version Information
String sver = "15-27";
void loop() {
// Crowtail Moisture Sensor
isSoilMoisture();
// Temperature and Humidity Sensor
isTH();
// RTC (Real-Time Clock)
isRTC();
// isGPS
isGPS();
// Delay 2 Second
delay( 2000 );
// Display Temperature and Humidity
isDisplayTH();
// Delay 2 Second
delay( 2000 );
// Display EEPROM
isDisplayEEPROM();
// Delay 2 Second
delay( 2000 );
// Display RTC
isDisplayRTC();
// Delay 2 Second
delay( 2000 );
// GPS Vector Pointer Target
isDisplayInfo();
// Delay 2 Second
delay( 2000 );
}
/****** Don Luc Electronics © ****** Software Version Information Project #15: Environment – GPS – Mk27 DL2502Mk04p.ino DL2502Mk04 1 x Crowduino Uno - SD 1 x Crowtail - Base Shield 1 x Crowtail - GPS 1 x Crowtail - RTC 2.0 1 x Crowtail - Temperature and Humidity Sensor 2.0 1 x Crowtail - Rotary Angle Sensor 2.0 1 x Crowtail - Moisture Sensor 2.0 1 x Crowtail - I2C LCD 1 x Crowtail - LED(Green) 1 x Crowtail - LED(Yellow) 1 x USB Battery Pack 1 x USB Mini-B Cable */ // Include the Library Code // EEPROM library to read and write EEPROM with unique ID for unit #include <EEPROM.h> // Wire #include <Wire.h> // Liquid Crystal #include "LiquidCrystal.h" // Temperature and Humidity Sensor #include "DHT.h" // RTC (Real-Time Clock) #include "RTClib.h" // GPS Receiver #include <TinyGPS++.h> // Software Serial #include <SoftwareSerial.h> // GPS Receiver static const int RXPin = 2; // This one is unused and doesnt have a conection static const int TXPin = 3; // GPS Baud static const uint32_t GPSBaud = 9600; // The TinyGPS++ object TinyGPSPlus gps; // The serial connection to the GPS device SoftwareSerial ss(RXPin, TXPin); // Latitude float TargetLat; // Longitude float TargetLon; // GPS Status String GPSSt = ""; // RTC (Real-Time Clock) RTC_DS1307 RTC; String dateRTC = ""; String timeRTC = ""; // Temperature and Humidity Sensor #define DHTPIN 5 // DHT 11 #define DHTTYPE DHT11 DHT dht(DHTPIN, DHTTYPE); // Temperature and Humidity Sensor float h = 0; float t = 0; // Potentiometer int iPotentiometer = A1; // Change Your Threshold Here int Threshold = 0; int zz = 0; // Liquid Crystal // Connect via i2c LiquidCrystal lcd(0); // Crowtail Moisture Sensor int iSoilMoisture = A0; int iSoilMoistureVal = 0; // LED Yellow int iLEDYellow = 7; // LED Green int iLEDGreen = 6; // EEPROM Unique ID Information String uid = ""; // Software Version Information String sver = "15-27"; void loop() { // Crowtail Moisture Sensor isSoilMoisture(); // Temperature and Humidity Sensor isTH(); // RTC (Real-Time Clock) isRTC(); // isGPS isGPS(); // Delay 2 Second delay( 2000 ); // Display Temperature and Humidity isDisplayTH(); // Delay 2 Second delay( 2000 ); // Display EEPROM isDisplayEEPROM(); // Delay 2 Second delay( 2000 ); // Display RTC isDisplayRTC(); // Delay 2 Second delay( 2000 ); // GPS Vector Pointer Target isDisplayInfo(); // Delay 2 Second delay( 2000 ); }
/****** Don Luc Electronics © ******
Software Version Information
Project #15: Environment – GPS – Mk27
DL2502Mk04p.ino
DL2502Mk04
1 x Crowduino Uno - SD
1 x Crowtail - Base Shield
1 x Crowtail - GPS
1 x Crowtail - RTC 2.0
1 x Crowtail - Temperature and Humidity Sensor 2.0
1 x Crowtail - Rotary Angle Sensor 2.0
1 x Crowtail - Moisture Sensor 2.0
1 x Crowtail - I2C LCD
1 x Crowtail - LED(Green)
1 x Crowtail - LED(Yellow)
1 x USB Battery Pack
1 x USB Mini-B Cable
*/

// Include the Library Code
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>
// Wire
#include <Wire.h>
// Liquid Crystal
#include "LiquidCrystal.h"
// Temperature and Humidity Sensor
#include "DHT.h"
// RTC (Real-Time Clock)
#include "RTClib.h"
// GPS Receiver
#include <TinyGPS++.h>
// Software Serial
#include <SoftwareSerial.h>

// GPS Receiver
static const int RXPin = 2;
// This one is unused and doesnt have a conection
static const int TXPin = 3;
// GPS Baud
static const uint32_t GPSBaud = 9600;
// The TinyGPS++ object
TinyGPSPlus gps;
// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);
// Latitude
float TargetLat;
// Longitude
float TargetLon;
// GPS Status
String GPSSt = "";

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

// Temperature and Humidity Sensor
#define DHTPIN 5
// DHT 11
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
// Temperature and Humidity Sensor
float h = 0;
float t = 0;

// Potentiometer
int iPotentiometer = A1;
// Change Your Threshold Here
int Threshold = 0;
int zz = 0;

// Liquid Crystal
// Connect via i2c
LiquidCrystal lcd(0);

// Crowtail Moisture Sensor
int iSoilMoisture = A0;
int iSoilMoistureVal = 0;

// LED Yellow
int iLEDYellow = 7;

// LED Green
int iLEDGreen = 6;

// EEPROM Unique ID Information
String uid = "";

// Software Version Information
String sver = "15-27";

void loop() {

  // Crowtail Moisture Sensor
  isSoilMoisture();

  // Temperature and Humidity Sensor
  isTH();

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

  // isGPS
  isGPS();

  // Delay 2 Second
  delay( 2000 );

  // Display Temperature and Humidity
  isDisplayTH();

  // Delay 2 Second
  delay( 2000 );

  // Display EEPROM
  isDisplayEEPROM();

  // Delay 2 Second
  delay( 2000 );

  // Display RTC
  isDisplayRTC();

  // Delay 2 Second
  delay( 2000 );

  // GPS Vector Pointer Target
  isDisplayInfo();

  // Delay 2 Second
  delay( 2000 );

}

getDisplay.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// getDisplay
// Crowbits - OLED 128X64 UID
void isDisplayUID(){
// Set up the LCD's number of rows and columns:
lcd.begin(16, 2);
// Print a message to the LCD.
// Cursor
lcd.setCursor(0, 0);
lcd.print("Don Luc Electron");
// Cursor
lcd.setCursor(0, 1);
// Print a message to the LCD.
lcd.print( sver );
}
// isDisplay Green
void isDisplayG(){
// Print a message to the LCD
// Clear
lcd.clear();
// Cursor
lcd.setCursor(0, 0);
lcd.print("Humid Soil");
// Cursor
lcd.setCursor(0, 1);
// Print a message to the LCD
lcd.print( iSoilMoistureVal );
}
// isDisplay Yellow
void isDisplayY(){
// Print a message to the LCD
// Clear
lcd.clear();
// Cursor
lcd.setCursor(0, 0);
lcd.print("Dry Soil");
// Cursor
lcd.setCursor(0, 1);
// Print a message to the LCD
lcd.print( iSoilMoistureVal );
}
// Display Temperature and Humidity
void isDisplayTH(){
// Clear
lcd.clear();
// Set the cursor to column 0, line 0
lcd.setCursor(0, 0);
lcd.print("H: ");
lcd.print(h);
lcd.print(" %");
// Set the cursor to column 0, line 1
lcd.setCursor(0, 1);
lcd.print("T: ");
lcd.print(t);
lcd.print(" *C");
}
// Display EEPROM
void isDisplayEEPROM(){
// Clear
lcd.clear();
// Set the cursor to column 0, line 0
lcd.setCursor(0, 0);
lcd.print("EEPROM");
// Set the cursor to column 0, line 1
lcd.setCursor(0, 1);
lcd.print( uid );
}
// Display RTC
void isDisplayRTC(){
// Clear
lcd.clear();
// Set the cursor to column 0, line 0
lcd.setCursor(0, 0);
lcd.print( dateRTC );
// Set the cursor to column 0, line 1
lcd.setCursor(0, 1);
lcd.print( timeRTC );
}
// GPS Vector Pointer Target
void isDisplayInfo(){
// Clear
lcd.clear();
// Set the cursor to column 0, line 0
lcd.setCursor(0, 0);
lcd.print( "Lat: " );
lcd.print( TargetLat );
// Set the cursor to column 0, line 1
lcd.setCursor(0, 1);
lcd.print( "Lon: " );
lcd.print( TargetLon );
}
// getDisplay // Crowbits - OLED 128X64 UID void isDisplayUID(){ // Set up the LCD's number of rows and columns: lcd.begin(16, 2); // Print a message to the LCD. // Cursor lcd.setCursor(0, 0); lcd.print("Don Luc Electron"); // Cursor lcd.setCursor(0, 1); // Print a message to the LCD. lcd.print( sver ); } // isDisplay Green void isDisplayG(){ // Print a message to the LCD // Clear lcd.clear(); // Cursor lcd.setCursor(0, 0); lcd.print("Humid Soil"); // Cursor lcd.setCursor(0, 1); // Print a message to the LCD lcd.print( iSoilMoistureVal ); } // isDisplay Yellow void isDisplayY(){ // Print a message to the LCD // Clear lcd.clear(); // Cursor lcd.setCursor(0, 0); lcd.print("Dry Soil"); // Cursor lcd.setCursor(0, 1); // Print a message to the LCD lcd.print( iSoilMoistureVal ); } // Display Temperature and Humidity void isDisplayTH(){ // Clear lcd.clear(); // Set the cursor to column 0, line 0 lcd.setCursor(0, 0); lcd.print("H: "); lcd.print(h); lcd.print(" %"); // Set the cursor to column 0, line 1 lcd.setCursor(0, 1); lcd.print("T: "); lcd.print(t); lcd.print(" *C"); } // Display EEPROM void isDisplayEEPROM(){ // Clear lcd.clear(); // Set the cursor to column 0, line 0 lcd.setCursor(0, 0); lcd.print("EEPROM"); // Set the cursor to column 0, line 1 lcd.setCursor(0, 1); lcd.print( uid ); } // Display RTC void isDisplayRTC(){ // Clear lcd.clear(); // Set the cursor to column 0, line 0 lcd.setCursor(0, 0); lcd.print( dateRTC ); // Set the cursor to column 0, line 1 lcd.setCursor(0, 1); lcd.print( timeRTC ); } // GPS Vector Pointer Target void isDisplayInfo(){ // Clear lcd.clear(); // Set the cursor to column 0, line 0 lcd.setCursor(0, 0); lcd.print( "Lat: " ); lcd.print( TargetLat ); // Set the cursor to column 0, line 1 lcd.setCursor(0, 1); lcd.print( "Lon: " ); lcd.print( TargetLon ); }
// getDisplay
// Crowbits - OLED 128X64 UID
void isDisplayUID(){

  // Set up the LCD's number of rows and columns: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  // Cursor
  lcd.setCursor(0, 0);
  lcd.print("Don Luc Electron");
  // Cursor
  lcd.setCursor(0, 1);
  // Print a message to the LCD.
  lcd.print( sver );

}
// isDisplay Green
void isDisplayG(){

  // Print a message to the LCD
  // Clear
  lcd.clear();
  // Cursor
  lcd.setCursor(0, 0);
  lcd.print("Humid Soil");
  // Cursor
  lcd.setCursor(0, 1);
  // Print a message to the LCD
  lcd.print( iSoilMoistureVal );
  
}
// isDisplay Yellow
void isDisplayY(){

  // Print a message to the LCD
  // Clear
  lcd.clear();
  // Cursor
  lcd.setCursor(0, 0);
  lcd.print("Dry Soil");
  // Cursor
  lcd.setCursor(0, 1);
  // Print a message to the LCD
  lcd.print( iSoilMoistureVal );
  
}
// Display Temperature and Humidity
void isDisplayTH(){

  // Clear
  lcd.clear();
  // Set the cursor to column 0, line 0
  lcd.setCursor(0, 0);
  lcd.print("H: "); 
  lcd.print(h);
  lcd.print(" %");
  // Set the cursor to column 0, line 1
  lcd.setCursor(0, 1);
  lcd.print("T: "); 
  lcd.print(t);
  lcd.print(" *C");
  
}
// Display EEPROM
void isDisplayEEPROM(){

  // Clear
  lcd.clear();
  // Set the cursor to column 0, line 0
  lcd.setCursor(0, 0);
  lcd.print("EEPROM"); 
  // Set the cursor to column 0, line 1
  lcd.setCursor(0, 1);
  lcd.print( uid ); 

}
// Display RTC
void isDisplayRTC(){

  // Clear
  lcd.clear();
  // Set the cursor to column 0, line 0
  lcd.setCursor(0, 0);
  lcd.print( dateRTC );
  // Set the cursor to column 0, line 1
  lcd.setCursor(0, 1);
  lcd.print( timeRTC );
  
}
// GPS Vector Pointer Target
void isDisplayInfo(){

  // Clear
  lcd.clear();
  // Set the cursor to column 0, line 0
  lcd.setCursor(0, 0);
  lcd.print( "Lat: " );
  lcd.print( TargetLat );
  // Set the cursor to column 0, line 1
  lcd.setCursor(0, 1);
  lcd.print( "Lon: " );
  lcd.print( TargetLon );
  
}

getEEPROM.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// EEPROM
// isUID EEPROM Unique ID
void isUID() {
// Is Unit ID
uid = "";
for (int x = 0; x < 7; x++)
{
uid = uid + char(EEPROM.read(x));
}
}
// EEPROM // isUID EEPROM Unique ID void isUID() { // Is Unit ID uid = ""; for (int x = 0; x < 7; x++) { uid = uid + char(EEPROM.read(x)); } }
// EEPROM
// isUID EEPROM Unique ID
void isUID() {
  
  // Is Unit ID
  uid = "";
  for (int x = 0; x < 7; x++)
  {
    uid = uid + char(EEPROM.read(x));
  }
  
}

getGPS.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// GPS Receiver
// isGPS
void isGPS(){
// Receives NEMA data from GPS receiver
// This sketch displays information every time a
//new sentence is correctly encoded
while ( ss.available() > 0) {
// Read
if ( gps.encode( ss.read() ))
{
// GPS Vector Pointer Target
displayInfo();
}
}
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";
}
}
// GPS Receiver // isGPS void isGPS(){ // Receives NEMA data from GPS receiver // This sketch displays information every time a //new sentence is correctly encoded while ( ss.available() > 0) { // Read if ( gps.encode( ss.read() )) { // GPS Vector Pointer Target displayInfo(); } } 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"; } }
// GPS Receiver
// isGPS
void isGPS(){

  // Receives NEMA data from GPS receiver
  // This sketch displays information every time a 
  //new sentence is correctly encoded
  while ( ss.available() > 0) {
    
    // Read
    if ( gps.encode( ss.read() ))
    {
     
       // GPS Vector Pointer Target
       displayInfo();
       
    }
    
  }
  
  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";
    
  }

}

getRTC.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// RTC (Real-Time Clock)
// Setup RTC
void isSetupRTC(){
// RTC (Real-Time Clock)
RTC.begin();
// RTC Running
if (! RTC.isrunning()) {
// following line sets the RTC to the date & time
//this sketch was compiled
RTC.adjust(DateTime(__DATE__, __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;
}
// RTC (Real-Time Clock) // Setup RTC void isSetupRTC(){ // RTC (Real-Time Clock) RTC.begin(); // RTC Running if (! RTC.isrunning()) { // following line sets the RTC to the date & time //this sketch was compiled RTC.adjust(DateTime(__DATE__, __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; }
// RTC (Real-Time Clock)
// Setup RTC
void isSetupRTC(){

  // RTC (Real-Time Clock)
  RTC.begin();

  // RTC Running
  if (! RTC.isrunning()) {
    
    // following line sets the RTC to the date & time
    //this sketch was compiled
    RTC.adjust(DateTime(__DATE__, __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;

}

getSoilMoisture.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// Crowtail Moisture Sensor
// Soil Moisture
void isSoilMoisture(){
// Connect Soil Moisture Sensor to Analog 0
// iSoilMoistureVal => 0~700 Soil Moisture
iSoilMoistureVal = analogRead( iSoilMoisture );
// Threshold => 200~500
zz = analogRead( iPotentiometer );
Threshold = map( zz, 0, 1024, 200, 500);
// Threshold
if (iSoilMoistureVal > Threshold) {
// 300~700 - Humid Soil
// LED Yellow
digitalWrite(iLEDYellow, LOW);
// Display Green
isDisplayG();
// LED Green
digitalWrite(iLEDGreen, HIGH);
}
else {
// 0-300 Dry Soil
// LED Green
digitalWrite(iLEDGreen, LOW);
// Display Yellow
isDisplayY();
digitalWrite(iLEDYellow, HIGH);
}
}
// Crowtail Moisture Sensor // Soil Moisture void isSoilMoisture(){ // Connect Soil Moisture Sensor to Analog 0 // iSoilMoistureVal => 0~700 Soil Moisture iSoilMoistureVal = analogRead( iSoilMoisture ); // Threshold => 200~500 zz = analogRead( iPotentiometer ); Threshold = map( zz, 0, 1024, 200, 500); // Threshold if (iSoilMoistureVal > Threshold) { // 300~700 - Humid Soil // LED Yellow digitalWrite(iLEDYellow, LOW); // Display Green isDisplayG(); // LED Green digitalWrite(iLEDGreen, HIGH); } else { // 0-300 Dry Soil // LED Green digitalWrite(iLEDGreen, LOW); // Display Yellow isDisplayY(); digitalWrite(iLEDYellow, HIGH); } }
// Crowtail Moisture Sensor
// Soil Moisture
void isSoilMoisture(){

  // Connect Soil Moisture Sensor to Analog 0
  // iSoilMoistureVal => 0~700 Soil Moisture
  iSoilMoistureVal = analogRead( iSoilMoisture );

  // Threshold => 200~500
  zz = analogRead( iPotentiometer );
  Threshold = map( zz, 0, 1024, 200, 500);

  // Threshold
  if (iSoilMoistureVal > Threshold) {

    // 300~700 - Humid Soil
    // LED Yellow
    digitalWrite(iLEDYellow, LOW);
    // Display Green
    isDisplayG();
    // LED Green
    digitalWrite(iLEDGreen, HIGH);
    
  }
  else {
    
    // 0-300 Dry Soil
    // LED Green
    digitalWrite(iLEDGreen, LOW);
    // Display Yellow
    isDisplayY();
    digitalWrite(iLEDYellow, HIGH);
    
  }

}

getTH.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// Temperature and Humidity Sensor
void isTH(){
// Temperature
t = dht.readTemperature();
// Humidity
h = dht.readHumidity();
}
// Temperature and Humidity Sensor void isTH(){ // Temperature t = dht.readTemperature(); // Humidity h = dht.readHumidity(); }
// Temperature and Humidity Sensor
void isTH(){

  // Temperature
  t = dht.readTemperature();
  // Humidity
  h = dht.readHumidity();
  
}

setup.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// Setup
void setup()
{
// Delay
delay(100);
// isUID EEPROM Unique ID
isUID();
// Delay
delay(100);
// Initialize the LED iLED Yellow
pinMode(iLEDYellow, OUTPUT);
// Initialize the LED LED Green
pinMode(iLEDGreen, OUTPUT);
// Temperature and Humidity Sensor
dht.begin();
// Delay
delay(100);
// Setup RTC
isSetupRTC();
// Delay
delay(100);
// GPS Receiver
// Setup GPS
ss.begin(GPSBaud);
// Delay
delay(100);
// Display UID
isDisplayUID();
// Delay 5 Second
delay( 5000 );
}
// Setup void setup() { // Delay delay(100); // isUID EEPROM Unique ID isUID(); // Delay delay(100); // Initialize the LED iLED Yellow pinMode(iLEDYellow, OUTPUT); // Initialize the LED LED Green pinMode(iLEDGreen, OUTPUT); // Temperature and Humidity Sensor dht.begin(); // Delay delay(100); // Setup RTC isSetupRTC(); // Delay delay(100); // GPS Receiver // Setup GPS ss.begin(GPSBaud); // Delay delay(100); // Display UID isDisplayUID(); // Delay 5 Second delay( 5000 ); }
// Setup
void setup()
{
 
  // Delay
  delay(100);
  
  // isUID EEPROM Unique ID
  isUID();
  
  // Delay
  delay(100);

  // Initialize the LED iLED Yellow
  pinMode(iLEDYellow, OUTPUT);

  // Initialize the LED LED Green
  pinMode(iLEDGreen, OUTPUT);

  // Temperature and Humidity Sensor
  dht.begin();

  // Delay
  delay(100);
  
  // Setup RTC
  isSetupRTC();
  
  // Delay
  delay(100);

  // GPS Receiver
  // Setup GPS
  ss.begin(GPSBaud);
  
  // Delay
  delay(100);

  // Display UID
  isDisplayUID();
  
  // Delay 5 Second
  delay( 5000 );

}

——

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

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

  • Programming Language
  • Single-Board 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

Follow Us

Luc Paquin – Curriculum Vitae – 2024
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
Hackster.io: https://www.hackster.io/neosteam-labs
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

Project #25 – Movement – GPS Receiver – Mk11

——

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

——

GPS Receiver

——

GPS Receiver

——

GPS Receiver

——

Global Positioning System (GPS)

The Global Positioning System (GPS) is a satellite-based radionavigation system owned by the United States government 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″ 320×240 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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
/****** 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 );
}
/****** 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 ); }
/****** 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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// 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]);
}
}
// 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]); } }
// 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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// 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]);
}
}
// 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]); } }
// 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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// 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 );
}
// 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 ); }
// 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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// 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]);
}
}
// 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]); } }
// 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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// 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]);
}
}
// 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]); } }
// 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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// 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]);
}
}
// 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]); } }
// 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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// 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 );
}
// 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 ); }
// 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: https://www.donluc.com/?page_id=1927

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

  • Programming Language
  • Single-Board 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

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
Hackster.io: https://www.hackster.io/neosteam-labs
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

Project #15: Environment – RTC – Mk26

——

#DonLucElectronics #DonLuc #Arduino #RTC #EEPROM #DHT11 #ASM #Display #Elecrow #Project #Patreon #Electronics #Microcontrollers #IoT #Fritzing #Programming #Consultant

——

RTC

——

RTC

——

RTC

——

Crowtail – RTC 2.0

If you want to make your own electronic watch a RTC module is necessary to generate you the right time, with very low power consumption. This tiny RTC module is based on the clock chip DS1307 which communicates with microcontrollers with I2C protocol. The clock/calendar provides seconds, minutes, hours, day, date, month, and year information. The end of the month date is automatically adjusted for months with fewer than 31 days, including corrections for leap year. This module is really low power consumption, it can serves you more than a month with a CR1220 battery.

DL2502Mk02

1 x Crowduino Uno – SD
1 x Crowtail – Base Shield
1 x Crowtail – RTC 2.0
1 x Crowtail – Temperature and Humidity Sensor 2.0
1 x Crowtail – Rotary Angle Sensor 2.0
1 x Crowtail – Moisture Sensor 2.0
1 x Crowtail – I2C LCD
1 x Crowtail – LED(Green)
1 x Crowtail – LED(Yellow)
1 x USB Battery Pack
1 x USB Mini-B Cable

Crowduino Uno – SD

SCL – A5
SDA – A4
POT – A1
ASM – A0
LEDY – 7
LEDG – 6
ITH – 5
VIN – +5V
GND – GND

DL2502Mk02p

DL2502Mk02p.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
/****** Don Luc Electronics © ******
Software Version Information
Project #15: Environment – RTC – Mk26
DL2502Mk02p.ino
DL2502Mk02
1 x Crowduino Uno - SD
1 x Crowtail - Base Shield
1 x Crowtail - RTC 2.0
1 x Crowtail - Temperature and Humidity Sensor 2.0
1 x Crowtail - Rotary Angle Sensor 2.0
1 x Crowtail - Moisture Sensor 2.0
1 x Crowtail - I2C LCD
1 x Crowtail - LED(Green)
1 x Crowtail - LED(Yellow)
1 x USB Battery Pack
1 x USB Mini-B Cable
*/
// Include the Library Code
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>
// Wire
#include <Wire.h>
// Liquid Crystal
#include "LiquidCrystal.h"
// Temperature and Humidity Sensor
#include "DHT.h"
// RTC (Real-Time Clock)
#include "RTClib.h"
// RTC (Real-Time Clock)
RTC_DS1307 RTC;
String dateRTC = "";
String timeRTC = "";
// Temperature and Humidity Sensor
#define DHTPIN 5
// DHT 11
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
// Temperature and Humidity Sensor
float h = 0;
float t = 0;
// Potentiometer
int iPotentiometer = A1;
// Change Your Threshold Here
int Threshold = 0;
int zz = 0;
// Liquid Crystal
// Connect via i2c
LiquidCrystal lcd(0);
// Crowtail Moisture Sensor
int iSoilMoisture = A0;
int iSoilMoistureVal = 0;
// LED Yellow
int iLEDYellow = 7;
// LED Green
int iLEDGreen = 6;
// EEPROM Unique ID Information
String uid = "";
// Software Version Information
String sver = "15-26";
void loop() {
// Crowtail Moisture Sensor
isSoilMoisture();
// Temperature and Humidity Sensor
isTH();
// RTC (Real-Time Clock)
isRTC();
// Delay 2 Second
delay( 2000 );
// Display Temperature and Humidity
isDisplayTH();
// Delay 2 Second
delay( 2000 );
// Display EEPROM
isDisplayEEPROM();
// Delay 2 Second
delay( 2000 );
// Display RTC
isDisplayRTC();
// Delay 2 Second
delay( 2000 );
}
/****** Don Luc Electronics © ****** Software Version Information Project #15: Environment – RTC – Mk26 DL2502Mk02p.ino DL2502Mk02 1 x Crowduino Uno - SD 1 x Crowtail - Base Shield 1 x Crowtail - RTC 2.0 1 x Crowtail - Temperature and Humidity Sensor 2.0 1 x Crowtail - Rotary Angle Sensor 2.0 1 x Crowtail - Moisture Sensor 2.0 1 x Crowtail - I2C LCD 1 x Crowtail - LED(Green) 1 x Crowtail - LED(Yellow) 1 x USB Battery Pack 1 x USB Mini-B Cable */ // Include the Library Code // EEPROM library to read and write EEPROM with unique ID for unit #include <EEPROM.h> // Wire #include <Wire.h> // Liquid Crystal #include "LiquidCrystal.h" // Temperature and Humidity Sensor #include "DHT.h" // RTC (Real-Time Clock) #include "RTClib.h" // RTC (Real-Time Clock) RTC_DS1307 RTC; String dateRTC = ""; String timeRTC = ""; // Temperature and Humidity Sensor #define DHTPIN 5 // DHT 11 #define DHTTYPE DHT11 DHT dht(DHTPIN, DHTTYPE); // Temperature and Humidity Sensor float h = 0; float t = 0; // Potentiometer int iPotentiometer = A1; // Change Your Threshold Here int Threshold = 0; int zz = 0; // Liquid Crystal // Connect via i2c LiquidCrystal lcd(0); // Crowtail Moisture Sensor int iSoilMoisture = A0; int iSoilMoistureVal = 0; // LED Yellow int iLEDYellow = 7; // LED Green int iLEDGreen = 6; // EEPROM Unique ID Information String uid = ""; // Software Version Information String sver = "15-26"; void loop() { // Crowtail Moisture Sensor isSoilMoisture(); // Temperature and Humidity Sensor isTH(); // RTC (Real-Time Clock) isRTC(); // Delay 2 Second delay( 2000 ); // Display Temperature and Humidity isDisplayTH(); // Delay 2 Second delay( 2000 ); // Display EEPROM isDisplayEEPROM(); // Delay 2 Second delay( 2000 ); // Display RTC isDisplayRTC(); // Delay 2 Second delay( 2000 ); }
/****** Don Luc Electronics © ******
Software Version Information
Project #15: Environment – RTC – Mk26
DL2502Mk02p.ino
DL2502Mk02
1 x Crowduino Uno - SD
1 x Crowtail - Base Shield
1 x Crowtail - RTC 2.0
1 x Crowtail - Temperature and Humidity Sensor 2.0
1 x Crowtail - Rotary Angle Sensor 2.0
1 x Crowtail - Moisture Sensor 2.0
1 x Crowtail - I2C LCD
1 x Crowtail - LED(Green)
1 x Crowtail - LED(Yellow)
1 x USB Battery Pack
1 x USB Mini-B Cable
*/

// Include the Library Code
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>
// Wire
#include <Wire.h>
// Liquid Crystal
#include "LiquidCrystal.h"
// Temperature and Humidity Sensor
#include "DHT.h"
// RTC (Real-Time Clock)
#include "RTClib.h"

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

// Temperature and Humidity Sensor
#define DHTPIN 5
// DHT 11
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
// Temperature and Humidity Sensor
float h = 0;
float t = 0;

// Potentiometer
int iPotentiometer = A1;
// Change Your Threshold Here
int Threshold = 0;
int zz = 0;

// Liquid Crystal
// Connect via i2c
LiquidCrystal lcd(0);

// Crowtail Moisture Sensor
int iSoilMoisture = A0;
int iSoilMoistureVal = 0;

// LED Yellow
int iLEDYellow = 7;

// LED Green
int iLEDGreen = 6;

// EEPROM Unique ID Information
String uid = "";

// Software Version Information
String sver = "15-26";

void loop() {

  // Crowtail Moisture Sensor
  isSoilMoisture();

  // Temperature and Humidity Sensor
  isTH();

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

  // Delay 2 Second
  delay( 2000 );

  // Display Temperature and Humidity
  isDisplayTH();

  // Delay 2 Second
  delay( 2000 );

  // Display EEPROM
  isDisplayEEPROM();

  // Delay 2 Second
  delay( 2000 );

  // Display RTC
  isDisplayRTC();

  // Delay 2 Second
  delay( 2000 );

}

getDisplay.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
/****** Don Luc Electronics © ******
Software Version Information
Project #15: Environment – RTC – Mk26
DL2502Mk02p.ino
DL2502Mk02
1 x Crowduino Uno - SD
1 x Crowtail - Base Shield
1 x Crowtail - RTC 2.0
1 x Crowtail - Temperature and Humidity Sensor 2.0
1 x Crowtail - Rotary Angle Sensor 2.0
1 x Crowtail - Moisture Sensor 2.0
1 x Crowtail - I2C LCD
1 x Crowtail - LED(Green)
1 x Crowtail - LED(Yellow)
1 x USB Battery Pack
1 x USB Mini-B Cable
*/
// Include the Library Code
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>
// Wire
#include <Wire.h>
// Liquid Crystal
#include "LiquidCrystal.h"
// Temperature and Humidity Sensor
#include "DHT.h"
// RTC (Real-Time Clock)
#include "RTClib.h"
// RTC (Real-Time Clock)
RTC_DS1307 RTC;
String dateRTC = "";
String timeRTC = "";
// Temperature and Humidity Sensor
#define DHTPIN 5
// DHT 11
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
// Temperature and Humidity Sensor
float h = 0;
float t = 0;
// Potentiometer
int iPotentiometer = A1;
// Change Your Threshold Here
int Threshold = 0;
int zz = 0;
// Liquid Crystal
// Connect via i2c
LiquidCrystal lcd(0);
// Crowtail Moisture Sensor
int iSoilMoisture = A0;
int iSoilMoistureVal = 0;
// LED Yellow
int iLEDYellow = 7;
// LED Green
int iLEDGreen = 6;
// EEPROM Unique ID Information
String uid = "";
// Software Version Information
String sver = "15-26";
void loop() {
// Crowtail Moisture Sensor
isSoilMoisture();
// Temperature and Humidity Sensor
isTH();
// RTC (Real-Time Clock)
isRTC();
// Delay 2 Second
delay( 2000 );
// Display Temperature and Humidity
isDisplayTH();
// Delay 2 Second
delay( 2000 );
// Display EEPROM
isDisplayEEPROM();
// Delay 2 Second
delay( 2000 );
// Display RTC
isDisplayRTC();
// Delay 2 Second
delay( 2000 );
}
/****** Don Luc Electronics © ****** Software Version Information Project #15: Environment – RTC – Mk26 DL2502Mk02p.ino DL2502Mk02 1 x Crowduino Uno - SD 1 x Crowtail - Base Shield 1 x Crowtail - RTC 2.0 1 x Crowtail - Temperature and Humidity Sensor 2.0 1 x Crowtail - Rotary Angle Sensor 2.0 1 x Crowtail - Moisture Sensor 2.0 1 x Crowtail - I2C LCD 1 x Crowtail - LED(Green) 1 x Crowtail - LED(Yellow) 1 x USB Battery Pack 1 x USB Mini-B Cable */ // Include the Library Code // EEPROM library to read and write EEPROM with unique ID for unit #include <EEPROM.h> // Wire #include <Wire.h> // Liquid Crystal #include "LiquidCrystal.h" // Temperature and Humidity Sensor #include "DHT.h" // RTC (Real-Time Clock) #include "RTClib.h" // RTC (Real-Time Clock) RTC_DS1307 RTC; String dateRTC = ""; String timeRTC = ""; // Temperature and Humidity Sensor #define DHTPIN 5 // DHT 11 #define DHTTYPE DHT11 DHT dht(DHTPIN, DHTTYPE); // Temperature and Humidity Sensor float h = 0; float t = 0; // Potentiometer int iPotentiometer = A1; // Change Your Threshold Here int Threshold = 0; int zz = 0; // Liquid Crystal // Connect via i2c LiquidCrystal lcd(0); // Crowtail Moisture Sensor int iSoilMoisture = A0; int iSoilMoistureVal = 0; // LED Yellow int iLEDYellow = 7; // LED Green int iLEDGreen = 6; // EEPROM Unique ID Information String uid = ""; // Software Version Information String sver = "15-26"; void loop() { // Crowtail Moisture Sensor isSoilMoisture(); // Temperature and Humidity Sensor isTH(); // RTC (Real-Time Clock) isRTC(); // Delay 2 Second delay( 2000 ); // Display Temperature and Humidity isDisplayTH(); // Delay 2 Second delay( 2000 ); // Display EEPROM isDisplayEEPROM(); // Delay 2 Second delay( 2000 ); // Display RTC isDisplayRTC(); // Delay 2 Second delay( 2000 ); }
/****** Don Luc Electronics © ******
Software Version Information
Project #15: Environment – RTC – Mk26
DL2502Mk02p.ino
DL2502Mk02
1 x Crowduino Uno - SD
1 x Crowtail - Base Shield
1 x Crowtail - RTC 2.0
1 x Crowtail - Temperature and Humidity Sensor 2.0
1 x Crowtail - Rotary Angle Sensor 2.0
1 x Crowtail - Moisture Sensor 2.0
1 x Crowtail - I2C LCD
1 x Crowtail - LED(Green)
1 x Crowtail - LED(Yellow)
1 x USB Battery Pack
1 x USB Mini-B Cable
*/

// Include the Library Code
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>
// Wire
#include <Wire.h>
// Liquid Crystal
#include "LiquidCrystal.h"
// Temperature and Humidity Sensor
#include "DHT.h"
// RTC (Real-Time Clock)
#include "RTClib.h"

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

// Temperature and Humidity Sensor
#define DHTPIN 5
// DHT 11
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
// Temperature and Humidity Sensor
float h = 0;
float t = 0;

// Potentiometer
int iPotentiometer = A1;
// Change Your Threshold Here
int Threshold = 0;
int zz = 0;

// Liquid Crystal
// Connect via i2c
LiquidCrystal lcd(0);

// Crowtail Moisture Sensor
int iSoilMoisture = A0;
int iSoilMoistureVal = 0;

// LED Yellow
int iLEDYellow = 7;

// LED Green
int iLEDGreen = 6;

// EEPROM Unique ID Information
String uid = "";

// Software Version Information
String sver = "15-26";

void loop() {

  // Crowtail Moisture Sensor
  isSoilMoisture();

  // Temperature and Humidity Sensor
  isTH();

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

  // Delay 2 Second
  delay( 2000 );

  // Display Temperature and Humidity
  isDisplayTH();

  // Delay 2 Second
  delay( 2000 );

  // Display EEPROM
  isDisplayEEPROM();

  // Delay 2 Second
  delay( 2000 );

  // Display RTC
  isDisplayRTC();

  // Delay 2 Second
  delay( 2000 );

}

getEEPROM.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// EEPROM
// isUID EEPROM Unique ID
void isUID() {
// Is Unit ID
uid = "";
for (int x = 0; x < 7; x++)
{
uid = uid + char(EEPROM.read(x));
}
}
// EEPROM // isUID EEPROM Unique ID void isUID() { // Is Unit ID uid = ""; for (int x = 0; x < 7; x++) { uid = uid + char(EEPROM.read(x)); } }
// EEPROM
// isUID EEPROM Unique ID
void isUID() {
  
  // Is Unit ID
  uid = "";
  for (int x = 0; x < 7; x++)
  {
    uid = uid + char(EEPROM.read(x));
  }
  
}

getRTC.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// RTC (Real-Time Clock)
// Setup RTC
void isSetupRTC(){
// RTC (Real-Time Clock)
RTC.begin();
// RTC Running
if (! RTC.isrunning()) {
// following line sets the RTC to the date & time
//this sketch was compiled
RTC.adjust(DateTime(__DATE__, __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;
}
// RTC (Real-Time Clock) // Setup RTC void isSetupRTC(){ // RTC (Real-Time Clock) RTC.begin(); // RTC Running if (! RTC.isrunning()) { // following line sets the RTC to the date & time //this sketch was compiled RTC.adjust(DateTime(__DATE__, __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; }
// RTC (Real-Time Clock)
// Setup RTC
void isSetupRTC(){

  // RTC (Real-Time Clock)
  RTC.begin();

  // RTC Running
  if (! RTC.isrunning()) {
    
    // following line sets the RTC to the date & time
    //this sketch was compiled
    RTC.adjust(DateTime(__DATE__, __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;

}

getSoilMoisture.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// Crowtail Moisture Sensor
// Soil Moisture
void isSoilMoisture(){
// Connect Soil Moisture Sensor to Analog 0
// iSoilMoistureVal => 0~700 Soil Moisture
iSoilMoistureVal = analogRead( iSoilMoisture );
// Threshold => 200~500
zz = analogRead( iPotentiometer );
Threshold = map( zz, 0, 1024, 200, 500);
// Threshold
if (iSoilMoistureVal > Threshold) {
// 300~700 - Humid Soil
// LED Yellow
digitalWrite(iLEDYellow, LOW);
// Display Green
isDisplayG();
// LED Green
digitalWrite(iLEDGreen, HIGH);
}
else {
// 0-300 Dry Soil
// LED Green
digitalWrite(iLEDGreen, LOW);
// Display Yellow
isDisplayY();
digitalWrite(iLEDYellow, HIGH);
}
}
// Crowtail Moisture Sensor // Soil Moisture void isSoilMoisture(){ // Connect Soil Moisture Sensor to Analog 0 // iSoilMoistureVal => 0~700 Soil Moisture iSoilMoistureVal = analogRead( iSoilMoisture ); // Threshold => 200~500 zz = analogRead( iPotentiometer ); Threshold = map( zz, 0, 1024, 200, 500); // Threshold if (iSoilMoistureVal > Threshold) { // 300~700 - Humid Soil // LED Yellow digitalWrite(iLEDYellow, LOW); // Display Green isDisplayG(); // LED Green digitalWrite(iLEDGreen, HIGH); } else { // 0-300 Dry Soil // LED Green digitalWrite(iLEDGreen, LOW); // Display Yellow isDisplayY(); digitalWrite(iLEDYellow, HIGH); } }
// Crowtail Moisture Sensor
// Soil Moisture
void isSoilMoisture(){

  // Connect Soil Moisture Sensor to Analog 0
  // iSoilMoistureVal => 0~700 Soil Moisture
  iSoilMoistureVal = analogRead( iSoilMoisture );

  // Threshold => 200~500
  zz = analogRead( iPotentiometer );
  Threshold = map( zz, 0, 1024, 200, 500);

  // Threshold
  if (iSoilMoistureVal > Threshold) {

    // 300~700 - Humid Soil
    // LED Yellow
    digitalWrite(iLEDYellow, LOW);
    // Display Green
    isDisplayG();
    // LED Green
    digitalWrite(iLEDGreen, HIGH);
    
  }
  else {
    
    // 0-300 Dry Soil
    // LED Green
    digitalWrite(iLEDGreen, LOW);
    // Display Yellow
    isDisplayY();
    digitalWrite(iLEDYellow, HIGH);
    
  }

}

getTH.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// Temperature and Humidity Sensor
void isTH(){
// Temperature
t = dht.readTemperature();
// Humidity
h = dht.readHumidity();
}
// Temperature and Humidity Sensor void isTH(){ // Temperature t = dht.readTemperature(); // Humidity h = dht.readHumidity(); }
// Temperature and Humidity Sensor
void isTH(){

  // Temperature
  t = dht.readTemperature();
  // Humidity
  h = dht.readHumidity();
  
}

setup.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// Setup
void setup()
{
// Delay
delay(100);
// isUID EEPROM Unique ID
isUID();
// Delay
delay(100);
// Initialize the LED iLED Yellow
pinMode(iLEDYellow, OUTPUT);
// Initialize the LED LED Green
pinMode(iLEDGreen, OUTPUT);
// Temperature and Humidity Sensor
dht.begin();
// Delay
delay(100);
// Setup RTC
isSetupRTC();
// Delay
delay(100);
// Display UID
isDisplayUID();
// Delay 5 Second
delay( 5000 );
}
// Setup void setup() { // Delay delay(100); // isUID EEPROM Unique ID isUID(); // Delay delay(100); // Initialize the LED iLED Yellow pinMode(iLEDYellow, OUTPUT); // Initialize the LED LED Green pinMode(iLEDGreen, OUTPUT); // Temperature and Humidity Sensor dht.begin(); // Delay delay(100); // Setup RTC isSetupRTC(); // Delay delay(100); // Display UID isDisplayUID(); // Delay 5 Second delay( 5000 ); }
// Setup
void setup()
{
 
  // Delay
  delay(100);
  
  // isUID EEPROM Unique ID
  isUID();
  
  // Delay
  delay(100);

  // Initialize the LED iLED Yellow
  pinMode(iLEDYellow, OUTPUT);

  // Initialize the LED LED Green
  pinMode(iLEDGreen, OUTPUT);

  // Temperature and Humidity Sensor
  dht.begin();

  // Delay
  delay(100);
  
  // Setup RTC
  isSetupRTC();
  
  // Delay
  delay(100);

  // Display UID
  isDisplayUID();
  
  // Delay 5 Second
  delay( 5000 );

}

——

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

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

  • Programming Language
  • Single-Board 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

Follow Us

Luc Paquin – Curriculum Vitae – 2024
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
Hackster.io: https://www.hackster.io/neosteam-labs
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

Project #25 – Movement – RTC – Mk10

——

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

——

RTC

——

RTC

——

RTC

——

Adafruit DS3231 Precision RTC FeatherWing

This is the DS3231 Precision RTC FeatherWing: it adds an extremely accurate I2C-integrated Real Time Clock (RTC) with a Temperature Compensated Crystal Oscillator to any Feather main board. This RTC is the most precise you can get in a small, low power package. Most RTCs use an external 32kHz timing crystal that is used to keep time with low current draw. And that’s all well and good, but those crystals have slight drift, particularly when the temperature changes (the temperature changes the oscillation frequency very very very slightly but it does add up!) This RTC is in a beefy package because the crystal is inside the chip! And right next to the integrated crystal is a temperature sensor. That sensor compensates for the frequency changes by adding or removing clock ticks so that the timekeeping stays on schedule. With a CR1220 12mm coin cell plugged into the top of the FeatherWing, you can get years of precision timekeeping, even when main power is lost. Great for datalogging and clocks, or anything where you need to really know the time.

DL2502Mk01

1 x DFRobot FireBeetle 2 ESP32-E
1 x Fermion: 2.0″ 320×240 IPS TFT LCD
1 x GDL Line 10 CM
1 x Crowtail – I2C Hub 2.0
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
DC – D2
CS – D6
RST – D3
RX2 – Bluetooth
TX2 – Bluetooth
VIN – +3.3V
GND – GND

——

DL2502Mk01p

DL2502Mk01p.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
/****** Don Luc Electronics © ******
Software Version Information
Project #25 - Movement - RTC - Mk10
25-10
DL2502Mk01p.ino
DL2502Mk01
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 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"
// 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-10";
void loop() {
// Accelemeter ADXL345
isADXL345();
// Compass HMC5883L
isHMC5883L();
// isEEPROM
isEEPROM();
// RTC (Real-Time Clock)
isRTC();
// Accelemeter and Compass, ADXL345 and HMC5883L
isDisplayADXL345HMC5883L();
// Delay 0.5 Second
delay( 500 );
}
/****** Don Luc Electronics © ****** Software Version Information Project #25 - Movement - RTC - Mk10 25-10 DL2502Mk01p.ino DL2502Mk01 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 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" // 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-10"; void loop() { // Accelemeter ADXL345 isADXL345(); // Compass HMC5883L isHMC5883L(); // isEEPROM isEEPROM(); // RTC (Real-Time Clock) isRTC(); // Accelemeter and Compass, ADXL345 and HMC5883L isDisplayADXL345HMC5883L(); // Delay 0.5 Second delay( 500 ); }
/****** Don Luc Electronics © ******
Software Version Information
Project #25 - Movement - RTC - Mk10
25-10
DL2502Mk01p.ino
DL2502Mk01
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 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"

// 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-10";

void loop() {

  // Accelemeter ADXL345
  isADXL345();

  // Compass HMC5883L
  isHMC5883L();

  // isEEPROM
  isEEPROM();

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

  // Accelemeter and Compass, ADXL345 and HMC5883L
  isDisplayADXL345HMC5883L();

  // Delay 0.5 Second
  delay( 500 );

}

getAccelemeterADXL345.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// 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]);
}
}
// 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]); } }
// 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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// 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]);
}
}
// 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]); } }
// 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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// 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");
// Real-Time Clock
screen.setCursor(0, 60);
screen.println("Real-Time Clock");
// 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 );
}
// 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"); // Real-Time Clock screen.setCursor(0, 60); screen.println("Real-Time Clock"); // 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 ); }
// 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");
  // Real-Time Clock
  screen.setCursor(0, 60);
  screen.println("Real-Time Clock");
  // 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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// 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]);
}
}
// 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]); } }
// 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]);
    
  }
  
}

getRTC.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// 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]);
}
}
// 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]); } }
// 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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// Setup
void setup()
{
// Serial Begin
Serial.begin(115200);
Serial.println("Starting BLE work!");
// Bluetooth Serial
SerialBT.begin("DL2502Mk01");
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();
// DFRobot Display 240x320 - UID
// Don Luc Electronics
// Version
isDisplayUID();
// Delay 5 Second
delay( 5000 );
}
// Setup void setup() { // Serial Begin Serial.begin(115200); Serial.println("Starting BLE work!"); // Bluetooth Serial SerialBT.begin("DL2502Mk01"); 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(); // DFRobot Display 240x320 - UID // Don Luc Electronics // Version isDisplayUID(); // Delay 5 Second delay( 5000 ); }
// Setup
void setup()
{
 
  // Serial Begin
  Serial.begin(115200);
  Serial.println("Starting BLE work!");

  // Bluetooth Serial
  SerialBT.begin("DL2502Mk01");
  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();

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

  // Delay 5 Second
  delay( 5000 );

}

——

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

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

  • Programming Language
  • Single-Board 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

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
Hackster.io: https://www.hackster.io/neosteam-labs
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

Project #15: Environment – EEPROM – Mk25

——

#DonLucElectronics #DonLuc #Arduino #EEPROM #DHT11 #ASM #Display #Elecrow #Project #Patreon #Electronics #Microcontrollers #IoT #Fritzing #Programming #Consultant

——

EEPROM

——

EEPROM

——

EEPROM

——

EEPROM

EEPROM (Electrically Erasable Programmable Read-only Memory) is a type of non-volatile memory. EEPROM is a type of non-volatile ROM that enables individual bytes of data to be erased and reprogrammed. That is why EEPROM chips are known as byte erasable chips. EEPROM is usually used to store small amounts of data in computing and other electronic devices. It is used in computers, usually integrated in microcontrollers such as smart cards and remote keyless systems, or as a separate chip device, to store relatively small amounts of data by allowing individual bytes to be erased and reprogrammed.

DL2501Mk08

1 x Crowduino Uno – SD
1 x Crowtail – Base Shield
1 x Crowtail – Temperature and Humidity Sensor 2.0
1 x Crowtail – Rotary Angle Sensor 2.0
1 x Crowtail – Moisture Sensor 2.0
1 x Crowtail – I2C LCD
1 x Crowtail – LED(Green)
1 x Crowtail – LED(Yellow)
1 x USB Battery Pack
1 x USB Mini-B Cable

Crowduino Uno – SD

SCL – A5
SDA – A4
POT – A1
ASM – A0
LEDY – 7
LEDG – 6
ITH – 5
VIN – +5V
GND – GND

DLE-EEPROM-UID-UnoMk001

DLE-EEPROM-UID-UnoMk001.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
/* ***** Don Luc Electronics © ******
Software Version Information
DLE-EEPROM-UID-UnoMk001
Arduino UNO
5V
ver: UnoMk001
EEPROM with unique ID
*/
// Include Library Code
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>
// Software Version Information
String sver = "UnoMk001";
// Unit ID information
String uid = "DLEU001";
// Read Unique ID
// String ruid = "";
void loop()
{
// <== Write and Read EEPROM
isEEPROMw();
}
/* ***** Don Luc Electronics © ****** Software Version Information DLE-EEPROM-UID-UnoMk001 Arduino UNO 5V ver: UnoMk001 EEPROM with unique ID */ // Include Library Code // EEPROM library to read and write EEPROM with unique ID for unit #include <EEPROM.h> // Software Version Information String sver = "UnoMk001"; // Unit ID information String uid = "DLEU001"; // Read Unique ID // String ruid = ""; void loop() { // <== Write and Read EEPROM isEEPROMw(); }
/* ***** Don Luc Electronics © ******
Software Version Information
DLE-EEPROM-UID-UnoMk001
Arduino UNO
5V
ver: UnoMk001
EEPROM with unique ID
*/

// Include Library Code
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>

// Software Version Information
String sver = "UnoMk001";
// Unit ID information
String uid = "DLEU001"; 
// Read Unique ID
// String ruid = "";

void loop() 
{

   // <== Write and Read EEPROM 
   isEEPROMw();
  
}

getEEPROM.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// getEEPROM
// Write and Read EEPROM with Unique ID for Unit
void isEEPROMw() {
// Write EEPROM with Unique ID for Unit
int incb = 0;
int v = 0;
String emp = "";
String ruid = "";
// Set Unit ID
// The message starts with uid then is followed by 7 characters
// First clear a string buffer
emp = "";
// Loop through the 7 ID characters and write their ASCII (byte) value to the EEPROM
for (int y = 0; y < 7; y++)
{
// Get ASCII value of character
v = int(uid.charAt(y)); // + 5));
// Add the actual character to the buffer
emp = emp + uid.charAt(y + 5);
// Write the value to the EEPROM
EEPROM.write(y, v);
}
// Write EEPROM with Unique ID for Unit
Serial.println( "Write ID Information");
// Read ID Information
// Unit ID
for (int y = 0; y < 7; y++)
{
ruid = ruid + char(EEPROM.read(y));
}
// Read ID Information
Serial.print( "Read ID Information: ");
Serial.println( ruid );
Serial.println( "Ok!" );
ruid = "";
delay( 5000 );
}
// getEEPROM // Write and Read EEPROM with Unique ID for Unit void isEEPROMw() { // Write EEPROM with Unique ID for Unit int incb = 0; int v = 0; String emp = ""; String ruid = ""; // Set Unit ID // The message starts with uid then is followed by 7 characters // First clear a string buffer emp = ""; // Loop through the 7 ID characters and write their ASCII (byte) value to the EEPROM for (int y = 0; y < 7; y++) { // Get ASCII value of character v = int(uid.charAt(y)); // + 5)); // Add the actual character to the buffer emp = emp + uid.charAt(y + 5); // Write the value to the EEPROM EEPROM.write(y, v); } // Write EEPROM with Unique ID for Unit Serial.println( "Write ID Information"); // Read ID Information // Unit ID for (int y = 0; y < 7; y++) { ruid = ruid + char(EEPROM.read(y)); } // Read ID Information Serial.print( "Read ID Information: "); Serial.println( ruid ); Serial.println( "Ok!" ); ruid = ""; delay( 5000 ); }
// getEEPROM
// Write and Read EEPROM with Unique ID for Unit
void isEEPROMw() {
  
  // Write EEPROM with Unique ID for Unit
  int incb = 0;
  int v = 0;
  String emp = "";
  String ruid = "";
    
  // Set Unit ID
  // The message starts with uid then is followed by 7 characters 
  // First clear a string buffer
  emp = "";
  // Loop through the 7 ID characters and write their ASCII (byte) value to the EEPROM
  for (int y = 0; y < 7; y++)
  {
        
     // Get ASCII value of character
     v = int(uid.charAt(y)); // + 5));
     // Add the actual character to the buffer
     emp = emp + uid.charAt(y + 5);
     // Write the value to the EEPROM
     EEPROM.write(y, v);
         
  } 
    
  // Write EEPROM with Unique ID for Unit
  Serial.println( "Write ID Information");

  // Read ID Information
  // Unit ID
  for (int y = 0; y < 7; y++)
  {
    
    ruid = ruid + char(EEPROM.read(y));
    
  }
  
  // Read ID Information
  Serial.print( "Read ID Information: ");
  Serial.println( ruid );
  Serial.println( "Ok!" );
  ruid = "";

  delay( 5000 );
   
}

setup.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// Setup
void setup()
{
// Open the serial port at 9600 bps:
Serial.begin(9600);
// Serial
Serial.print( "Software Version Information: ");
Serial.println( sver );
Serial.print( "Unit ID Information: ");
Serial.println( uid );
delay(5000);
}
// Setup void setup() { // Open the serial port at 9600 bps: Serial.begin(9600); // Serial Serial.print( "Software Version Information: "); Serial.println( sver ); Serial.print( "Unit ID Information: "); Serial.println( uid ); delay(5000); }
// Setup
void setup() 
{

  // Open the serial port at 9600 bps:
  Serial.begin(9600);

  // Serial
  Serial.print( "Software Version Information: ");
  Serial.println( sver );
  Serial.print( "Unit ID Information: ");
  Serial.println( uid );
  
  delay(5000);
   
}

DL2501Mk08p

DL2501Mk08p.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
/****** Don Luc Electronics © ******
Software Version Information
Project #15: Environment – EEPROM – Mk25
DL2501Mk08p.ino
DL2501Mk08
1 x Crowduino Uno - SD
1 x Crowtail - Base Shield
1 x Crowtail - Temperature and Humidity Sensor 2.0
1 x Crowtail - Rotary Angle Sensor 2.0
1 x Crowtail - Moisture Sensor 2.0
1 x Crowtail - I2C LCD
1 x Crowtail - LED(Green)
1 x Crowtail - LED(Yellow)
1 x USB Battery Pack
1 x USB Mini-B Cable
*/
// Include the Library Code
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>
// Wire
#include <Wire.h>
// Liquid Crystal
#include "LiquidCrystal.h"
// Temperature and Humidity Sensor
#include "DHT.h"
// Temperature and Humidity Sensor
#define DHTPIN 5
// DHT 11
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
// Temperature and Humidity Sensor
float h = 0;
float t = 0;
// Potentiometer
int iPotentiometer = A1;
// Change Your Threshold Here
int Threshold = 0;
int zz = 0;
// Liquid Crystal
// Connect via i2c
LiquidCrystal lcd(0);
// Crowtail Moisture Sensor
int iSoilMoisture = A0;
int iSoilMoistureVal = 0;
// LED Yellow
int iLEDYellow = 7;
// LED Green
int iLEDGreen = 6;
// EEPROM Unique ID Information
String uid = "";
// Software Version Information
String sver = "15-25";
void loop() {
// Crowtail Moisture Sensor
isSoilMoisture();
// Temperature and Humidity Sensor
isTH();
// Delay 2 Second
delay( 2000 );
// Display Temperature and Humidity
isDisplayTH();
// Delay 2 Second
delay( 2000 );
// Display EEPROM
isDisplayEEPROM();
// Delay 2 Second
delay( 2000 );
}
/****** Don Luc Electronics © ****** Software Version Information Project #15: Environment – EEPROM – Mk25 DL2501Mk08p.ino DL2501Mk08 1 x Crowduino Uno - SD 1 x Crowtail - Base Shield 1 x Crowtail - Temperature and Humidity Sensor 2.0 1 x Crowtail - Rotary Angle Sensor 2.0 1 x Crowtail - Moisture Sensor 2.0 1 x Crowtail - I2C LCD 1 x Crowtail - LED(Green) 1 x Crowtail - LED(Yellow) 1 x USB Battery Pack 1 x USB Mini-B Cable */ // Include the Library Code // EEPROM library to read and write EEPROM with unique ID for unit #include <EEPROM.h> // Wire #include <Wire.h> // Liquid Crystal #include "LiquidCrystal.h" // Temperature and Humidity Sensor #include "DHT.h" // Temperature and Humidity Sensor #define DHTPIN 5 // DHT 11 #define DHTTYPE DHT11 DHT dht(DHTPIN, DHTTYPE); // Temperature and Humidity Sensor float h = 0; float t = 0; // Potentiometer int iPotentiometer = A1; // Change Your Threshold Here int Threshold = 0; int zz = 0; // Liquid Crystal // Connect via i2c LiquidCrystal lcd(0); // Crowtail Moisture Sensor int iSoilMoisture = A0; int iSoilMoistureVal = 0; // LED Yellow int iLEDYellow = 7; // LED Green int iLEDGreen = 6; // EEPROM Unique ID Information String uid = ""; // Software Version Information String sver = "15-25"; void loop() { // Crowtail Moisture Sensor isSoilMoisture(); // Temperature and Humidity Sensor isTH(); // Delay 2 Second delay( 2000 ); // Display Temperature and Humidity isDisplayTH(); // Delay 2 Second delay( 2000 ); // Display EEPROM isDisplayEEPROM(); // Delay 2 Second delay( 2000 ); }
/****** Don Luc Electronics © ******
Software Version Information
Project #15: Environment – EEPROM – Mk25
DL2501Mk08p.ino
DL2501Mk08
1 x Crowduino Uno - SD
1 x Crowtail - Base Shield
1 x Crowtail - Temperature and Humidity Sensor 2.0
1 x Crowtail - Rotary Angle Sensor 2.0
1 x Crowtail - Moisture Sensor 2.0
1 x Crowtail - I2C LCD
1 x Crowtail - LED(Green)
1 x Crowtail - LED(Yellow)
1 x USB Battery Pack
1 x USB Mini-B Cable
*/

// Include the Library Code
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>
// Wire
#include <Wire.h>
// Liquid Crystal
#include "LiquidCrystal.h"
// Temperature and Humidity Sensor
#include "DHT.h"

// Temperature and Humidity Sensor
#define DHTPIN 5
// DHT 11
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
// Temperature and Humidity Sensor
float h = 0;
float t = 0;

// Potentiometer
int iPotentiometer = A1;
// Change Your Threshold Here
int Threshold = 0;
int zz = 0;

// Liquid Crystal
// Connect via i2c
LiquidCrystal lcd(0);

// Crowtail Moisture Sensor
int iSoilMoisture = A0;
int iSoilMoistureVal = 0;

// LED Yellow
int iLEDYellow = 7;

// LED Green
int iLEDGreen = 6;

// EEPROM Unique ID Information
String uid = "";

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

void loop() {

  // Crowtail Moisture Sensor
  isSoilMoisture();

  // Temperature and Humidity Sensor
  isTH();

  // Delay 2 Second
  delay( 2000 );

  // Display Temperature and Humidity
  isDisplayTH();

  // Delay 2 Second
  delay( 2000 );

  // Display EEPROM
  isDisplayEEPROM();

  // Delay 2 Second
  delay( 2000 );

}

getDisplay.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// getDisplay
// Crowbits - OLED 128X64 UID
void isDisplayUID(){
// Set up the LCD's number of rows and columns:
lcd.begin(16, 2);
// Print a message to the LCD.
// Cursor
lcd.setCursor(0, 0);
lcd.print("Don Luc Electron");
// Cursor
lcd.setCursor(0, 1);
// Print a message to the LCD.
lcd.print( sver );
}
// isDisplay Green
void isDisplayG(){
// Print a message to the LCD
// Clear
lcd.clear();
// Cursor
lcd.setCursor(0, 0);
lcd.print("Humid Soil");
// Cursor
lcd.setCursor(0, 1);
// Print a message to the LCD
lcd.print( iSoilMoistureVal );
}
// isDisplay Yellow
void isDisplayY(){
// Print a message to the LCD
// Clear
lcd.clear();
// Cursor
lcd.setCursor(0, 0);
lcd.print("Dry Soil");
// Cursor
lcd.setCursor(0, 1);
// Print a message to the LCD
lcd.print( iSoilMoistureVal );
}
// Display Temperature and Humidity
void isDisplayTH(){
// Clear
lcd.clear();
// Set the cursor to column 0, line 0
lcd.setCursor(0, 0);
lcd.print("H: ");
lcd.print(h);
lcd.print(" %");
// Set the cursor to column 0, line 1
lcd.setCursor(0, 1);
lcd.print("T: ");
lcd.print(t);
lcd.print(" *C");
}
// Display EEPROM
void isDisplayEEPROM(){
// Clear
lcd.clear();
// Set the cursor to column 0, line 0
lcd.setCursor(0, 0);
lcd.print("EEPROM");
// Set the cursor to column 0, line 1
lcd.setCursor(0, 1);
lcd.print( uid );
}
// getDisplay // Crowbits - OLED 128X64 UID void isDisplayUID(){ // Set up the LCD's number of rows and columns: lcd.begin(16, 2); // Print a message to the LCD. // Cursor lcd.setCursor(0, 0); lcd.print("Don Luc Electron"); // Cursor lcd.setCursor(0, 1); // Print a message to the LCD. lcd.print( sver ); } // isDisplay Green void isDisplayG(){ // Print a message to the LCD // Clear lcd.clear(); // Cursor lcd.setCursor(0, 0); lcd.print("Humid Soil"); // Cursor lcd.setCursor(0, 1); // Print a message to the LCD lcd.print( iSoilMoistureVal ); } // isDisplay Yellow void isDisplayY(){ // Print a message to the LCD // Clear lcd.clear(); // Cursor lcd.setCursor(0, 0); lcd.print("Dry Soil"); // Cursor lcd.setCursor(0, 1); // Print a message to the LCD lcd.print( iSoilMoistureVal ); } // Display Temperature and Humidity void isDisplayTH(){ // Clear lcd.clear(); // Set the cursor to column 0, line 0 lcd.setCursor(0, 0); lcd.print("H: "); lcd.print(h); lcd.print(" %"); // Set the cursor to column 0, line 1 lcd.setCursor(0, 1); lcd.print("T: "); lcd.print(t); lcd.print(" *C"); } // Display EEPROM void isDisplayEEPROM(){ // Clear lcd.clear(); // Set the cursor to column 0, line 0 lcd.setCursor(0, 0); lcd.print("EEPROM"); // Set the cursor to column 0, line 1 lcd.setCursor(0, 1); lcd.print( uid ); }
// getDisplay
// Crowbits - OLED 128X64 UID
void isDisplayUID(){

  // Set up the LCD's number of rows and columns: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  // Cursor
  lcd.setCursor(0, 0);
  lcd.print("Don Luc Electron");
  // Cursor
  lcd.setCursor(0, 1);
  // Print a message to the LCD.
  lcd.print( sver );

}
// isDisplay Green
void isDisplayG(){

  // Print a message to the LCD
  // Clear
  lcd.clear();
  // Cursor
  lcd.setCursor(0, 0);
  lcd.print("Humid Soil");
  // Cursor
  lcd.setCursor(0, 1);
  // Print a message to the LCD
  lcd.print( iSoilMoistureVal );
  
}
// isDisplay Yellow
void isDisplayY(){

  // Print a message to the LCD
  // Clear
  lcd.clear();
  // Cursor
  lcd.setCursor(0, 0);
  lcd.print("Dry Soil");
  // Cursor
  lcd.setCursor(0, 1);
  // Print a message to the LCD
  lcd.print( iSoilMoistureVal );
  
}
// Display Temperature and Humidity
void isDisplayTH(){

  // Clear
  lcd.clear();
  // Set the cursor to column 0, line 0
  lcd.setCursor(0, 0);
  lcd.print("H: "); 
  lcd.print(h);
  lcd.print(" %");
  // Set the cursor to column 0, line 1
  lcd.setCursor(0, 1);
  lcd.print("T: "); 
  lcd.print(t);
  lcd.print(" *C");
  
}
// Display EEPROM
void isDisplayEEPROM(){

  // Clear
  lcd.clear();
  // Set the cursor to column 0, line 0
  lcd.setCursor(0, 0);
  lcd.print("EEPROM"); 
  // Set the cursor to column 0, line 1
  lcd.setCursor(0, 1);
  lcd.print( uid ); 

}

getEEPROM.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// EEPROM
// isUID EEPROM Unique ID
void isUID() {
// Is Unit ID
uid = "";
for (int x = 0; x < 7; x++)
{
uid = uid + char(EEPROM.read(x));
}
}
// EEPROM // isUID EEPROM Unique ID void isUID() { // Is Unit ID uid = ""; for (int x = 0; x < 7; x++) { uid = uid + char(EEPROM.read(x)); } }
// EEPROM
// isUID EEPROM Unique ID
void isUID() {
  
  // Is Unit ID
  uid = "";
  for (int x = 0; x < 7; x++)
  {
    uid = uid + char(EEPROM.read(x));
  }
  
}

getSoilMoisture.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// Crowtail Moisture Sensor
// Soil Moisture
void isSoilMoisture(){
// Connect Soil Moisture Sensor to Analog 0
// iSoilMoistureVal => 0~700 Soil Moisture
iSoilMoistureVal = analogRead( iSoilMoisture );
// Threshold => 200~500
zz = analogRead( iPotentiometer );
Threshold = map( zz, 0, 1024, 200, 500);
// Threshold
if (iSoilMoistureVal > Threshold) {
// 300~700 - Humid Soil
// LED Yellow
digitalWrite(iLEDYellow, LOW);
// Display Green
isDisplayG();
// LED Green
digitalWrite(iLEDGreen, HIGH);
}
else {
// 0-300 Dry Soil
// LED Green
digitalWrite(iLEDGreen, LOW);
// Display Yellow
isDisplayY();
digitalWrite(iLEDYellow, HIGH);
}
}
// Crowtail Moisture Sensor // Soil Moisture void isSoilMoisture(){ // Connect Soil Moisture Sensor to Analog 0 // iSoilMoistureVal => 0~700 Soil Moisture iSoilMoistureVal = analogRead( iSoilMoisture ); // Threshold => 200~500 zz = analogRead( iPotentiometer ); Threshold = map( zz, 0, 1024, 200, 500); // Threshold if (iSoilMoistureVal > Threshold) { // 300~700 - Humid Soil // LED Yellow digitalWrite(iLEDYellow, LOW); // Display Green isDisplayG(); // LED Green digitalWrite(iLEDGreen, HIGH); } else { // 0-300 Dry Soil // LED Green digitalWrite(iLEDGreen, LOW); // Display Yellow isDisplayY(); digitalWrite(iLEDYellow, HIGH); } }
// Crowtail Moisture Sensor
// Soil Moisture
void isSoilMoisture(){

  // Connect Soil Moisture Sensor to Analog 0
  // iSoilMoistureVal => 0~700 Soil Moisture
  iSoilMoistureVal = analogRead( iSoilMoisture );

  // Threshold => 200~500
  zz = analogRead( iPotentiometer );
  Threshold = map( zz, 0, 1024, 200, 500);

  // Threshold
  if (iSoilMoistureVal > Threshold) {

    // 300~700 - Humid Soil
    // LED Yellow
    digitalWrite(iLEDYellow, LOW);
    // Display Green
    isDisplayG();
    // LED Green
    digitalWrite(iLEDGreen, HIGH);
    
  }
  else {
    
    // 0-300 Dry Soil
    // LED Green
    digitalWrite(iLEDGreen, LOW);
    // Display Yellow
    isDisplayY();
    digitalWrite(iLEDYellow, HIGH);
    
  }

}

getTH.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// Temperature and Humidity Sensor
void isTH(){
// Temperature
t = dht.readTemperature();
// Humidity
h = dht.readHumidity();
}
// Temperature and Humidity Sensor void isTH(){ // Temperature t = dht.readTemperature(); // Humidity h = dht.readHumidity(); }
// Temperature and Humidity Sensor
void isTH(){

  // Temperature
  t = dht.readTemperature();
  // Humidity
  h = dht.readHumidity();
  
}

setup.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// Setup
void setup()
{
// Delay
delay(100);
// isUID EEPROM Unique ID
isUID();
// Delay
delay(100);
// Initialize the LED iLED Yellow
pinMode(iLEDYellow, OUTPUT);
// Initialize the LED LED Green
pinMode(iLEDGreen, OUTPUT);
// Temperature and Humidity Sensor
dht.begin();
// Display UID
isDisplayUID();
// Delay 5 Second
delay( 5000 );
}
// Setup void setup() { // Delay delay(100); // isUID EEPROM Unique ID isUID(); // Delay delay(100); // Initialize the LED iLED Yellow pinMode(iLEDYellow, OUTPUT); // Initialize the LED LED Green pinMode(iLEDGreen, OUTPUT); // Temperature and Humidity Sensor dht.begin(); // Display UID isDisplayUID(); // Delay 5 Second delay( 5000 ); }
// Setup
void setup()
{
 
  // Delay
  delay(100);
  
  // isUID EEPROM Unique ID
  isUID();
  
  // Delay
  delay(100);

  // Initialize the LED iLED Yellow
  pinMode(iLEDYellow, OUTPUT);

  // Initialize the LED LED Green
  pinMode(iLEDGreen, OUTPUT);

  // Temperature and Humidity Sensor
  dht.begin();

  // Display UID
  isDisplayUID();
  
  // Delay 5 Second
  delay( 5000 );

}

——

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

  • Programming Language
  • Single-Board 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

Follow Us

Luc Paquin – Curriculum Vitae – 2024
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
Hackster.io: https://www.hackster.io/neosteam-labs
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

Project #25 – Movement – EEPROM – Mk09

——

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

——

EEPROM

——

EEPROM

——

EEPROM

——

EEPROM

EEPROM (Electrically Erasable Programmable Read-only Memory) is a type of non-volatile memory. EEPROM is a type of non-volatile ROM that enables individual bytes of data to be erased and reprogrammed. That is why EEPROM chips are known as byte erasable chips. EEPROM is usually used to store small amounts of data in computing and other electronic devices. It is used in computers, usually integrated in microcontrollers such as smart cards and remote keyless systems, or as a separate chip device, to store relatively small amounts of data by allowing individual bytes to be erased and reprogrammed.

The microcontroller on the Arduino boards have 512 bytes of EEPROM: memory whose values are kept when the board is turned off. Functions in the EEPROM class are automatically included with the platform for your board, meaning you do not need to install any external libraries. The supported microcontrollers on the various Arduino have different amounts of EEPROM: 1024 bytes on the ATmega328P, 512 bytes on the ATmega168 and ATmega8, 4 KB (4096 bytes) on the ATmega1280 and ATmega2560. The Arduino boards have an emulated EEPROM space of 1024 bytes. The EEPROM library on ESP32 provides a reliable way to store data persistently, so that it remains accessible even when the power supply is disconnected. Unlike RAM, the data we save with the EEPROM library does not get lost when power is cut. This feature makes it an ideal choice for retaining configurations, settings, and other important data in embedded devices like the ESP32.

DL2501Mk07

1 x DFRobot FireBeetle 2 ESP32-E
1 x Fermion: 2.0″ 320×240 IPS TFT LCD
1 x GDL Line 10 CM
1 x Crowtail – I2C Hub 2.0
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
DC – D2
CS – D6
RST – D3
RX2 – Bluetooth
TX2 – Bluetooth
VIN – +3.3V
GND – GND

DLE-EEPROM-UID-ESP32Mk001

DLE-EEPROM-UID-ESP32Mk001.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
/* ***** Don Luc Electronics © ******
Software Version Information
DLE-EEPROM-UID-ESP32Mk001
ver: ESPMk001
EEPROM with unique ID
*/
// Include Library Code
// EEPROM library to read and write EEPROM with unique ID for unit
#include "EEPROM.h"
// The current address in the EEPROM (i.e. which byte
// we're going to write to next)
#define EEPROM_SIZE 64
// Software Version Information
String sver = "ESPMk001";
// Unit ID information
String uid = "DLE0001";
// Read Unique ID
// String ruid = "";
void loop()
{
// <== Write and Read EEPROM
isEEPROMw();
}
/* ***** Don Luc Electronics © ****** Software Version Information DLE-EEPROM-UID-ESP32Mk001 ver: ESPMk001 EEPROM with unique ID */ // Include Library Code // EEPROM library to read and write EEPROM with unique ID for unit #include "EEPROM.h" // The current address in the EEPROM (i.e. which byte // we're going to write to next) #define EEPROM_SIZE 64 // Software Version Information String sver = "ESPMk001"; // Unit ID information String uid = "DLE0001"; // Read Unique ID // String ruid = ""; void loop() { // <== Write and Read EEPROM isEEPROMw(); }
/* ***** Don Luc Electronics © ******
Software Version Information
DLE-EEPROM-UID-ESP32Mk001
ver: ESPMk001
EEPROM with unique ID
*/

// Include Library Code
// EEPROM library to read and write EEPROM with unique ID for unit
#include "EEPROM.h"

// The current address in the EEPROM (i.e. which byte
// we're going to write to next)
#define EEPROM_SIZE 64

// Software Version Information
String sver = "ESPMk001";
// Unit ID information
String uid = "DLE0001"; 
// Read Unique ID
// String ruid = "";

void loop() 
{

   // <== Write and Read EEPROM 
   isEEPROMw();
  
}

getEEPROM.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// getEEPROM
// Write and Read EEPROM with Unique ID for Unit
void isEEPROMw() {
// EEPROM
int incb = 0;
int v = 0;
String msg = "";
String emp = "";
String ruid = "";
// Set Unit ID
// The message starts with sid then is followed by 5 characters
// First clear a string buffer
emp = "";
// Loop through the 7 ID characters and write their ASCII (byte) value to the EEPROM
for (int x = 0; x < 7; x++)
{
// Get ASCII value of character
v = int(uid.charAt(x)); // + 5));
// Add the actual character to the buffer so we can send it back to the PC
emp = emp + uid.charAt(x + 5);
// Write the value to the EEPROM
EEPROM.write(x, v);
EEPROM.commit();
}
delay( 500 );
// Write EEPROM with Unique ID for Unit
Serial.println( "Write ID Information");
// Read ID Information
// Unit ID
for (int y = 0; y < 7; y++)
{
ruid = ruid + char(EEPROM.read(y));
}
// Read ID Information
Serial.print( "Read ID Information: ");
Serial.println( ruid );
Serial.println( "Ok!" );
ruid = "";
delay( 5000 );
}
// getEEPROM // Write and Read EEPROM with Unique ID for Unit void isEEPROMw() { // EEPROM int incb = 0; int v = 0; String msg = ""; String emp = ""; String ruid = ""; // Set Unit ID // The message starts with sid then is followed by 5 characters // First clear a string buffer emp = ""; // Loop through the 7 ID characters and write their ASCII (byte) value to the EEPROM for (int x = 0; x < 7; x++) { // Get ASCII value of character v = int(uid.charAt(x)); // + 5)); // Add the actual character to the buffer so we can send it back to the PC emp = emp + uid.charAt(x + 5); // Write the value to the EEPROM EEPROM.write(x, v); EEPROM.commit(); } delay( 500 ); // Write EEPROM with Unique ID for Unit Serial.println( "Write ID Information"); // Read ID Information // Unit ID for (int y = 0; y < 7; y++) { ruid = ruid + char(EEPROM.read(y)); } // Read ID Information Serial.print( "Read ID Information: "); Serial.println( ruid ); Serial.println( "Ok!" ); ruid = ""; delay( 5000 ); }
// getEEPROM
// Write and Read EEPROM with Unique ID for Unit
void isEEPROMw() {
  
  // EEPROM
  int incb = 0;
  int v = 0;
  String msg = "";
  String emp = "";
  String ruid = "";
  
  // Set Unit ID
  // The message starts with sid then is followed by 5 characters 
  // First clear a string buffer
  emp = "";
  // Loop through the 7 ID characters and write their ASCII (byte) value to the EEPROM
  for (int x = 0; x < 7; x++)
    {
       // Get ASCII value of character
       v = int(uid.charAt(x)); // + 5));
       // Add the actual character to the buffer so we can send it back to the PC
       emp = emp + uid.charAt(x + 5);
       // Write the value to the EEPROM
       EEPROM.write(x, v);
       EEPROM.commit();
    }

   delay( 500 );

   // Write EEPROM with Unique ID for Unit
   Serial.println( "Write ID Information");

  // Read ID Information
  // Unit ID
  for (int y = 0; y < 7; y++)
  {
    
    ruid = ruid + char(EEPROM.read(y));
    
  }
  
  // Read ID Information
  Serial.print( "Read ID Information: ");
  Serial.println( ruid );
  Serial.println( "Ok!" );
  ruid = "";

  delay( 5000 );
   
}

setup.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// Setup
void setup()
{
// EEPROM with unique ID
EEPROM.begin(EEPROM_SIZE);
// Open the serial port at 9600 bps:
Serial.begin(9600);
// Serial
Serial.print( "Software Version Information: ");
Serial.println( sver );
Serial.print( "Unit ID Information: ");
Serial.println( uid );
delay(5000);
}
// Setup void setup() { // EEPROM with unique ID EEPROM.begin(EEPROM_SIZE); // Open the serial port at 9600 bps: Serial.begin(9600); // Serial Serial.print( "Software Version Information: "); Serial.println( sver ); Serial.print( "Unit ID Information: "); Serial.println( uid ); delay(5000); }
// Setup
void setup() 
{

  // EEPROM with unique ID
  EEPROM.begin(EEPROM_SIZE);

  // Open the serial port at 9600 bps:
  Serial.begin(9600);

  // Serial
  Serial.print( "Software Version Information: ");
  Serial.println( sver );
  Serial.print( "Unit ID Information: ");
  Serial.println( uid );
  
  delay(5000);
   
}

——

DL2501Mk07p

DL2501Mk07p.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
/****** Don Luc Electronics © ******
Software Version Information
Project #25 - Movement - EEPROM - Mk09
25-09
DL2501Mk07p.ino
DL2501Mk07
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 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>
// 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-09";
void loop() {
// Accelemeter ADXL345
isADXL345();
// Compass HMC5883L
isHMC5883L();
// isEEPROM
isEEPROM();
// Accelemeter ADXL345 Compass HMC5883L Display
isDisplayADXL345HMC5883L();
// Delay 0.5 Second
delay( 500 );
}
/****** Don Luc Electronics © ****** Software Version Information Project #25 - Movement - EEPROM - Mk09 25-09 DL2501Mk07p.ino DL2501Mk07 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 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> // 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-09"; void loop() { // Accelemeter ADXL345 isADXL345(); // Compass HMC5883L isHMC5883L(); // isEEPROM isEEPROM(); // Accelemeter ADXL345 Compass HMC5883L Display isDisplayADXL345HMC5883L(); // Delay 0.5 Second delay( 500 ); }
/****** Don Luc Electronics © ******
Software Version Information
Project #25 - Movement - EEPROM - Mk09
25-09
DL2501Mk07p.ino
DL2501Mk07
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 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>

// 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-09";

void loop() {

  // Accelemeter ADXL345
  isADXL345();

  // Compass HMC5883L
  isHMC5883L();

  // isEEPROM
  isEEPROM();

  // Accelemeter ADXL345 Compass HMC5883L Display
  isDisplayADXL345HMC5883L();

  // Delay 0.5 Second
  delay( 500 );

}

getAccelemeterADXL345.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// 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]);
}
}
// 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]); } }
// 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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// 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]);
}
}
// 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]); } }
// 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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// 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");
// EEPROM
screen.setCursor(0, 60);
screen.println("EEPROM");
// 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 ADXL345
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 );
}
// 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"); // EEPROM screen.setCursor(0, 60); screen.println("EEPROM"); // 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 ADXL345 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 ); }
// 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");
  // EEPROM
  screen.setCursor(0, 60);
  screen.println("EEPROM");
  // 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 ADXL345
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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// 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]);
}
}
// 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]); } }
// 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]);
    
  }
  
}

setup.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// Setup
void setup()
{
// Serial Begin
Serial.begin(115200);
Serial.println("Starting BLE work!");
// Bluetooth Serial
SerialBT.begin("DL2501Mk07");
Serial.println("Bluetooth Started! Ready to pair...");
// Delay
delay( 100 );
// EEPROM Size
EEPROM.begin(EEPROM_SIZE);
// EEPROM Unique ID
isUID();
// Delay
delay(100);
// DFRobot Display 240x320
screen.begin();
// Delay
delay(100);
// Setup Accelemeter ADXL345
isSetupADXL345();
// Setup HMC5883L
isSetupHMC5883L();
// DFRobot Display 240x320 - UID
// Don Luc Electronics
// Version
isDisplayUID();
// Delay 5 Second
delay( 5000 );
}
// Setup void setup() { // Serial Begin Serial.begin(115200); Serial.println("Starting BLE work!"); // Bluetooth Serial SerialBT.begin("DL2501Mk07"); Serial.println("Bluetooth Started! Ready to pair..."); // Delay delay( 100 ); // EEPROM Size EEPROM.begin(EEPROM_SIZE); // EEPROM Unique ID isUID(); // Delay delay(100); // DFRobot Display 240x320 screen.begin(); // Delay delay(100); // Setup Accelemeter ADXL345 isSetupADXL345(); // Setup HMC5883L isSetupHMC5883L(); // DFRobot Display 240x320 - UID // Don Luc Electronics // Version isDisplayUID(); // Delay 5 Second delay( 5000 ); }
// Setup
void setup()
{
 
  // Serial Begin
  Serial.begin(115200);
  Serial.println("Starting BLE work!");

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

  // Delay
  delay( 100 );

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

  // DFRobot Display 240x320
  screen.begin();

  // Delay
  delay(100);

  // Setup Accelemeter ADXL345
  isSetupADXL345();

  // Setup HMC5883L
  isSetupHMC5883L();

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

  // Delay 5 Second
  delay( 5000 );

}

——

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

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

  • Programming Language
  • Single-Board 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

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
Hackster.io: https://www.hackster.io/neosteam-labs
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

Project #15: Environment – DHT11 – Mk24

——

#DonLucElectronics #DonLuc #Arduino #DHT11 #ASM #Display #Elecrow #Project #Patreon #Electronics #Microcontrollers #IoT #Fritzing #Programming #Consultant

——

DHT11

——

DHT11

——

DHT11

——

Crowtail – Temperature and Humidity Sensor 2.0

This module can help you detect the temperature and humidity of the environment of your house. The module contains a DHT11 Temperature and Humidity sensor that is a complex sensor with a calibrated digital signal out. It uses digital module acquisition technology and the temperature & humidity sensor technology. The sensor consists of a resistance-type moisture element and an NTC temperature measuring element. Because of the single-wire serial interface, it is easy to use the module.

  • -Work Voltage: 3.3 Volt ~ 5 Volt
  • -Measuring Range: Humidity: 20% – 90% RH
  • -Measuring Range: Temperature: 0 ~ 50 °C
  • -Signal Collecting Period: 2S
  • -Accuracy: Humidity: ±5% RH
  • -Accuracy: Temperature: ±2°C

DL2501Mk06

1 x Crowduino Uno – SD
1 x Crowtail – Base Shield
1 x Crowtail – Temperature and Humidity Sensor 2.0
1 x Crowtail – Rotary Angle Sensor 2.0
1 x Crowtail – Moisture Sensor 2.0
1 x Crowtail – I2C LCD
1 x Crowtail – LED(Green)
1 x Crowtail – LED(Yellow)
1 x USB Battery Pack
1 x USB Mini-B Cable

Crowduino Uno – SD

SCL – A5
SDA – A4
POT – A1
ASM – A0
LEDY – 7
LEDG – 6
ITH – 5
VIN – +5V
GND – GND

DL2501Mk06p

DL2501Mk06p.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
/****** Don Luc Electronics © ******
Software Version Information
Project #15: Environment – DHT11 – Mk24
DL2501Mk06p.ino
DL2501Mk06
1 x Crowduino Uno - SD
1 x Crowtail - Base Shield
1 x Crowtail - Temperature and Humidity Sensor 2.0
1 x Crowtail - Rotary Angle Sensor 2.0
1 x Crowtail - Moisture Sensor 2.0
1 x Crowtail - I2C LCD
1 x Crowtail - LED(Green)
1 x Crowtail - LED(Yellow)
1 x USB Battery Pack
1 x USB Mini-B Cable
*/
// Include the Library Code
// Wire
#include <Wire.h>
// Liquid Crystal
#include "LiquidCrystal.h"
// Temperature and Humidity Sensor
#include "DHT.h"
// Temperature and Humidity Sensor
#define DHTPIN 5
// DHT 11
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
// Temperature and Humidity Sensor
float h = 0;
float t = 0;
// Potentiometer
int iPotentiometer = A1;
// Change Your Threshold Here
int Threshold = 0;
int zz = 0;
// Liquid Crystal
// Connect via i2c
LiquidCrystal lcd(0);
// Crowtail Moisture Sensor
int iSoilMoisture = A0;
int iSoilMoistureVal = 0;
// LED Yellow
int iLEDYellow = 7;
// LED Green
int iLEDGreen = 6;
// Software Version Information
String sver = "15-24";
void loop() {
// Crowtail Moisture Sensor
isSoilMoisture();
// Temperature and Humidity Sensor
isTH();
// Delay 2 Second
delay( 2000 );
// Display Temperature and Humidity
isDisplayTH();
// Delay 2 Second
delay( 2000 );
}
/****** Don Luc Electronics © ****** Software Version Information Project #15: Environment – DHT11 – Mk24 DL2501Mk06p.ino DL2501Mk06 1 x Crowduino Uno - SD 1 x Crowtail - Base Shield 1 x Crowtail - Temperature and Humidity Sensor 2.0 1 x Crowtail - Rotary Angle Sensor 2.0 1 x Crowtail - Moisture Sensor 2.0 1 x Crowtail - I2C LCD 1 x Crowtail - LED(Green) 1 x Crowtail - LED(Yellow) 1 x USB Battery Pack 1 x USB Mini-B Cable */ // Include the Library Code // Wire #include <Wire.h> // Liquid Crystal #include "LiquidCrystal.h" // Temperature and Humidity Sensor #include "DHT.h" // Temperature and Humidity Sensor #define DHTPIN 5 // DHT 11 #define DHTTYPE DHT11 DHT dht(DHTPIN, DHTTYPE); // Temperature and Humidity Sensor float h = 0; float t = 0; // Potentiometer int iPotentiometer = A1; // Change Your Threshold Here int Threshold = 0; int zz = 0; // Liquid Crystal // Connect via i2c LiquidCrystal lcd(0); // Crowtail Moisture Sensor int iSoilMoisture = A0; int iSoilMoistureVal = 0; // LED Yellow int iLEDYellow = 7; // LED Green int iLEDGreen = 6; // Software Version Information String sver = "15-24"; void loop() { // Crowtail Moisture Sensor isSoilMoisture(); // Temperature and Humidity Sensor isTH(); // Delay 2 Second delay( 2000 ); // Display Temperature and Humidity isDisplayTH(); // Delay 2 Second delay( 2000 ); }
/****** Don Luc Electronics © ******
Software Version Information
Project #15: Environment – DHT11 – Mk24
DL2501Mk06p.ino
DL2501Mk06
1 x Crowduino Uno - SD
1 x Crowtail - Base Shield
1 x Crowtail - Temperature and Humidity Sensor 2.0
1 x Crowtail - Rotary Angle Sensor 2.0
1 x Crowtail - Moisture Sensor 2.0
1 x Crowtail - I2C LCD
1 x Crowtail - LED(Green)
1 x Crowtail - LED(Yellow)
1 x USB Battery Pack
1 x USB Mini-B Cable
*/

// Include the Library Code
// Wire
#include <Wire.h>
// Liquid Crystal
#include "LiquidCrystal.h"
// Temperature and Humidity Sensor
#include "DHT.h"

// Temperature and Humidity Sensor
#define DHTPIN 5
// DHT 11
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
// Temperature and Humidity Sensor
float h = 0;
float t = 0;

// Potentiometer
int iPotentiometer = A1;
// Change Your Threshold Here
int Threshold = 0;
int zz = 0;

// Liquid Crystal
// Connect via i2c
LiquidCrystal lcd(0);

// Crowtail Moisture Sensor
int iSoilMoisture = A0;
int iSoilMoistureVal = 0;

// LED Yellow
int iLEDYellow = 7;

// LED Green
int iLEDGreen = 6;

// Software Version Information
String sver = "15-24";

void loop() {

  // Crowtail Moisture Sensor
  isSoilMoisture();

  // Temperature and Humidity Sensor
  isTH();

  // Delay 2 Second
  delay( 2000 );

  // Display Temperature and Humidity
  isDisplayTH();

  // Delay 2 Second
  delay( 2000 );

}

getDisplay.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// getDisplay
// Crowbits - OLED 128X64 UID
void isDisplayUID(){
// Set up the LCD's number of rows and columns:
lcd.begin(16, 2);
// Print a message to the LCD.
// Cursor
lcd.setCursor(0, 0);
lcd.print("Don Luc Electron");
// Cursor
lcd.setCursor(0, 1);
// Print a message to the LCD.
lcd.print( sver );
}
// isDisplay Green
void isDisplayG(){
// Print a message to the LCD
// Clear
lcd.clear();
// Cursor
lcd.setCursor(0, 0);
lcd.print("Humid Soil");
// Cursor
lcd.setCursor(0, 1);
// Print a message to the LCD
lcd.print( iSoilMoistureVal );
}
// isDisplay Yellow
void isDisplayY(){
// Print a message to the LCD
// Clear
lcd.clear();
// Cursor
lcd.setCursor(0, 0);
lcd.print("Dry Soil");
// Cursor
lcd.setCursor(0, 1);
// Print a message to the LCD
lcd.print( iSoilMoistureVal );
}
// Display Temperature and Humidity
void isDisplayTH(){
// Set the cursor to column 0, line 0
lcd.setCursor(0, 0);
lcd.print("H: ");
lcd.print(h);
lcd.print(" %");
// Set the cursor to column 0, line 1
lcd.setCursor(0, 1);
lcd.print("T: ");
lcd.print(t);
lcd.print(" *C");
}
// getDisplay // Crowbits - OLED 128X64 UID void isDisplayUID(){ // Set up the LCD's number of rows and columns: lcd.begin(16, 2); // Print a message to the LCD. // Cursor lcd.setCursor(0, 0); lcd.print("Don Luc Electron"); // Cursor lcd.setCursor(0, 1); // Print a message to the LCD. lcd.print( sver ); } // isDisplay Green void isDisplayG(){ // Print a message to the LCD // Clear lcd.clear(); // Cursor lcd.setCursor(0, 0); lcd.print("Humid Soil"); // Cursor lcd.setCursor(0, 1); // Print a message to the LCD lcd.print( iSoilMoistureVal ); } // isDisplay Yellow void isDisplayY(){ // Print a message to the LCD // Clear lcd.clear(); // Cursor lcd.setCursor(0, 0); lcd.print("Dry Soil"); // Cursor lcd.setCursor(0, 1); // Print a message to the LCD lcd.print( iSoilMoistureVal ); } // Display Temperature and Humidity void isDisplayTH(){ // Set the cursor to column 0, line 0 lcd.setCursor(0, 0); lcd.print("H: "); lcd.print(h); lcd.print(" %"); // Set the cursor to column 0, line 1 lcd.setCursor(0, 1); lcd.print("T: "); lcd.print(t); lcd.print(" *C"); }
// getDisplay
// Crowbits - OLED 128X64 UID
void isDisplayUID(){

  // Set up the LCD's number of rows and columns: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  // Cursor
  lcd.setCursor(0, 0);
  lcd.print("Don Luc Electron");
  // Cursor
  lcd.setCursor(0, 1);
  // Print a message to the LCD.
  lcd.print( sver );

}
// isDisplay Green
void isDisplayG(){

  // Print a message to the LCD
  // Clear
  lcd.clear();
  // Cursor
  lcd.setCursor(0, 0);
  lcd.print("Humid Soil");
  // Cursor
  lcd.setCursor(0, 1);
  // Print a message to the LCD
  lcd.print( iSoilMoistureVal );
  
}
// isDisplay Yellow
void isDisplayY(){

  // Print a message to the LCD
  // Clear
  lcd.clear();
  // Cursor
  lcd.setCursor(0, 0);
  lcd.print("Dry Soil");
  // Cursor
  lcd.setCursor(0, 1);
  // Print a message to the LCD
  lcd.print( iSoilMoistureVal );
  
}
// Display Temperature and Humidity
void isDisplayTH(){

  // Set the cursor to column 0, line 0
  lcd.setCursor(0, 0);
  lcd.print("H: "); 
  lcd.print(h);
  lcd.print(" %");
  // Set the cursor to column 0, line 1
  lcd.setCursor(0, 1);
  lcd.print("T: "); 
  lcd.print(t);
  lcd.print(" *C");
  
}

getSoilMoisture.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// Crowtail Moisture Sensor
// Soil Moisture
void isSoilMoisture(){
// Connect Soil Moisture Sensor to Analog 0
// iSoilMoistureVal => 0~700 Soil Moisture
iSoilMoistureVal = analogRead( iSoilMoisture );
// Threshold => 200~500
zz = analogRead( iPotentiometer );
Threshold = map( zz, 0, 1024, 200, 500);
// Threshold
if (iSoilMoistureVal > Threshold) {
// 300~700 - Humid Soil
// LED Yellow
digitalWrite(iLEDYellow, LOW);
// Display Green
isDisplayG();
// LED Green
digitalWrite(iLEDGreen, HIGH);
}
else {
// 0-300 Dry Soil
// LED Green
digitalWrite(iLEDGreen, LOW);
// Display Yellow
isDisplayY();
digitalWrite(iLEDYellow, HIGH);
}
}
// Crowtail Moisture Sensor // Soil Moisture void isSoilMoisture(){ // Connect Soil Moisture Sensor to Analog 0 // iSoilMoistureVal => 0~700 Soil Moisture iSoilMoistureVal = analogRead( iSoilMoisture ); // Threshold => 200~500 zz = analogRead( iPotentiometer ); Threshold = map( zz, 0, 1024, 200, 500); // Threshold if (iSoilMoistureVal > Threshold) { // 300~700 - Humid Soil // LED Yellow digitalWrite(iLEDYellow, LOW); // Display Green isDisplayG(); // LED Green digitalWrite(iLEDGreen, HIGH); } else { // 0-300 Dry Soil // LED Green digitalWrite(iLEDGreen, LOW); // Display Yellow isDisplayY(); digitalWrite(iLEDYellow, HIGH); } }
// Crowtail Moisture Sensor
// Soil Moisture
void isSoilMoisture(){

  // Connect Soil Moisture Sensor to Analog 0
  // iSoilMoistureVal => 0~700 Soil Moisture
  iSoilMoistureVal = analogRead( iSoilMoisture );

  // Threshold => 200~500
  zz = analogRead( iPotentiometer );
  Threshold = map( zz, 0, 1024, 200, 500);

  // Threshold
  if (iSoilMoistureVal > Threshold) {

    // 300~700 - Humid Soil
    // LED Yellow
    digitalWrite(iLEDYellow, LOW);
    // Display Green
    isDisplayG();
    // LED Green
    digitalWrite(iLEDGreen, HIGH);
    
  }
  else {
    
    // 0-300 Dry Soil
    // LED Green
    digitalWrite(iLEDGreen, LOW);
    // Display Yellow
    isDisplayY();
    digitalWrite(iLEDYellow, HIGH);
    
  }

}

getTH.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// Temperature and Humidity Sensor
void isTH(){
// Temperature
t = dht.readTemperature();
// Humidity
h = dht.readHumidity();
}
// Temperature and Humidity Sensor void isTH(){ // Temperature t = dht.readTemperature(); // Humidity h = dht.readHumidity(); }
// Temperature and Humidity Sensor
void isTH(){

  // Temperature
  t = dht.readTemperature();
  // Humidity
  h = dht.readHumidity();
  
}

setup.ino

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// Setup
void setup()
{
// Delay
delay(100);
// Initialize the LED iLED Yellow
pinMode(iLEDYellow, OUTPUT);
// Initialize the LED LED Green
pinMode(iLEDGreen, OUTPUT);
// Temperature and Humidity Sensor
dht.begin();
// Display UID
isDisplayUID();
// Delay 5 Second
delay( 5000 );
}
// Setup void setup() { // Delay delay(100); // Initialize the LED iLED Yellow pinMode(iLEDYellow, OUTPUT); // Initialize the LED LED Green pinMode(iLEDGreen, OUTPUT); // Temperature and Humidity Sensor dht.begin(); // Display UID isDisplayUID(); // Delay 5 Second delay( 5000 ); }
// Setup
void setup()
{
 
  // Delay
  delay(100);

  // Initialize the LED iLED Yellow
  pinMode(iLEDYellow, OUTPUT);

  // Initialize the LED LED Green
  pinMode(iLEDGreen, OUTPUT);

  // Temperature and Humidity Sensor
  dht.begin();

  // Display UID
  isDisplayUID();
  
  // Delay 5 Second
  delay( 5000 );

}

——

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

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

  • Programming Language
  • Single-Board 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

Follow Us

Luc Paquin – Curriculum Vitae – 2024
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
Hackster.io: https://www.hackster.io/neosteam-labs
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

Categories
Archives