The Alpha Geek – Geeking Out

SparkFun

SparkFun

1 2 3 32

Project #29 – DFRobot – AltIMU-10 – Mk19

——

#DonLucElectronics #DonLuc #DFRobot #AltIMU10 #9DOF #GPS #FireBeetle2ESP32E #EEPROM #RTC #SD #Display #Pololu #ESP32 #IoT #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

AltIMU-10

——

AltIMU-10

——

AltIMU-10

——

Pololu AltIMU-10 v5 Gyro, Accelerometer, Compass, and Altimeter

The Pololu AltIMU-10 v5 is a compact board that combines ST’s LSM6DS33 3-axis gyroscope and 3-axis accelerometer, LIS3MDL 3-axis magnetometer, and LPS25H digital barometer to form an inertial measurement unit (IMU) and altimeter. These sensors are great ICs, but their small packages make them difficult for the typical student or hobbyist to use. They also operate at voltages below 3.6 Volt, which can make interfacing difficult for microcontrollers operating at 5 Volt. The AltIMU-10 v5 addresses these issues by incorporating additional electronics, including a voltage regulator and a level-shifting circuit, while keeping the overall size as compact as possible. The board ships fully populated with its SMD components, including the LSM6DS33, LIS3MDL, and LPS25H.

Attitude and Heading Reference System (AHRS)

An attitude and heading reference system (AHRS) uses an inertial measurement unit (IMU) consisting of microelectromechanical system (MEMS) inertial sensors to measure the angular rate, acceleration, and Earth’s magnetic field. These measurements can then be used to derive an estimate of the object’s attitude. An AHRS typically includes a 3-axis gyroscope, a 3-axis accelerometer, and a 3-axis magnetometer to determine an estimate of a system’s orientation. Each of these sensors contribute different measurements to the combined system and each exhibit unique limitations.

DL2406Mk06

1 x DFRobot FireBeetle 2 ESP32-E
1 x Adafruit SHARP Memory Display
1 x Adafruit MicroSD card breakout board+
1 x MicroSD 16 GB
1 x Pololu AltIMU-10 v5
1 x GPS Receiver – GP-20U7
2 x Switch
1 x 1K Ohm
1 x 1 x Lithium Ion Battery – 1000mAh
1 x Green LED
1 x USB 3.1 Cable A to C

DFRobot FireBeetle 2 ESP32-E

LED – 2
DSCK – 4
DMOSI – 16
DSS – 17
SCK – 22
MOSI – 23
MISO – 19
CS – 13
GPR – 26
GPT – 25
SCL – 21
SDA – 22
LED – 14
SWI – 3
XAC – A0
YAC – A1
ZAC – A2
VIN – +3.3V
GND – GND

——

DL2406Mk06p.ino

/****** Don Luc Electronics © ******
Software Version Information
Project #29 - DFRobot - AltIMU-10 - Mk19
29-19
DL2406Mk06p.ino
DL2406Mk06
1 x DFRobot FireBeetle 2 ESP32-E
1 x Adafruit SHARP Memory Display
1 x Adafruit MicroSD card breakout board+
1 x MicroSD 16 GB
1 x Pololu AltIMU-10 v5
1 x GPS Receiver - GP-20U7
2 x Switch
1 x 1K Ohm
1 x 1 x Lithium Ion Battery - 1000mAh
1 x Green LED
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"
// Wire
#include <Wire.h>
// SD Card
#include "FS.h"
#include "SD.h"
#include "SPI.h"
// SHARP Memory Display
#include <Adafruit_SharpMem.h>
#include <Adafruit_GFX.h>
// GPS Receiver
#include <TinyGPS++.h>
// ESP32 Hardware Serial
#include <HardwareSerial.h>
// Includes and variables for IMU integration
// STMicroelectronics LSM6DS33 Gyroscope and Accelerometer
#include <LSM6.h>
// STMicroelectronics LIS3MDL Magnetometer
#include <LIS3MDL.h>
// STMicroelectronics LPS25H digital Barometer
#include <LPS.h>

// Earth's magnetic field varies by location. Add or subtract
// a declination to get a more accurate heading. Calculate
// your's here: http://www.ngdc.noaa.gov/geomag-web/#declination
// Declination (degrees) in Mexicali
#define DECLINATION 10.31

// 9DoF IMU
// STMicroelectronics LSM6DS33 Gyroscope and Accelerometer
LSM6 imu;
// Accelerometer and Gyroscopes
// Accelerometer
int imuAX;
int imuAY;
int imuAZ;
//String FullStringB = "";
// Gyroscopes 
int imuGX;
int imuGY;
int imuGZ;
// STMicroelectronics LIS3MDL magnetometer
LIS3MDL mag;
// Magnetometer
int magX;
int magY;
int magZ;
// STMicroelectronics LPS25H digital barometer
LPS ps;
// Digital Barometer
float pressure;
float altitude;
float temperature;
// Attitude Calculate Pitch, Roll, and Headind
float r;
float p;
float h;

// ESP32 HardwareSerial
HardwareSerial tGPS(2);

// GPS Receiver
#define gpsRXPIN 26
// This one is unused and doesnt have a conection
#define gpsTXPIN 25
// 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 TargetALT;
// GPS Status
String GPSSt = "";

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

// SHARP Memory Display
#define SHARP_SCK  4
#define SHARP_MOSI 16
#define SHARP_SS   17
// Set the size of the display here, e.g. 144x168!
Adafruit_SharpMem display(SHARP_SCK, SHARP_MOSI, SHARP_SS, 144, 168);
// The currently-available SHARP Memory Display (144x168 pixels)
// requires > 4K of microcontroller RAM; it WILL NOT WORK on Arduino Uno
// or other <4K "classic" devices.
#define BLACK 0
#define WHITE 1

// LED Green
int iLEDGreen = 2;

// Define LED
int iLED = 14;

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

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

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

void loop() {

  // Accelerometer and Gyroscopes
  isIMU();

  // Magnetometer
  isMag();

  // Barometer
  isBarometer();

  // Attitude Calculate Pitch, Roll, and Heading
  isAttitude(imuAX, imuAY, imuAZ, -imuGY, -imuGX, imuGZ);

  // isGPS
  isGPS();

  // Read the state of the Switch value
  iSwitchState = digitalRead(iSwitch);
  
  // The Switch is HIGH:
  if (iSwitchState == HIGH) {

    // Attitude Calculate Pitch, Roll, and Heading and Barometer
    isDisplayAttitude();
  
  } else {

    // Display GPS
    isDisplayGPS();
    
  }  

  // MicroSD Card
  isSD();

  // iLED HIGH
  digitalWrite(iLED, HIGH );

  // Delay 5 Second
  delay(5000);

}

getAccelGyro.ino

// Accelerometer and Gyroscopes
// Setup IMU
void isSetupIMU() {

  // Setup IMU
  imu.init();
  // Default
  imu.enableDefault();
  
}
// Accelerometer and Gyroscopes
void isIMU() {

  // Accelerometer and Gyroscopes
  imu.read();
  // Accelerometer x, y, z
  imuAX = imu.a.x;
  imuAY = imu.a.y;
  imuAZ = imu.a.z;
  // Gyroscopes x, y, z
  imuGX = imu.g.x;
  imuGY = imu.g.y;
  imuGZ = imu.g.z;

}

getAttitude.ino

// Attitude Calculate Pitch, Roll, and Heading
void isAttitude(float ax, float ay, float az, float mx, float my, float mz) {

  // Attitude Calculate Pitch, Roll, and Heading
  float roll = atan2(ay, az);
  float pitch = atan2(-ax, sqrt(ay * ay + az * az));

  float heading;
  if (my == 0)
    heading = (mx < 0) ? PI : 0;
  else
    heading = atan2(mx, my);

  heading -= DECLINATION * PI / 180;

  if (heading > PI) heading -= (2 * PI);
  else if (heading < -PI) heading += (2 * PI);

  // Convert everything from radians to degrees:
  heading *= 180.0 / PI;
  pitch *= 180.0 / PI;
  roll  *= 180.0 / PI;

  h = heading;
  p = pitch;
  r = roll;
  
}

getBarometer.ino

// STMicroelectronics LPS25H digital barometer
// Setup Barometer
void isSetupBarometer(){

  // Setup Barometer
  ps.init();
  // Default
  ps.enableDefault();
  
}
// Barometer
void isBarometer(){

  // Barometer
  pressure = ps.readPressureMillibars();
  // Altitude Meters
  altitude = ps.pressureToAltitudeMeters(pressure);
  // Temperature Celsius
  temperature = ps.readTemperatureC();

}

getDisplay.ino

// SHARP Memory Display
// SHARP Memory Display - UID
void isDisplayUID() {

    // Text Display 
    // Clear Display
    display.clearDisplay();
    display.setRotation(4);
    display.setTextSize(3);
    display.setTextColor(BLACK);
    // Don Luc Electronics
    display.setCursor(0,10);
    display.println( "Don Luc" );
    display.setTextSize(2);
    display.setCursor(0,40);
    display.println( "Electronics" );
    // Version
    //display.setTextSize(3);
    display.setCursor(0,70);
    display.println( "Version" );
    //display.setTextSize(2);
    display.setCursor(0,95);   
    display.println( sver );
    // EEPROM
    display.setCursor(0,120);
    display.println( "EEPROM" );
    display.setCursor(0,140);   
    display.println( uid );
    // Refresh
    display.refresh();
    delay( 100 );
    
}
// Attitude Calculate Pitch, Roll, and Heading
void isDisplayAttitude() {

    // Text Display
    // Clear Display
    display.clearDisplay();
    display.setRotation(4);
    display.setTextSize(2);
    display.setTextColor(BLACK);
    // Pitch
    display.setCursor(0,5);
    display.print( "Pi: " );
    display.println( p );
    // Roll
    display.setCursor(0,25);
    display.print( "Ro: " );
    display.println( r );
    // Heading
    display.setCursor(0,45);
    display.print( "He: " );
    display.println( h );
    // Temperature Celsius
    display.setCursor(0,65);
    display.print( "Te: " );
    display.println( temperature );
    // Barometer
    display.setCursor(0,85);
    display.print( "Ba: " );
    display.println( pressure );
    // Altitude Meters
    display.setCursor(0,105);
    display.print( "Al: " );
    display.println( altitude );
    // Refresh
    display.refresh();
    delay( 100 );

}
// Display GPS
void isDisplayGPS() {

    // Text Display Date
    // Clear Display
    display.clearDisplay();
    display.setRotation(4);
    display.setTextSize(2);
    display.setTextColor(BLACK);
    // Latitude
    display.setCursor(0,5);
    display.print( "Lat: " );
    display.println( TargetLat );
    // Longitude
    display.setCursor(0,30);
    display.print( "Lon: " );
    display.println( TargetLon );
    // GPS Date
    display.setCursor(0,55);
    display.println( TargetDat );
    // GPS Time
    display.setCursor(0,80);
    display.println( TargetTim );
    // GPS Speed M/S
    display.setCursor(0,105);
    display.print( TargetSMS );
    display.println( " M/S" );
    // GPS Altitude Meters
    display.setCursor(0,130);
    display.print( TargetALT );
    display.println( " M" );
    // Refresh
    display.refresh();
    delay( 100 );

}

getEEPROM.ino

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

// 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
  TargetALT = "";
  if (gps.altitude.isValid())
  {
    
     // Altitude
     // Meters
     int z = gps.altitude.meters();
     TargetALT = String( z, DEC);

  }
  
}

getMagnetometer.ino

// Magnetometer
// Setup Magnetometer
void isSetupMag() {

  // Setup Magnetometer
  mag.init();
  // Default
  mag.enableDefault();
  
}
// Magnetometer
void isMag() {

  // Magnetometer
  mag.read();
  // Magnetometer x, y, z
  magX = mag.m.x;
  magY = mag.m.y;
  magZ = mag.m.z;

}

getSD.ino

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

  //DFR|EEPROM Unique ID|Version|
  //Accelerometer X|Accelerometer Y|Accelerometer Z|
  //Gyroscope X|Gyroscope Y|Gyroscope Z|
  //Magnetometer X|Magnetometer Y|Magnetometer Z|
  //Pitch|Roll|Heading|
  //Temperature C|Pressure Millibars|Altitude Meters|
  //GPS|Latitude|Longitude|GPS Date|GPS Time|GPS Speed M/S|GPS Altitude|*\r
  zzzzzz = "DFR|" + uid + "|" + sver + "|"
  + String(imuAX) + "|" + String(imuAY) + "|" + String(imuAZ) + "|"
  + String(imuGX) + "|" + String(imuGY) + "|" + String(imuGZ) + "|"
  + String(magX) + "|" + String(magY) + "|" + String(magZ) + "|"
  + String(p) + "|" + String(r) + "|" + String(h) + "|"
  + String(temperature) + "|" + String(pressure) + "|" + String(altitude) + "|"
  + String(GPSSt) + "|" + String(TargetLat) + "|" 
  + String(TargetLon) + "|" + String(TargetDat) + "|" + String(TargetTim) + "|" 
  + String(TargetSMS) + "|" + String(TargetALT)+ "|*\r";

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

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

  // Append File
  appendFile(SD, "/dfrdata.txt", msg );
  
}
// 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

// Setup
void setup()
{
  
  // Give display time to power on
  delay(100);

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

  // Give display
  delay(100);

  // Set up I2C bus
  Wire.begin();

  // Give display
  delay(100);

  //MicroSD Card
  isSetupSD();

  // SHARP Display Start & Clear the Display
  display.begin();
  // Clear Display
  display.clearDisplay();

  // Delay
  delay( 100 );

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

  // Delay
  delay( 100 );

  // Setup IMU
  isSetupIMU();

  // Setup Magnetometer
  isSetupMag();

  // Setup Barometer
  isSetupBarometer();

  // Delay
  delay( 100 );

  // Initialize digital pin iLED as an output
  pinMode(iLED, OUTPUT);

  // Outputting high, the LED turns on
  digitalWrite(iLED, HIGH);

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

  // iLEDGreen HIGH
  digitalWrite(iLEDGreen, HIGH );

  // Initialize the Switch
  pinMode(iSwitch, INPUT);

  // Don Luc Electronics
  // Version
  // EEPROM
  isDisplayUID();
  
  // Delay 5 Second
  delay( 5000 );

}

——

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

Teacher, Instructor, E-Mentor, 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/
LinkedIn: https://www.linkedin.com/in/jlucpaquin/

Don Luc

Project #29 – DFRobot – L3G4200D – Mk18

——

#DonLucElectronics #DonLuc #DFRobot #L3G4200D #HMC5883L #ADXL335 #GPS #FireBeetle2ESP32E #EEPROM #RTC #SD #Display #SparkFun #ESP32 #IoT #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

L3G4200D

——

L3G4200D

——

L3G4200D

——

SparkFun Tri-Axis Gyroscope – L3G4200D

This is a breakout board for the L3G4200D low-power three-axis angular rate sensor. The L3G4200D is a MEMS motion sensor and has a full scale of dps and is capable of measuring rates with a user-selectable bandwidth. These work great in gaming and virtual reality input devices, motion control with MMI, GPS navigation systems, appliances and robotics. The L3G4200D is a low-power three-axis angular rate sensor able to provide unprecedented stablility of zero rate level and sensitivity over temperature and time. It includes a sensing element and an IC interface capable of providing the measured angular rate to the external world through a digital interface.

DL2406Mk05

1 x DFRobot FireBeetle 2 ESP32-E
1 x Adafruit SHARP Memory Display
1 x Adafruit MicroSD card breakout board+
1 x MicroSD 16 GB
1 x SparkFun Triple Axis Accelerometer ADXL335
1 x SparkFun Triple Axis Magnetometer HMC5883L
1 x SparkFun Tri-Axis Gyroscope L3G4200D
1 x GPS Receiver – GP-20U7
2 x Switch
1 x 1K Ohm
1 x 1 x Lithium Ion Battery – 1000mAh
1 x Green LED
1 x USB 3.1 Cable A to C

DFRobot FireBeetle 2 ESP32-E

LED – 2
DSCK – 4
DMOSI – 16
DSS – 17
SCK – 22
MOSI – 23
MISO – 19
CS – 13
GPR – 26
GPT – 25
SCL – 21
SDA – 22
LED – 14
SWI – 3
XAC – A0
YAC – A1
ZAC – A2
VIN – +3.3V
GND – GND

——

DL2406Mk05p.ino

/****** Don Luc Electronics © ******
Software Version Information
Project #29 - DFRobot - L3G4200D - Mk18
29-18
DL2406Mk05p.ino
DL2406Mk05
1 x DFRobot FireBeetle 2 ESP32-E
1 x Adafruit SHARP Memory Display
1 x Adafruit MicroSD card breakout board+
1 x MicroSD 16 GB
1 x SparkFun Triple Axis Magnetometer HMC5883L
1 x SparkFun Triple Axis Accelerometer ADXL335
1 x SparkFun Tri-Axis Gyroscope L3G4200D
1 x GPS Receiver - GP-20U7
2 x Switch
1 x 1K Ohm
1 x 1 x Lithium Ion Battery - 1000mAh
1 x Green LED
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"
// Wire
#include <Wire.h>
// SD Card
#include "FS.h"
#include "SD.h"
#include "SPI.h"
// SHARP Memory Display
#include <Adafruit_SharpMem.h>
#include <Adafruit_GFX.h>
// GPS Receiver
#include <TinyGPS++.h>
// ESP32 Hardware Serial
#include <HardwareSerial.h>
// Triple Axis Magnetometer
#include <HMC5883L.h>
// Gyroscope
#include <L3G4200D.h>

// Gyroscope
L3G4200D gyroscope;
// Timers
unsigned long timer = 0;
float timeStep = 0.01;
// Pitch, Roll and Yaw values
float pitch = 0;
float roll = 0;
float yaw = 0;

// Triple Axis Magnetometer
HMC5883L compass;
// Triple Axis Magnetometer
int mX = 0;
int mY = 0;
int mZ = 0;

// Accelerometer ADXL335
int iX = A0;
int iY = A1;
int iZ = A2;
// Accelerometer
int X = 0;
int Y = 0;
int Z = 0;

// ESP32 HardwareSerial
HardwareSerial tGPS(2);

// GPS Receiver
#define gpsRXPIN 26
// This one is unused and doesnt have a conection
#define gpsTXPIN 25
// 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 TargetALT;
// GPS Status
String GPSSt = "";

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

// SHARP Memory Display
#define SHARP_SCK  4
#define SHARP_MOSI 16
#define SHARP_SS   17
// Set the size of the display here, e.g. 144x168!
Adafruit_SharpMem display(SHARP_SCK, SHARP_MOSI, SHARP_SS, 144, 168);
// The currently-available SHARP Memory Display (144x168 pixels)
// requires > 4K of microcontroller RAM; it WILL NOT WORK on Arduino Uno
// or other <4K "classic" devices.
#define BLACK 0
#define WHITE 1

// LED Green
int iLEDGreen = 2;

// Define LED
int iLED = 14;

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

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

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

void loop() {

  // isGPS
  isGPS();

  // Accelerometer ADXL335
  isADXL335();

  // Magnetometer
  isMagnetometer();

  // Gyroscope
  isGyroscope();

  // Read the state of the Switch value
  iSwitchState = digitalRead(iSwitch);
  
  // The Switch is HIGH:
  if (iSwitchState == HIGH) {

    // Display Accelerometer ADXL335
    isDisplayADXL335();
  
  } else {

    // Display GPS
    isDisplayGPS();
    
  }  

  // MicroSD Card
  isSD();

  // iLED HIGH
  digitalWrite(iLED, HIGH );

  // Delay 5 Second
  delay(5000);

}

getAccelerometer.ino

// Accelerometer ADXL335
// ADXL335
void isADXL335() {

  // Accelerometer ADXL335
  // Accelerometer X, Y, Z
  // X
  X = analogRead(iX);
  // Y
  Y = analogRead(iY);
  // Z
  Z = analogRead(iZ);
  
}

getDisplay.ino

// SHARP Memory Display
// SHARP Memory Display - UID
void isDisplayUID() {

    // Text Display 
    // Clear Display
    display.clearDisplay();
    display.setRotation(4);
    display.setTextSize(3);
    display.setTextColor(BLACK);
    // Don Luc Electronics
    display.setCursor(0,10);
    display.println( "Don Luc" );
    display.setTextSize(2);
    display.setCursor(0,40);
    display.println( "Electronics" );
    // Version
    //display.setTextSize(3);
    display.setCursor(0,70);
    display.println( "Version" );
    //display.setTextSize(2);
    display.setCursor(0,95);   
    display.println( sver );
    // EEPROM
    display.setCursor(0,120);
    display.println( "EEPROM" );
    display.setCursor(0,140);   
    display.println( uid );
    // Refresh
    display.refresh();
    delay( 100 );
    
}
// Display Accelerometer ADXL335
void isDisplayADXL335() {

    // Text Display
    // Clear Display
    display.clearDisplay();
    display.setRotation(4);
    display.setTextSize(1);
    display.setTextColor(BLACK);
    // Accelerometer X
    display.setCursor(0,5);
    display.print( "AX: " );
    display.println( X );
    // Accelerometer Y
    display.setCursor(0,20);
    display.print( "AY: " );
    display.println( Y );
    // Accelerometer Z
    display.setCursor(0,35);
    display.print( "AZ: " );
    display.println( Z );
    // Magnetometer X
    display.setCursor(0,50);
    display.print( "MX: " );
    display.println( mX );
    // Magnetometer Y
    display.setCursor(0,65);
    display.print( "MY: " );
    display.println( mY );
    // Magnetometer Z
    display.setCursor(0,80);
    display.print( "MZ: " );
    display.println( mZ );
    // Gyroscope Pitch
    display.setCursor(0,95);
    display.print( "Pitch: " );
    display.println( pitch );
    // Gyroscope Roll
    display.setCursor(0,110);
    display.print( "Roll: " );
    display.println( roll );
    // Gyroscope Yaw
    display.setCursor(0,125);
    display.print( "Yaw: " );
    display.println( yaw );
    // Refresh
    display.refresh();
    delay( 100 );

}
// Display GPS
void isDisplayGPS() {

    // Text Display Date
    // Clear Display
    display.clearDisplay();
    display.setRotation(4);
    display.setTextSize(2);
    display.setTextColor(BLACK);
    // Latitude
    display.setCursor(0,5);
    display.print( "Lat: " );
    display.println( TargetLat );
    // Longitude
    display.setCursor(0,30);
    display.print( "Lon: " );
    display.println( TargetLon );
    // GPS Date
    display.setCursor(0,55);
    display.println( TargetDat );
    // GPS Time
    display.setCursor(0,80);
    display.println( TargetTim );
    // GPS Speed M/S
    display.setCursor(0,105);
    display.print( TargetSMS );
    display.println( " M/S" );
    // GPS Altitude Meters
    display.setCursor(0,130);
    display.print( TargetALT );
    display.println( " M" );
    // Refresh
    display.refresh();
    delay( 100 );

}

getEEPROM.ino

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

// 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
  TargetALT = "";
  if (gps.altitude.isValid())
  {
    
     // Altitude
     // Meters
     int z = gps.altitude.meters();
     TargetALT = String( z, DEC);

  }
  
}

getGyroscope.ino

// L3G4200D Triple Axis Gyroscope
// Setup Gyroscope
void isSetupGyroscope() {

  // Setup Gyroscope
  // Set scale 2000 dps and 400HZ Output data rate (cut-off 50)
  while(!gyroscope.begin(L3G4200D_SCALE_2000DPS, L3G4200D_DATARATE_400HZ_50))
  {
    // Could not find a valid L3G4200D sensor, check wiring!
    delay(500);
    
  }

  // Calibrate gyroscope. The calibration must be at rest.
  // If you don't want calibrate, comment this line.
  gyroscope.calibrate(100);
  
}
// L3G4200D Gyroscope
void isGyroscope(){

  // Timer
  timer = millis();

  // Read normalized values
  Vector norm = gyroscope.readNormalize();

  // Calculate Pitch, Roll and Yaw
  pitch = pitch + norm.YAxis * timeStep;
  roll = roll + norm.XAxis * timeStep;
  yaw = yaw + norm.ZAxis * timeStep;

}

getMagnetometer.ino

// Magnetometer
// Setup Magnetometer
void isSetupMagnetometer(){

  // Magnetometer Serial
  // Initialize HMC5883L
  while (!compass.begin())
  {
    delay(500);
  }

  // Set measurement range
  // +/- 1.30 Ga: HMC5883L_RANGE_1_3GA (default)
  compass.setRange(HMC5883L_RANGE_1_3GA);

  // Set measurement mode
  // Continuous-Measurement: HMC5883L_CONTINOUS (default)
  compass.setMeasurementMode(HMC5883L_CONTINOUS);
 
  // Set data rate
  // 15.00Hz: HMC5883L_DATARATE_15HZ (default)
  compass.setDataRate(HMC5883L_DATARATE_15HZ);

  // Set number of samples averaged
  // 1 sample:  HMC5883L_SAMPLES_1 (default)
  compass.setSamples(HMC5883L_SAMPLES_1);
  
}
// Magnetometer
void isMagnetometer(){

  // Magnetometer Vector Norm
  Vector norm = compass.readNormalize();
  // Vector X, Y, Z
  // Magnetometer X Normalize
  mX = norm.XAxis;
  // Magnetometer Y Normalize
  mY = norm.YAxis;
  // Magnetometer Z Normalize
  mZ = norm.ZAxis;

}

getSD.ino

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

  // DFR|EEPROM Unique ID|Version|Date|Time|
  //Accelerometer X|Accelerometer Y|Accelerometer Z
  //Magnetometer X|Magnetometer Y|Magnetometer Z
  //Gyroscope Pitch|Gyroscope Roll|Gyroscope Yaw
  //|GPS|Latitude|Longitude|GPS Date|GPS Time|GPS Speed M/S|GPS Altitude|*\r
  zzzzzz = "DFR|" + uid + "|" + sver + "|"
  + String(X) + "|" + String(Y) + "|" + String(Z) + "|"
  + String(mX) + "|" + String(mY) + "|" + String(mZ) + "|"
  + String(pitch) + "|" + String(roll) + "|" + String(yaw) + "|"
  + String(GPSSt) + "|" + String(TargetLat) + "|" 
  + String(TargetLon) + "|" + String(TargetDat) + "|" + String(TargetTim) + "|" 
  + String(TargetSMS) + "|" + String(TargetALT)+ "|*\r";

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

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

  // Append File
  appendFile(SD, "/dfrdata.txt", msg );
  
}
// 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

// Setup
void setup()
{
  
  // Give display time to power on
  delay(100);

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

  // Give display
  delay(100);

  // Set up I2C bus
  Wire.begin();

  // Give display
  delay(100);

  //MicroSD Card
  isSetupSD();

  // SHARP Display Start & Clear the Display
  display.begin();
  // Clear Display
  display.clearDisplay();

  // Delay
  delay( 100 );

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

  // Delay
  delay( 100 );

  // Setup Triple Axis Magnetometer
  isSetupMagnetometer();

  // L3G4200D Gyroscope
  isSetupGyroscope();

  // Delay
  delay( 100 );

  // Initialize digital pin iLED as an output
  pinMode(iLED, OUTPUT);

  // Outputting high, the LED turns on
  digitalWrite(iLED, HIGH);

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

  // iLEDGreen HIGH
  digitalWrite(iLEDGreen, HIGH );

  // Initialize the Switch
  pinMode(iSwitch, INPUT);

  // Don Luc Electronics
  // Version
  // EEPROM
  isDisplayUID();
  
  // Delay 5 Second
  delay( 5000 );

}

——

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

Teacher, Instructor, E-Mentor, 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/
LinkedIn: https://www.linkedin.com/in/jlucpaquin/

Don Luc

Project #29 – DFRobot – HMC5883L – Mk17

——

#DonLucElectronics #DonLuc #DFRobot #HMC5883L #ADXL335 #GPS #FireBeetle2ESP32E #EEPROM #RTC #SD #Display #SparkFun #ESP32 #IoT #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

HMC5883L

——

HMC5883L

——

HMC5883L

——

SparkFun Triple Axis Magnetometer Breakout – HMC5883L

This is a breakout board for Honeywell’s HMC5883L, a 3-axis digital compass. Communication with the HMC5883L is simple and all done through an I2C interface. There is no on-board regulator, so a regulated voltage of 2.16-3.6VDC should be supplied. The breakout board includes the HMC5883L sensor and all filtering capacitors as shown. The power and 2-wire interface pins are all broken out to a 0.1 inch pitch header.

DL2406Mk04

1 x DFRobot FireBeetle 2 ESP32-E
1 x Adafruit SHARP Memory Display
1 x Adafruit MicroSD card breakout board+
1 x MicroSD 16 GB
1 x SparkFun Triple Axis Accelerometer ADXL335
1 x SparkFun Triple Axis Magnetometer HMC5883L
1 x GPS Receiver – GP-20U7
2 x Switch
1 x 1K Ohm
1 x 1 x Lithium Ion Battery – 1000mAh
1 x Green LED
1 x USB 3.1 Cable A to C

DFRobot FireBeetle 2 ESP32-E

LED – 2
DSCK – 4
DMOSI – 16
DSS – 17
SCK – 22
MOSI – 23
MISO – 19
CS – 13
GPR – 26
GPT – 25
SCL – 21
SDA – 22
LED – 14
SWI – 3
XAC – A0
YAC – A1
ZAC – A2
VIN – +3.3V
GND – GND

——

DL2406Mk04p.ino

/****** Don Luc Electronics © ******
Software Version Information
Project #29 - DFRobot - HMC5883L - Mk17
29-17
DL2406Mk04p.ino
DL2406Mk04
1 x DFRobot FireBeetle 2 ESP32-E
1 x Adafruit SHARP Memory Display
1 x Adafruit MicroSD card breakout board+
1 x MicroSD 16 GB
1 x SparkFun Triple Axis Magnetometer HMC5883L
1 x SparkFun Triple Axis Accelerometer ADXL335
1 x GPS Receiver - GP-20U7
2 x Switch
1 x 1K Ohm
1 x 1 x Lithium Ion Battery - 1000mAh
1 x Green LED
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"
// Wire
#include <Wire.h>
// SD Card
#include "FS.h"
#include "SD.h"
#include "SPI.h"
// SHARP Memory Display
#include <Adafruit_SharpMem.h>
#include <Adafruit_GFX.h>
// GPS Receiver
#include <TinyGPS++.h>
// ESP32 Hardware Serial
#include <HardwareSerial.h>
// Triple Axis Magnetometer
#include <HMC5883L.h>

// Triple Axis Magnetometer
HMC5883L compass;
// Triple Axis Magnetometer
int mX = 0;
int mY = 0;
int mZ = 0;

// Accelerometer ADXL335
int iX = A0;
int iY = A1;
int iZ = A2;
// Accelerometer
int X = 0;
int Y = 0;
int Z = 0;

// ESP32 HardwareSerial
HardwareSerial tGPS(2);

// GPS Receiver
#define gpsRXPIN 26
// This one is unused and doesnt have a conection
#define gpsTXPIN 25
// 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 TargetALT;
// GPS Status
String GPSSt = "";

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

// SHARP Memory Display
#define SHARP_SCK  4
#define SHARP_MOSI 16
#define SHARP_SS   17
// Set the size of the display here, e.g. 144x168!
Adafruit_SharpMem display(SHARP_SCK, SHARP_MOSI, SHARP_SS, 144, 168);
// The currently-available SHARP Memory Display (144x168 pixels)
// requires > 4K of microcontroller RAM; it WILL NOT WORK on Arduino Uno
// or other <4K "classic" devices.
#define BLACK 0
#define WHITE 1

// LED Green
int iLEDGreen = 2;

// Define LED
int iLED = 14;

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

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

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

void loop() {

  // isGPS
  isGPS();

  // Accelerometer ADXL335
  isADXL335();

  // Magnetometer
  isMagnetometer();

  // Read the state of the Switch value
  iSwitchState = digitalRead(iSwitch);
  
  // The Switch is HIGH:
  if (iSwitchState == HIGH) {

    // Display Accelerometer ADXL335
    isDisplayADXL335();
  
  } else {

    // Display GPS
    isDisplayGPS();
    
  }  

  // MicroSD Card
  isSD();

  // iLED HIGH
  digitalWrite(iLED, HIGH );

  // Delay 5 Second
  delay(5000);

}

getAccelerometer.ino

// Accelerometer ADXL335
// ADXL335
void isADXL335() {

  // Accelerometer ADXL335
  // Accelerometer X, Y, Z
  // X
  X = analogRead(iX);
  // Y
  Y = analogRead(iY);
  // Z
  Z = analogRead(iZ);
  
}

getDisplay.ino

// SHARP Memory Display
// SHARP Memory Display - UID
void isDisplayUID() {

    // Text Display 
    // Clear Display
    display.clearDisplay();
    display.setRotation(4);
    display.setTextSize(3);
    display.setTextColor(BLACK);
    // Don Luc Electronics
    display.setCursor(0,10);
    display.println( "Don Luc" );
    display.setTextSize(2);
    display.setCursor(0,40);
    display.println( "Electronics" );
    // Version
    //display.setTextSize(3);
    display.setCursor(0,70);
    display.println( "Version" );
    //display.setTextSize(2);
    display.setCursor(0,95);   
    display.println( sver );
    // EEPROM
    display.setCursor(0,120);
    display.println( "EEPROM" );
    display.setCursor(0,140);   
    display.println( uid );
    // Refresh
    display.refresh();
    delay( 100 );
    
}
// Display Accelerometer ADXL335
void isDisplayADXL335() {

    // Text Display
    // Clear Display
    display.clearDisplay();
    display.setRotation(4);
    display.setTextSize(2);
    display.setTextColor(BLACK);
    // Accelerometer X
    display.setCursor(0,5);
    display.print( "AX: " );
    display.println( X );
    // Accelerometer Y
    display.setCursor(0,30);
    display.print( "AY: " );
    display.println( Y );
    // Accelerometer Z
    display.setCursor(0,55);
    display.print( "AZ: " );
    display.println( Z );
    // Magnetometer X
    display.setCursor(0,80);
    display.print( "MX: " );
    display.println( mX );
    // Magnetometer Y
    display.setCursor(0,105);
    display.print( "MY: " );
    display.println( mY );
    // Magnetometer Z
    display.setCursor(0,130);
    display.print( "MZ: " );
    display.println( mZ );
    // Refresh
    display.refresh();
    delay( 100 );

}
// Display GPS
void isDisplayGPS() {

    // Text Display Date
    // Clear Display
    display.clearDisplay();
    display.setRotation(4);
    display.setTextSize(2);
    display.setTextColor(BLACK);
    // Latitude
    display.setCursor(0,5);
    display.print( "Lat: " );
    display.println( TargetLat );
    // Longitude
    display.setCursor(0,30);
    display.print( "Lon: " );
    display.println( TargetLon );
    // GPS Date
    display.setCursor(0,55);
    display.println( TargetDat );
    // GPS Time
    display.setCursor(0,80);
    display.println( TargetTim );
    // GPS Speed M/S
    display.setCursor(0,105);
    display.print( TargetSMS );
    display.println( " M/S" );
    // GPS Altitude Meters
    display.setCursor(0,130);
    display.print( TargetALT );
    display.println( " M" );
    // Refresh
    display.refresh();
    delay( 100 );

}

getEEPROM.ino

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

// 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
  TargetALT = "";
  if (gps.altitude.isValid())
  {
    
     // Altitude
     // Meters
     int z = gps.altitude.meters();
     TargetALT = String( z, DEC);

  }
  
}

getMagnetometer.ino

// Magnetometer
// Setup Magnetometer
void isSetupMagnetometer(){

  // Magnetometer Serial
  // Initialize HMC5883L
  while (!compass.begin())
  {
    delay(500);
  }

  // Set measurement range
  // +/- 1.30 Ga: HMC5883L_RANGE_1_3GA (default)
  compass.setRange(HMC5883L_RANGE_1_3GA);

  // Set measurement mode
  // Continuous-Measurement: HMC5883L_CONTINOUS (default)
  compass.setMeasurementMode(HMC5883L_CONTINOUS);
 
  // Set data rate
  // 15.00Hz: HMC5883L_DATARATE_15HZ (default)
  compass.setDataRate(HMC5883L_DATARATE_15HZ);

  // Set number of samples averaged
  // 1 sample:  HMC5883L_SAMPLES_1 (default)
  compass.setSamples(HMC5883L_SAMPLES_1);
  
}
// Magnetometer
void isMagnetometer(){

  // Magnetometer Vector Norm
  Vector norm = compass.readNormalize();
  // Vector X, Y, Z
  // Magnetometer X Normalize
  mX = norm.XAxis;
  // Magnetometer Y Normalize
  mY = norm.YAxis;
  // Magnetometer Z Normalize
  mZ = norm.ZAxis;

}

getSD.ino

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

  // DFR|EEPROM Unique ID|Version|Date|Time|
  //Accelerometer X|Accelerometer Y|Accelerometer Z
  //Magnetometer X|Magnetometer Y|Magnetometer Z
  //|GPS|Latitude|Longitude|GPS Date|GPS Time|GPS Speed M/S|GPS Altitude|*\r
  zzzzzz = "DFR|" + uid + "|" + sver + "|"
  + String(X) + "|" + String(Y) + "|" + String(Z) + "|"
  + String(mX) + "|" + String(mY) + "|" + String(mZ) + "|"
  + String(GPSSt) + "|" + String(TargetLat) + "|" 
  + String(TargetLon) + "|" + String(TargetDat) + "|" + String(TargetTim) + "|" 
  + String(TargetSMS) + "|" + String(TargetALT)+ "|*\r";

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

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

  // Append File
  appendFile(SD, "/dfrdata.txt", msg );
  
}
// 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

// Setup
void setup()
{
  
  // Give display time to power on
  delay(100);

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

  // Give display
  delay(100);

  // Set up I2C bus
  Wire.begin();

  // Give display
  delay(100);

  //MicroSD Card
  isSetupSD();

  // SHARP Display Start & Clear the Display
  display.begin();
  // Clear Display
  display.clearDisplay();

  // Delay
  delay( 100 );

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

  // Delay
  delay( 100 );

  // Setup Triple Axis Magnetometer
  isSetupMagnetometer();

  // Delay
  delay( 100 );

  // Initialize digital pin iLED as an output
  pinMode(iLED, OUTPUT);

  // Outputting high, the LED turns on
  digitalWrite(iLED, HIGH);

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

  // iLEDGreen HIGH
  digitalWrite(iLEDGreen, HIGH );

  // Initialize the Switch
  pinMode(iSwitch, INPUT);

  // Don Luc Electronics
  // Version
  // EEPROM
  isDisplayUID();
  
  // Delay 5 Second
  delay( 5000 );

}

——

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

Teacher, Instructor, E-Mentor, 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/
LinkedIn: https://www.linkedin.com/in/jlucpaquin/

Don Luc

Project #29 – DFRobot – ADXL335 – Mk16

——

#DonLucElectronics #DonLuc #DFRobot #ADXL335 #GPS #FireBeetle2ESP32E #EEPROM #RTC #SD #Display #Adafruit #SparkFun #ESP32 #IoT #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

ADXL335

——

ADXL335

——

ADXL335

——

SparkFun Triple Axis Accelerometer Breakout – ADXL335

Breakout board for the 3 axis ADXL335 from Analog Devices. This is the latest in a long, proven line of analog sensors – the holy grail of accelerometers. The ADXL335 is a triple axis MEMS accelerometer with extremely low noise and power consumption only 320 uA. The sensor has a full sensing range of +/- 3g. There is no on-board regulation, provided power should be between 1.8 and 3.6 Volt. Board comes fully assembled and tested with external components installed. The included 0.1 uF capacitors set the bandwidth of each axis to 50 Hz.

DL2406Mk03

1 x DFRobot FireBeetle 2 ESP32-E
1 x Adafruit SHARP Memory Display
1 x Adafruit MicroSD card breakout board+
1 x MicroSD 16 GB
1 x Adafruit DS3231 Precision RTC FeatherWing – RTC
1 x Battery CR1220
1 x SparkFun Triple Axis Accelerometer ADXL335
1 x GPS Receiver – GP-20U7
2 x Switch
1 x 1K Ohm
1 x 1 x Lithium Ion Battery – 1000mAh
1 x Green LED
1 x USB 3.1 Cable A to C

DFRobot FireBeetle 2 ESP32-E

LED – 2
DSCK – 4
DMOSI – 16
DSS – 17
SCK – 22
MOSI – 23
MISO – 19
CS – 13
GPR – 26
GPT – 25
SCL – 21
SDA – 22
LED – 14
SWI – 3
XAC – A0
YAC – A1
ZAC – A2
VIN – +3.3V
GND – GND

——

DL2406Mk03p.ino

/****** Don Luc Electronics © ******
Software Version Information
Project #29 - DFRobot - ADXL335 - Mk16
29-16
DL2406Mk03p.ino
DL2406Mk03
1 x DFRobot FireBeetle 2 ESP32-E
1 x Adafruit SHARP Memory Display
1 x Adafruit MicroSD card breakout board+
1 x MicroSD 16 GB
1 x Adafruit DS3231 Precision RTC FeatherWing - RTC
1 x Battery CR1220
1 x SparkFun Triple Axis Accelerometer ADXL335
1 x GPS Receiver - GP-20U7
2 x Switch
1 x 1K Ohm
1 x 1 x Lithium Ion Battery - 1000mAh
1 x Green LED
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"
// Wire
#include <Wire.h>
// DS3231 RTC Date and Time
#include <RTClib.h>
// SD Card
#include "FS.h"
#include "SD.h"
#include "SPI.h"
// SHARP Memory Display
#include <Adafruit_SharpMem.h>
#include <Adafruit_GFX.h>
// GPS Receiver
#include <TinyGPS++.h>
// ESP32 Hardware Serial
#include <HardwareSerial.h>

// Accelerometer ADXL335
int iX = A0;
int iY = A1;
int iZ = A2;
// Accelerometer
int X = 0;
int Y = 0;
int Z = 0;

// ESP32 HardwareSerial
HardwareSerial tGPS(2);

// GPS Receiver
#define gpsRXPIN 26
// This one is unused and doesnt have a conection
#define gpsTXPIN 25
// 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 TargetALT;
// GPS Status
String GPSSt = "";

// DS3231 RTC Date and Time
RTC_DS3231 rtc;
String sDate;
String sTime;

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

// SHARP Memory Display
#define SHARP_SCK  4
#define SHARP_MOSI 16
#define SHARP_SS   17
// Set the size of the display here, e.g. 144x168!
Adafruit_SharpMem display(SHARP_SCK, SHARP_MOSI, SHARP_SS, 144, 168);
// The currently-available SHARP Memory Display (144x168 pixels)
// requires > 4K of microcontroller RAM; it WILL NOT WORK on Arduino Uno
// or other <4K "classic" devices.
#define BLACK 0
#define WHITE 1

// LED Green
int iLEDGreen = 2;

// Define LED
int iLED = 14;

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

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

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

void loop() {

  // DS3231 RTC Date and Time
  isRTC();

  // isGPS
  isGPS();

  // Accelerometer ADXL335
  isADXL335();

  // Read the state of the Switch value
  iSwitchState = digitalRead(iSwitch);
  
  // The Switch is HIGH:
  if (iSwitchState == HIGH) {

    // Display Accelerometer ADXL335
    isDisplayADXL335();
  
  } else {

    // Display GPS
    isDisplayGPS();
    
  }  

  // MicroSD Card
  isSD();

  // iLED HIGH
  digitalWrite(iLED, HIGH );

  // Delay 5 Second
  delay(5000);

}

getAccelerometer.ino

// Accelerometer ADXL335
// ADXL335
void isADXL335() {

  // Accelerometer ADXL335
  // Accelerometer X, Y, Z
  // X
  X = analogRead(iX);
  // Y
  Y = analogRead(iY);
  // Z
  Z = analogRead(iZ);
  
}

getDisplay.ino

// SHARP Memory Display
// SHARP Memory Display - UID
void isDisplayUID() {

    // Text Display 
    // Clear Display
    display.clearDisplay();
    display.setRotation(4);
    display.setTextSize(3);
    display.setTextColor(BLACK);
    // Don Luc Electronics
    display.setCursor(0,10);
    display.println( "Don Luc" );
    display.setTextSize(2);
    display.setCursor(0,40);
    display.println( "Electronics" );
    // Version
    //display.setTextSize(3);
    display.setCursor(0,70);
    display.println( "Version" );
    //display.setTextSize(2);
    display.setCursor(0,95);   
    display.println( sver );
    // EEPROM
    display.setCursor(0,120);
    display.println( "EEPROM" );
    display.setCursor(0,140);   
    display.println( uid );
    // Refresh
    display.refresh();
    delay( 100 );
    
}
// Display Accelerometer ADXL335
void isDisplayADXL335() {

    // Text Display
    // Clear Display
    display.clearDisplay();
    display.setRotation(4);
    display.setTextSize(2);
    display.setTextColor(BLACK);
    // Date
    display.setCursor(0,5);
    display.println( sDate );
    // Time
    display.setCursor(0,30);
    display.println( sTime );
    // X
    display.setCursor(0,55);
    display.print( "X: " );
    display.println( X );
    // Y
    display.setCursor(0,80);
    display.print( "Y: " );
    display.println( Y );
    // Z
    display.setCursor(0,105);
    display.print( "Z: " );
    display.println( Z );
    // Refresh
    display.refresh();
    delay( 100 );

}
// Display GPS
void isDisplayGPS() {

    // Text Display Date
    // Clear Display
    display.clearDisplay();
    display.setRotation(4);
    display.setTextSize(2);
    display.setTextColor(BLACK);
    // Latitude
    display.setCursor(0,5);
    display.print( "Lat: " );
    display.println( TargetLat );
    // Longitude
    display.setCursor(0,30);
    display.print( "Lon: " );
    display.println( TargetLon );
    // GPS Date
    display.setCursor(0,55);
    display.println( TargetDat );
    // GPS Time
    display.setCursor(0,80);
    display.println( TargetTim );
    // GPS Speed M/S
    display.setCursor(0,105);
    display.print( TargetSMS );
    display.println( " M/S" );
    // GPS Altitude Meters
    display.setCursor(0,130);
    display.print( TargetALT );
    display.println( " M" );
    // Refresh
    display.refresh();
    delay( 100 );

}

getEEPROM.ino

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

// 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
  TargetALT = "";
  if (gps.altitude.isValid())
  {
    
     // Altitude
     // Meters
     int z = gps.altitude.meters();
     TargetALT = String( z, DEC);

  }
  
}

getRTC.ino

// DS3231 RTC Date and Time
// Setup DS3231 RTC
void isSetupRTC() {

  if (! rtc.begin()) {
    while (1);
  }

  if (rtc.lostPower()) {
    // 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));
  }
  
}
// DS3231 RTC Date and Time
void isRTC(){
 
    // Date and Time
    sDate = "";
    sTime = "";
    // Date Time
    DateTime now = rtc.now();

    // sData
    sDate += String(now.year(), DEC);
    sDate += "/";
    sDate += String(now.month(), DEC);
    sDate += "/";
    sDate += String(now.day(), DEC);

    // sTime
    sTime += String(now.hour(), DEC);
    sTime += ":";
    sTime += String(now.minute(), DEC);
    sTime += ":";
    sTime += String(now.second(), DEC);

}

getSD.ino

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

  // DFR|EEPROM Unique ID|Version|Date|Time|
  //Accelerometer X|Accelerometer Y|Accelerometer Z
  //|GPS|Latitude|Longitude|GPS Date|GPS Time|GPS Speed M/S|GPS Altitude|*\r
  zzzzzz = "DFR|" + uid + "|" + sver + "|" + String(sDate) + "|" + String(sTime) + "|"
  + String(X) + "|" + String(Y) + "|" + String(Z) + "|"
  + String(GPSSt) + "|" + String(TargetLat) + "|" 
  + String(TargetLon) + "|" + String(TargetDat) + "|" + String(TargetTim) + "|" 
  + String(TargetSMS) + "|" + String(TargetALT)+ "|*\r";

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

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

  // Append File
  appendFile(SD, "/dfrdata.txt", msg );
  
}
// 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

// Setup
void setup()
{
  
  // Give display time to power on
  delay(100);

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

  // Give display
  delay(100);

  // Set up I2C bus
  Wire.begin();

  // Give display
  delay(100);

  // Setup DS3231 RTC
  isSetupRTC();

  //MicroSD Card
  isSetupSD();

  // SHARP Display Start & Clear the Display
  display.begin();
  // Clear Display
  display.clearDisplay();

  // Delay
  delay( 100 );

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

  // Initialize digital pin iLED as an output
  pinMode(iLED, OUTPUT);

  // Outputting high, the LED turns on
  digitalWrite(iLED, HIGH);

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

  // iLEDGreen HIGH
  digitalWrite(iLEDGreen, HIGH );

  // Initialize the Switch
  pinMode(iSwitch, INPUT);

  // Don Luc Electronics
  // Version
  // EEPROM
  isDisplayUID();
  
  // Delay 5 Second
  delay( 5000 );

}

——

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

Teacher, Instructor, E-Mentor, 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/
LinkedIn: https://www.linkedin.com/in/jlucpaquin/

Don Luc

Project #29 – DFRobot – GPS Receiver – Mk15

——

#DonLucElectronics #DonLuc #DFRobot #GPS #BME280 #CCS811 #FireBeetle2ESP32E #EEPROM #RTC #SD #Display #Adafruit #SparkFun #ESP32 #IoT #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #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.

DL2406Mk02

1 x DFRobot FireBeetle 2 ESP32-E
1 x Adafruit SHARP Memory Display
1 x Adafruit MicroSD card breakout board+
1 x MicroSD 16 GB
1 x Adafruit DS3231 Precision RTC FeatherWing – RTC
1 x Battery CR1220
1 x SparkFun Environmental Combo CCS811/BME280
1 x GPS Receiver – GP-20U7
3 x Switch
2 x 1K Ohm
1 x 1 x Lithium Ion Battery – 1000mAh
1 x Green LED
1 x USB 3.1 Cable A to C

DFRobot FireBeetle 2 ESP32-E

LED – 2
DSCK – 4
DMOSI – 16
DSS – 17
SCK – 22
MOSI – 23
MISO – 19
CS – 13
GPR – 26
GPT – 25
SCL – 21
SDA – 22
LED – 14
SWI – 3
SWG – 1
VIN – +3.3V
GND – GND

——

DL2406Mk02p.ino

/****** Don Luc Electronics © ******
Software Version Information
Project #29 - DFRobot - GPS Receiver - Mk15
29-15
DL2406Mk02p.ino
DL2406Mk02
1 x DFRobot FireBeetle 2 ESP32-E
1 x Adafruit SHARP Memory Display
1 x Adafruit MicroSD card breakout board+
1 x MicroSD 16 GB
1 x Adafruit DS3231 Precision RTC FeatherWing - RTC
1 x Battery CR1220
1 x SparkFun Environmental Combo CCS811/BME280
1 x GPS Receiver - GP-20U7
3 x Switch
2 x 1K Ohm
1 x 1 x Lithium Ion Battery - 1000mAh
1 x Green LED
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"
// Wire
#include <Wire.h>
// DS3231 RTC Date and Time
#include <RTClib.h>
// SD Card
#include "FS.h"
#include "SD.h"
#include "SPI.h"
// SHARP Memory Display
#include <Adafruit_SharpMem.h>
#include <Adafruit_GFX.h>
// SparkFun BME280 - Humidity, Temperature, Altitude and Barometric Pressure
#include <SparkFunBME280.h>
// SparkFun CCS811 - eCO2 & tVOC
#include <SparkFunCCS811.h>
// GPS Receiver
#include <TinyGPS++.h>
// ESP32 Hardware Serial
#include <HardwareSerial.h>

// ESP32 HardwareSerial
HardwareSerial tGPS(2);

// GPS Receiver
#define gpsRXPIN 26
// This one is unused and doesnt have a conection
#define gpsTXPIN 25
// 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 TargetALT;
// GPS Status
String GPSSt = "";

// SparkFun BME280 - Temperature, Humidity, Altitude and Barometric Pressure
BME280 myBME280;
// Temperature Celsius
float BMEtempC = 0;
// Humidity
float BMEhumid = 0;
// Altitude Meters
float BMEaltitudeM = 0;
// Barometric Pressure
float BMEpressure = 0;

// SparkFun CCS811 - eCO2 & tVOC
// Default I2C Address
#define CCS811_ADDR 0x5B 
CCS811 myCCS811(CCS811_ADDR);
// eCO2
float CCS811CO2 = 0;
// TVOC
float CCS811TVOC = 0;

// DS3231 RTC Date and Time
RTC_DS3231 rtc;
String sDate;
String sTime;

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

// SHARP Memory Display
#define SHARP_SCK  4
#define SHARP_MOSI 16
#define SHARP_SS   17
// Set the size of the display here, e.g. 144x168!
Adafruit_SharpMem display(SHARP_SCK, SHARP_MOSI, SHARP_SS, 144, 168);
// The currently-available SHARP Memory Display (144x168 pixels)
// requires > 4K of microcontroller RAM; it WILL NOT WORK on Arduino Uno
// or other <4K "classic" devices.
#define BLACK 0
#define WHITE 1

// LED Green
int iLEDGreen = 2;

// Define LED
int iLED = 14;

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

// Switch GPS
int iSwitchGPS = 1;
// Variable for reading the Switch GPS status
int iSwitchGPSState = 0;

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

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

void loop() {

  // DS3231 RTC Date and Time
  isRTC();

  // SparkFun BME280 - Temperature, Humidity, Altitude and Barometric Pressure
  isBME280();

  // SparkFun CCS811 - eCO2 & tVOC
  isCCS811();

  // isGPS
  isGPS();

  // Read the state of the Switch value
  iSwitchState = digitalRead(iSwitch);
  
  // The Switch is HIGH:
  if (iSwitchState == HIGH) {

    // Display Date, Time, Temperature, Humidity
    isDisplayDTTH();
  
  } else {
    
    // Read the state of the Switch value
    iSwitchGPSState = digitalRead(iSwitchGPS);
    
    if (iSwitchGPSState == HIGH) {

      // Display GPS
      isDisplayGPS();
      
    } else {
      
      // Display Date, Time, eCO2 Concentration, tVOC Concentration
      isDisplayDTCOVO();

    }  

  }
  
  // MicroSD Card
  isSD();

  // iLED HIGH
  digitalWrite(iLED, HIGH );

  // Delay 5 Second
  delay(5000);

}

getBME280.ino

// SparkFun BME280 - Temperature, Humidity, Altitude and Barometric Pressure
// isBME280 - Temperature, Humidity, Altitude and Barometric Pressure
void isBME280(){

  // Temperature Celsius
  BMEtempC = myBME280.readTempC();
  // Humidity
  BMEhumid = myBME280.readFloatHumidity() ;
  // Altitude Meters
  BMEaltitudeM = myBME280.readFloatAltitudeMeters();
  // Barometric Pressure
  BMEpressure = myBME280.readFloatPressure();
  
}

getCCS811.ino

// CCS811 - eCO2 & tVOC
// isCCS811 - eCO2 & tVOC
void isCCS811(){

  // This sends the temperature & humidity data to the CCS811
  myCCS811.setEnvironmentalData(BMEhumid, BMEtempC);

  // Calling this function updates the global tVOC and eCO2 variables
  myCCS811.readAlgorithmResults();

  // eCO2 Concentration
  CCS811CO2 = myCCS811.getCO2();
  
  // tVOC Concentration
  CCS811TVOC = myCCS811.getTVOC();
  
}

getDisplay.ino

// SHARP Memory Display
// SHARP Memory Display - UID
void isDisplayUID() {

    // Text Display 
    // Clear Display
    display.clearDisplay();
    display.setRotation(4);
    display.setTextSize(3);
    display.setTextColor(BLACK);
    // Don Luc Electronics
    display.setCursor(0,10);
    display.println( "Don Luc" );
    display.setTextSize(2);
    display.setCursor(0,40);
    display.println( "Electronics" );
    // Version
    //display.setTextSize(3);
    display.setCursor(0,70);
    display.println( "Version" );
    //display.setTextSize(2);
    display.setCursor(0,95);   
    display.println( sver );
    // EEPROM
    display.setCursor(0,120);
    display.println( "EEPROM" );
    display.setCursor(0,140);   
    display.println( uid );
    // Refresh
    display.refresh();
    delay( 100 );
    
}
// Display Date, Time, Temperature, Humidity, Altitude and Barometric Pressure
void isDisplayDTTH() {

    // Text Display Date
    // Clear Display
    display.clearDisplay();
    display.setRotation(4);
    display.setTextSize(2);
    display.setTextColor(BLACK);
    // Date
    display.setCursor(0,5);
    display.println( sDate );
    // Time
    display.setCursor(0,30);
    display.println( sTime );
    // Temperature
    display.setCursor(0,55);
    display.print( BMEtempC );
    display.println( "C" );
    // Humidity
    display.setCursor(0,80);
    display.print( BMEhumid );
    display.println( "%" );
    // Altitude Meters
    display.setCursor(0,105);
    display.print( BMEaltitudeM );
    display.println( "M" );
    // Barometric Pressure
    display.setCursor(0,130);
    display.println( BMEpressure );
    // Refresh
    display.refresh();
    delay( 100 );

}
// Display Display Date, Time, eCO2 Concentration, tVOC Concentration
void isDisplayDTCOVO() {

    // Text Display Date
    // Clear Display
    display.clearDisplay();
    display.setRotation(4);
    display.setTextSize(2);
    display.setTextColor(BLACK);
    // Date
    display.setCursor(0,5);
    display.println( sDate );
    // Time
    display.setCursor(0,30);
    display.println( sTime );
    // eCO2 Concentration
    display.setCursor(0,55);
    display.println( "eCO2" );
    display.setCursor(0,80);
    display.println( CCS811CO2 );
    // tVOC Concentration
    display.setCursor(0,105);
    display.println( "tVOC" );
    display.setCursor(0,130);
    display.println( CCS811TVOC );
    // Refresh
    display.refresh();
    delay( 100 );

}
// Display GPS
void isDisplayGPS() {

    // Text Display Date
    // Clear Display
    display.clearDisplay();
    display.setRotation(4);
    display.setTextSize(2);
    display.setTextColor(BLACK);
    // Latitude
    display.setCursor(0,5);
    display.print( "Lat: " );
    display.println( TargetLat );
    // Longitude
    display.setCursor(0,30);
    display.print( "Lon: " );
    display.println( TargetLon );
    // GPS Date
    display.setCursor(0,55);
    display.println( TargetDat );
    // GPS Time
    display.setCursor(0,80);
    display.println( TargetTim );
    // GPS Speed M/S
    display.setCursor(0,105);
    display.print( TargetSMS );
    display.println( " M/S" );
    // GPS Altitude Meters
    display.setCursor(0,130);
    display.print( TargetALT );
    display.println( " M" );
    // Refresh
    display.refresh();
    delay( 100 );

}

getEEPROM.ino

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

// 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
  TargetALT = "";
  if (gps.altitude.isValid())
  {
    
     // Altitude
     // Meters
     int z = gps.altitude.meters();
     TargetALT = String( z, DEC);

  }
  
}

getRTC.ino

// DS3231 RTC Date and Time
// Setup DS3231 RTC
void isSetupRTC() {

  if (! rtc.begin()) {
    while (1);
  }

  if (rtc.lostPower()) {
    // 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));
  }
  
}
// DS3231 RTC Date and Time
void isRTC(){
 
    // Date and Time
    sDate = "";
    sTime = "";
    // Date Time
    DateTime now = rtc.now();

    // sData
    sDate += String(now.year(), DEC);
    sDate += "/";
    sDate += String(now.month(), DEC);
    sDate += "/";
    sDate += String(now.day(), DEC);

    // sTime
    sTime += String(now.hour(), DEC);
    sTime += ":";
    sTime += String(now.minute(), DEC);
    sTime += ":";
    sTime += String(now.second(), DEC);

}

getSD.ino

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

  // DFR|EEPROM Unique ID|Version|Date|Time|Temperature Celsius|Humidity
  //|Altitude Meters|Barometric Pressure|eCO2 Concentration|tVOC Concentration
  //|GPS|Latitude|Longitude|GPS Date|GPS Time|GPS Speed M/S|GPS Altitude|*\r
  zzzzzz = "DFR|" + uid + "|" + sver + "|" + sDate + "|" + sTime + "|" 
  + String(BMEtempC) + "C|" + String(BMEhumid) + "%|" 
  + String(BMEaltitudeM) + " M|" + String(BMEpressure) + "|" + String(CCS811CO2) + "|" 
  + String(CCS811TVOC) + "|" + String(GPSSt) + "|" + String(TargetLat) + "|" 
  + String(TargetLon) + "|" + String(TargetDat) + "|" + String(TargetTim) + "|" 
  + String(TargetSMS) + "|" + String(TargetALT)+ "|*\r";

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

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

  // Append File
  appendFile(SD, "/dfrdata.txt", msg );
  
}
// 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

// Setup
void setup()
{
  
  // Give display time to power on
  delay(100);

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

  // Give display
  delay(100);

  // Set up I2C bus
  Wire.begin();

  // Give display
  delay(100);

  // Setup DS3231 RTC
  isSetupRTC();

  //MicroSD Card
  isSetupSD();

  // SHARP Display Start & Clear the Display
  display.begin();
  // Clear Display
  display.clearDisplay();

  // Delay
  delay( 100 );

  // SparkFun BME280 - Temperature, Humidity, Altitude and Barometric Pressure
  myBME280.begin();

  // CCS811 - eCO2 & tVOC
  myCCS811.begin();

  // Delay
  delay( 100 );

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

  // Initialize digital pin iLED as an output
  pinMode(iLED, OUTPUT);

  // Outputting high, the LED turns on
  digitalWrite(iLED, HIGH);

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

  // iLEDGreen HIGH
  digitalWrite(iLEDGreen, HIGH );

  // Initialize the Switch
  pinMode(iSwitch, INPUT);

  // Initialize the Switch GPS
  pinMode(iSwitchGPS, INPUT);

  // Don Luc Electronics
  // Version
  // EEPROM
  isDisplayUID();
  
  // Delay 5 Second
  delay( 5000 );

}

——

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

Teacher, Instructor, E-Mentor, 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/
LinkedIn: https://www.linkedin.com/in/jlucpaquin/

Don Luc

Project #29 – DFRobot – Environmental Combo – Mk14

——

#DonLucElectronics #DonLuc #DFRobot #BME280 #CCS811 #FireBeetle2ESP32E #EEPROM #RTC #SD #Display #Adafruit #SparkFun #ESP32 #IoT #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

Environmental Combo

——

Environmental Combo

——

Environmental Combo

——

SparkFun Environmental Combo Breakout – CCS811/BME280

The SparkFun CCS811/BME280 Environmental Combo Breakout takes care of all your atmospheric-quality sensing needs with the popular CCS811 and BME280 ICs. This unique breakout provides a variety of environmental data, including barometric pressure, humidity, temperature, TVOCs and equivalent eCO2 levels. To make it even easier to use this breakout, all communication is enacted exclusively via I2C, utilizing our handy Qwiic system.

The CCS811 is an exceedingly popular sensor, providing readings for equivalent eCO2 in the parts per million (PPM) and total volatile organic compounds in the parts per billion (PPB). The CCS811 also has a feature that allows it to fine-tune its readings if it has access to the current humidity and temperature. Luckily for us, the BME280 provides humidity, temperature and barometric pressure. This allows the sensors to work together to give us more accurate readings than they’d be able to provide on their own. We also made it easy to interface with them via I2C.

DL2406Mk01

1 x DFRobot FireBeetle 2 ESP32-E
1 x Adafruit SHARP Memory Display
1 x Adafruit MicroSD card breakout board+
1 x MicroSD 16 GB
1 x Adafruit DS3231 Precision RTC FeatherWing – RTC
1 x Battery CR1220
1 x SparkFun Environmental Combo CCS811/BME280
2 x Switch
1 x 1K Ohm
1 x 1 x Lithium Ion Battery – 1000mAh
1 x Green LED
1 x Slide Switch
1 x USB 3.1 Cable A to C

DFRobot FireBeetle 2 ESP32-E

LED – 2
DSCK – 4
DMOSI – 16
DSS – 17
SCK – 22
MOSI – 23
MISO – 19
CS – 13
SCL – 21
SDA – 22
LED – 14
SWI – 3
VIN – +3.3V
GND – GND

——

DL2406Mk01p.ino

/****** Don Luc Electronics © ******
Software Version Information
Project #29 - DFRobot - Environmental Combo - Mk14
29-14
DL2406Mk01p.ino
1 x DFRobot FireBeetle 2 ESP32-E
1 x Adafruit SHARP Memory Display
1 x Adafruit MicroSD card breakout board+
1 x MicroSD 16 GB
1 x Adafruit DS3231 Precision RTC FeatherWing - RTC
1 x Battery CR1220
1 x SparkFun Environmental Combo CCS811/BME280
2 x Switch
1 x 1K Ohm
1 x 1 x Lithium Ion Battery - 1000mAh
1 x Green LED
1 x Slide Switch
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"
// Wire
#include <Wire.h>
// DS3231 RTC Date and Time
#include <RTClib.h>
// SD Card
#include "FS.h"
#include "SD.h"
#include "SPI.h"
// SHARP Memory Display
#include <Adafruit_SharpMem.h>
#include <Adafruit_GFX.h>
// SparkFun BME280 - Humidity, Temperature, Altitude and Barometric Pressure
#include <SparkFunBME280.h>
// SparkFun CCS811 - eCO2 & tVOC
#include <SparkFunCCS811.h>

// SparkFun BME280 - Temperature, Humidity, Altitude and Barometric Pressure
BME280 myBME280;
// Temperature Celsius
float BMEtempC = 0;
// Humidity
float BMEhumid = 0;
// Altitude Meters
float BMEaltitudeM = 0;
// Barometric Pressure
float BMEpressure = 0;

// SparkFun CCS811 - eCO2 & tVOC
// Default I2C Address
#define CCS811_ADDR 0x5B 
CCS811 myCCS811(CCS811_ADDR);
// eCO2
float CCS811CO2 = 0;
// TVOC
float CCS811TVOC = 0;

// DS3231 RTC Date and Time
RTC_DS3231 rtc;
String sDate;
String sTime;

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

// SHARP Memory Display
#define SHARP_SCK  4
#define SHARP_MOSI 16
#define SHARP_SS   17
// Set the size of the display here, e.g. 144x168!
Adafruit_SharpMem display(SHARP_SCK, SHARP_MOSI, SHARP_SS, 144, 168);
// The currently-available SHARP Memory Display (144x168 pixels)
// requires > 4K of microcontroller RAM; it WILL NOT WORK on Arduino Uno
// or other <4K "classic" devices.
#define BLACK 0
#define WHITE 1

// LED Green
int iLEDGreen = 2;

// Define LED
int iLED = 14;

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

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

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

void loop() {

  // DS3231 RTC Date and Time
  isRTC();

  // SparkFun BME280 - Temperature, Humidity, Altitude and Barometric Pressure
  isBME280();

  // SparkFun CCS811 - eCO2 & tVOC
  isCCS811();

  // Read the state of the Switch value
  iSwitchState = digitalRead(iSwitch);
  
  // The Switch is HIGH:
  if (iSwitchState == HIGH) {

    // Display Date, Time, Temperature, Humidity
    isDisplayDTTH();
  
  } else {
    
    // Display Date, Time, eCO2 Concentration, tVOC Concentration
    isDisplayDTCOVO();

    
  }
  
  // MicroSD Card
  isSD();

  // iLED HIGH
  digitalWrite(iLED, HIGH );

  // Delay 1 Second
  delay(1000);

}

getBME280.ino

// SparkFun BME280 - Temperature, Humidity, Altitude and Barometric Pressure
// isBME280 - Temperature, Humidity, Altitude and Barometric Pressure
void isBME280(){

  // Temperature Celsius
  BMEtempC = myBME280.readTempC();
  // Humidity
  BMEhumid = myBME280.readFloatHumidity() ;
  // Altitude Meters
  BMEaltitudeM = myBME280.readFloatAltitudeMeters();
  // Barometric Pressure
  BMEpressure = myBME280.readFloatPressure();
  
}

getCCS811.ino

// CCS811 - eCO2 & tVOC
// isCCS811 - eCO2 & tVOC
void isCCS811(){

  // This sends the temperature & humidity data to the CCS811
  myCCS811.setEnvironmentalData(BMEhumid, BMEtempC);

  // Calling this function updates the global tVOC and eCO2 variables
  myCCS811.readAlgorithmResults();

  // eCO2 Concentration
  CCS811CO2 = myCCS811.getCO2();
  
  // tVOC Concentration
  CCS811TVOC = myCCS811.getTVOC();
  
}

getDisplay.ino

// SHARP Memory Display
// SHARP Memory Display - UID
void isDisplayUID() {

    // Text Display 
    // Clear Display
    display.clearDisplay();
    display.setRotation(4);
    display.setTextSize(3);
    display.setTextColor(BLACK);
    // Don Luc Electronics
    display.setCursor(0,10);
    display.println( "Don Luc" );
    display.setTextSize(2);
    display.setCursor(0,40);
    display.println( "Electronics" );
    // Version
    //display.setTextSize(3);
    display.setCursor(0,70);
    display.println( "Version" );
    //display.setTextSize(2);
    display.setCursor(0,95);   
    display.println( sver );
    // EEPROM
    display.setCursor(0,120);
    display.println( "EEPROM" );
    display.setCursor(0,140);   
    display.println( uid );
    // Refresh
    display.refresh();
    delay( 100 );
    
}
// Display Date, Time, Temperature, Humidity, Altitude and Barometric Pressure
void isDisplayDTTH() {

    // Text Display Date
    // Clear Display
    display.clearDisplay();
    display.setRotation(4);
    display.setTextSize(2);
    display.setTextColor(BLACK);
    // Date
    display.setCursor(0,5);
    display.println( sDate );
    // Time
    display.setCursor(0,30);
    display.println( sTime );
    // Temperature
    display.setCursor(0,55);
    display.print( BMEtempC );
    display.println( "C" );
    // Humidity
    display.setCursor(0,80);
    display.print( BMEhumid );
    display.println( "%" );
    // Altitude Meters
    display.setCursor(0,105);
    display.print( BMEaltitudeM );
    display.println( "M" );
    // Barometric Pressure
    display.setCursor(0,130);
    display.println( BMEpressure );
    // Refresh
    display.refresh();
    delay( 100 );

}
// Display Display Date, Time, eCO2 Concentration, tVOC Concentration
void isDisplayDTCOVO() {

    // Text Display Date
    // Clear Display
    display.clearDisplay();
    display.setRotation(4);
    display.setTextSize(2);
    display.setTextColor(BLACK);
    // Date
    display.setCursor(0,5);
    display.println( sDate );
    // Time
    display.setCursor(0,30);
    display.println( sTime );
    // eCO2 Concentration
    display.setCursor(0,55);
    display.println( "eCO2" );
    display.setCursor(0,80);
    display.println( CCS811CO2 );
    // tVOC Concentration
    display.setCursor(0,105);
    display.println( "tVOC" );
    display.setCursor(0,130);
    display.println( CCS811TVOC );
    // Refresh
    display.refresh();
    delay( 100 );

}

getEEPROM.ino

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

// DS3231 RTC Date and Time
// Setup DS3231 RTC
void isSetupRTC() {

  if (! rtc.begin()) {
    while (1);
  }

  if (rtc.lostPower()) {
    // 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));
  }
  
}
// DS3231 RTC Date and Time
void isRTC(){
 
    // Date and Time
    sDate = "";
    sTime = "";
    // Date Time
    DateTime now = rtc.now();

    // sData
    sDate += String(now.year(), DEC);
    sDate += "/";
    sDate += String(now.month(), DEC);
    sDate += "/";
    sDate += String(now.day(), DEC);

    // sTime
    sTime += String(now.hour(), DEC);
    sTime += ":";
    sTime += String(now.minute(), DEC);
    sTime += ":";
    sTime += String(now.second(), DEC);

}

getSD.ino

// MicroSD Card
// MicroSD Setup
void setupSD() {

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

  // DFR|EEPROM Unique ID|Version|Date|Time|Temperature Celsius|Humidity
  //|Altitude Meters|Barometric Pressure|eCO2 Concentration|tVOC Concentration|*\r
  zzzzzz = "DFR|" + uid + "|" + sver + "|" + sDate + "|" + sTime + "|" 
  + String(BMEtempC) + "C|" + String(BMEhumid) + "%|" 
  + String(BMEaltitudeM) + " M|" + String(BMEpressure) + "|" + String(CCS811CO2) + "|" 
  + String(CCS811TVOC) + "|*\r";

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

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

  // Append File
  appendFile(SD, "/dfrdata.txt", msg );
  
}
// 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

// Setup
void setup()
{
  
  // Give display time to power on
  delay(100);

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

  // Give display
  delay(100);

  // Set up I2C bus
  Wire.begin();

  // Give display
  delay(100);

  // Setup DS3231 RTC
  isSetupRTC();

  //MicroSD Card
  setupSD();

  // SHARP Display Start & Clear the Display
  display.begin();
  // Clear Display
  display.clearDisplay();

  // Delay
  delay( 100 );

  // SparkFun BME280 - Temperature, Humidity, Altitude and Barometric Pressure
  myBME280.begin();

  // CCS811 - eCO2 & tVOC
  myCCS811.begin();

  // Delay
  delay( 100 );

  // Initialize digital pin iLED as an output
  pinMode(iLED, OUTPUT);

  // Outputting high, the LED turns on
  digitalWrite(iLED, HIGH);

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

  // iLEDGreen HIGH
  digitalWrite(iLEDGreen, HIGH );

  // Initialize the Switch
  pinMode(iSwitch, INPUT);

  // Don Luc Electronics
  // Version
  // EEPROM
  isDisplayUID();
  
  // Delay 5 Second
  delay( 5000 );

}

——

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

Teacher, Instructor, E-Mentor, 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/
LinkedIn: https://www.linkedin.com/in/jlucpaquin/

Don Luc

Project #28 – Sensors – MMA7361 – Mk14

——

#DonLucElectronics #DonLuc #Sensors #MMA7361 #Adafruit #SparkFun #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

MMA7361

——

MMA7361

——

MMA7361

——

SparkFun Triple Axis Accelerometer Breakout – MMA7361

This is a breakout board for Freescale’s MMA7361L three-axis analog MEMS accelerometer. The sensor requires a very low amount of power and has a g-select input which switches the accelerometer between ±1.5g and ±6g measurement ranges. Other features include a sleep mode, signal conditioning, a 1-pole low pass filter, temperature compensation, self test, and 0g-detect which detects linear freefall. Zero-g offset and sensitivity are factory set and require no external devices.

This breadboard friendly board breaks out every pin of the MMA7361L to a 9-pin, 0.1″ pitch header. The sensor works on power between 2.2 and 3.6VDC (3.3 Volt optimal), and typically consumes just 400µA of current. All three axes have their own analog output.

  • Two selectable measuring ranges (±1.5g, ±6g)
  • Breadboard friendly – 0.1″ pitch header
  • Low current consumption: 400 µA
  • Sleep mode: 3 µA
  • Low voltage operation: 2.2 Volt – 3.6 Volt
  • High sensitivity (800 mV/g at 1.5g)
  • Fast turn on time (0.5 ms enable response time)
  • Self test for freefall detect diagnosis
  • 0g-Detect for freefall protection
  • Signal conditioning with low pass filter
  • Robust design, high shocks survivability

DL2401Mk04

1 x SparkFun Thing Plus – ESP32 WROOM
1 x DS3231 Precision RTC FeatherWing
1 x SparkFun Triple Axis Accelerometer Breakout – MMA7361
1 x Rocker Switch – SPST
1 x Resistor 10K Ohm
1 x CR1220 3V Lithium Coin Cell Battery
1 x 1 x Lithium Ion Battery – 1000mAh
1 x Terminal Block Breakout FeatherWing
1 x SparkFun Cerberus USB Cable

SparkFun Thing Plus – ESP32 WROOM

LED – LED_BUILTIN
SDA – Digital 23
SCL – Digital 22
SW1 – Digital 21
XAC – Analog A0
YAC – Analog A1
ZAC – Analog A2
VIN – +3.3V
GND – GND

——

DL2401Mk04p.ino

/****** Don Luc Electronics © ******
Software Version Information
Project #28 - Sensors - MMA7361 - Mk14
28-14
DL2401Mk04p.ino
1 x SparkFun Thing Plus - ESP32 WROOM
1 x DS3231 Precision RTC FeatherWing
1 x SparkFun Triple Axis Accelerometer Breakout - MMA7361
1 x Rocker Switch - SPST
1 x Resistor 10K Ohm
1 x Lithium Ion Battery - 1000mAh
1 x CR1220 3V Lithium Coin Cell Battery
1 x Terminal Block Breakout FeatherWing
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// Bluetooth LE keyboard
#include <BleKeyboard.h>
// Two Wire Interface (TWI/I2C)
#include <Wire.h>
// Serial Peripheral Interface
#include <SPI.h>
// DS3231 Precision RTC 
#include <RTClib.h>

// Bluetooth LE Keyboard
BleKeyboard bleKeyboard;
String sKeyboard = "";
// Send Size
byte sendSize = 0;

// DS3231 Precision RTC 
RTC_DS3231 rtc;
String dateRTC = "";
String timeRTC = "";

// Accelerometer MMA7361
int XAc = A0;
int YAc = A1;
int ZAc = A2;
// Read
int x = 0;
int y = 0; 
int z = 0;

// The number of the Rocker Switch pin
int iSwitch = 21;
// Variable for reading the button status
int SwitchState = 0;

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

void loop() {

  // Date and Time RTC
  isRTC ();

  // Accelerometer MMA7361
  isMMA7361();

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

  // Check if the button is pressed. If it is, the SwitchState is HIGH:
  if (SwitchState == HIGH) {

    // Bluetooth LE Keyboard
    isBluetooth();

  }

  // Delay 1 Second
  delay(1000);

}

getAccelerometer.ino

// Accelerometer MMA7361
// isMMA7361
void isMMA7361(){

  // Accelerometer Read
  x = analogRead(XAc); 
  y = analogRead(YAc);
  z = analogRead(ZAc);

  sKeyboard = sKeyboard + String(x) + "|" + String(y) + "|" + String(z) + "|*";
  
}

getBleKeyboard.ino

// Ble Keyboard
// Bluetooth
// isBluetooth
void isBluetooth() {

  // ESP32 BLE Keyboard
  if(bleKeyboard.isConnected()) {

    // Send Size Length
    sendSize = sKeyboard.length();

    // Send Size, charAt
    for(byte i = 0; i < sendSize+1; i++){

       // Write
       bleKeyboard.write(sKeyboard.charAt(i));
       delay(50);
    
    }
    bleKeyboard.write(KEY_RETURN);

  }

}

getRTC.ino

// Date & Time
// DS3231 Precision RTC
void isSetupRTC() {

  // DS3231 Precision RTC
  if (! rtc.begin()) {
    //Serial.println("Couldn't find RTC");
    //Serial.flush();
    while (1) delay(10);
  }

  if (rtc.lostPower()) {
    //Serial.println("RTC lost power, let's set the time!");
    // 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(2023, 8, 10, 11, 0, 0));
  }
  
}
// Date and Time RTC
void isRTC () {

  // Date and Time
  dateRTC = "";
  timeRTC = "";
  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;

  // bleKeyboard
  sKeyboard = "SEN|" + sver + "|" + String(dateRTC) 
  + "|" + String(timeRTC) + "|";

}

setup.ino

// Setup
void setup()
{
  
  // Give display time to power on
  delay(100);

  // Bluetooth LE keyboard
  bleKeyboard.begin();
  
  // Wire - Inialize I2C Hardware
  Wire.begin();

  // Give display time to power on
  delay(100);

  // Date & Time RTC
  // DS3231 Precision RTC 
  isSetupRTC();

  // Give display time to power on
  delay(100);
  
  // Initialize the Switch pin as an input
  pinMode(iSwitch, INPUT);

  // Initialize digital pin LED_BUILTIN as an output
  pinMode(LED_BUILTIN, OUTPUT);
  // Turn the LED on HIGH
  digitalWrite(LED_BUILTIN, HIGH);

  // Delay 5 Second
  delay( 5000 );

}

——

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

Teacher, Instructor, E-Mentor, 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
  • 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/

Don Luc

Project #28 – Sensors – PIR Motion Sensor – Mk13

——

#DonLucElectronics #DonLuc #Sensors #PIR #Adafruit #SparkFun #Pololu #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

PIR Motion Sensor

——

PIR Motion Sensor

——

PIR Motion Sensor

——

PIR Motion Sensor (JST)

This is a simple to use motion sensor. Power it up and wait 1-2 seconds for the sensor to get a snapshot of the still room. If anything moves after that period, the “Alarm” pin will go low. This unit works great from 5 to 12 Volt. The alarm pin is an open collector meaning you will need a pull up resistor on the alarm pin. The open drain setup allows multiple motion sensors to be connected on a single input pin. If any of the motion sensors go off, the input pin will be pulled low.

At their most fundamental level, PIR sensor’s are infrared-sensitive light detectors. By monitoring light in the infrared spectrum, PIR sensors can sense subtle changes in temperature across the area they’re viewing. When a human or some other object comes into the PIR’s field-of-view, the radiation pattern changes, and the PIR interprets that change as movement. All that’s left for us to connect is three pins: power, ground, and the output signal.

DL2401Mk02

1 x SparkFun Thing Plus – ESP32 WROOM
1 x DS3231 Precision RTC FeatherWing
1 x PIR Motion Sensor
1 x Pololu 5V Step-Up Voltage Regulator U1V10F5
1 x Rocker Switch – SPST
1 x Resistor 10K Ohm
1 x CR1220 3V Lithium Coin Cell Battery
1 x 1 x Lithium Ion Battery – 1000mAh
1 x Terminal Block Breakout FeatherWing
1 x SparkFun Cerberus USB Cable

SparkFun Thing Plus – ESP32 WROOM

LED – LED_BUILTIN
SDA – Digital 23
SCL – Digital 22
SW1 – Digital 21
PIR – Digital 14
VIN – +3.3V
VIN – +5V
GND – GND

——

DL2401Mk01p.ino

/****** Don Luc Electronics © ******
Software Version Information
Project #28 - Sensors - PIR Motion Sensor - Mk13
28-13
DL2401Mk01p.ino
1 x SparkFun Thing Plus - ESP32 WROOM
1 x DS3231 Precision RTC FeatherWing
1 x PIR Motion Sensor
1 x Pololu 5V Step-Up Voltage Regulator U1V10F5
1 x Rocker Switch - SPST
1 x Resistor 10K Ohm
1 x Lithium Ion Battery - 1000mAh
1 x CR1220 3V Lithium Coin Cell Battery
1 x Terminal Block Breakout FeatherWing
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// Bluetooth LE keyboard
#include <BleKeyboard.h>
// Two Wire Interface (TWI/I2C)
#include <Wire.h>
// Serial Peripheral Interface
#include <SPI.h>
// DS3231 Precision RTC 
#include <RTClib.h>

// Bluetooth LE Keyboard
BleKeyboard bleKeyboard;
String sKeyboard = "";
// Send Size
byte sendSize = 0;

// DS3231 Precision RTC 
RTC_DS3231 rtc;
String dateRTC = "";
String timeRTC = "";

// PIR Motion
// Motion detector
const int iMotion = 14;
// Proximity
int proximity = LOW;
String Det = "";

// The number of the Rocker Switch pin
int iSwitch = 21;
// Variable for reading the button status
int SwitchState = 0;

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

void loop() {

  // Date and Time RTC
  isRTC ();

  // isPIR Motion
  isPIR();

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

  // Check if the button is pressed. If it is, the SwitchState is HIGH:
  if (SwitchState == HIGH) {

    // Bluetooth LE Keyboard
    isBluetooth();

  }

  // Delay 1 Second
  delay(1000);

}

getBleKeyboard.ino

// Ble Keyboard
// Bluetooth
// isBluetooth
void isBluetooth() {

  // ESP32 BLE Keyboard
  if(bleKeyboard.isConnected()) {

    // Send Size Length
    sendSize = sKeyboard.length();

    // Send Size, charAt
    for(byte i = 0; i < sendSize+1; i++){

       // Write
       bleKeyboard.write(sKeyboard.charAt(i));
       delay(50);
    
    }
    bleKeyboard.write(KEY_RETURN);

  }

}

getPIR.ino

// PIR Motion
// Setup PIR
void setupPIR() {

  // Setup PIR Montion
  pinMode(iMotion, INPUT_PULLUP);
  
}
// isPIR Motion
void isPIR() {

  // Proximity
  proximity = digitalRead(iMotion);
  if (proximity == LOW) 
  {

    // PIR Motion Sensor's LOW, Motion is detected
    Det = "Motion Yes";

  }
  else
  {

    // PIR Motion Sensor's HIGH
    Det = "No";
    
  }

  sKeyboard = sKeyboard + String(Det) + "|*";
  
}

getRTC.ino

// Date & Time
// DS3231 Precision RTC
void isSetupRTC() {

  // DS3231 Precision RTC
  if (! rtc.begin()) {
    //Serial.println("Couldn't find RTC");
    //Serial.flush();
    while (1) delay(10);
  }

  if (rtc.lostPower()) {
    //Serial.println("RTC lost power, let's set the time!");
    // 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(2023, 8, 10, 11, 0, 0));
  }
  
}
// Date and Time RTC
void isRTC () {

  // Date and Time
  dateRTC = "";
  timeRTC = "";
  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;

  // bleKeyboard
  sKeyboard = "SEN|" + sver + "|" + String(dateRTC) 
  + "|" + String(timeRTC) + "|";

}

setup.ino

// Setup
void setup()
{
  
  // Give display time to power on
  delay(100);

  // Bluetooth LE keyboard
  bleKeyboard.begin();
  
  // Wire - Inialize I2C Hardware
  Wire.begin();

  // Give display time to power on
  delay(100);

  // Date & Time RTC
  // DS3231 Precision RTC 
  isSetupRTC();

  // Give display time to power on
  delay(100);
  
  // PIR Motion
  // Setup PIR
  setupPIR();
  
  // Initialize the Switch pin as an input
  pinMode(iSwitch, INPUT);

  // Initialize digital pin LED_BUILTIN as an output
  pinMode(LED_BUILTIN, OUTPUT);
  // Turn the LED on HIGH
  digitalWrite(LED_BUILTIN, HIGH);

  // Delay 5 Second
  delay( 5000 );

}

——

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

Teacher, Instructor, E-Mentor, 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
  • 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/

Don Luc

Project #05: Lamps – NeoPixels – Mk02

——

#DonLucElectronics #DonLuc #Lamps #NeoPixels #Keyboard #Adafruit #SparkFun #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

NeoPixels

——

NeoPixels

——

NeoPixels

——

NeoPixels

——

NeoPixels

The WS2812 Integrated Light Source, or NeoPixel in Adafruit parlance, is the latest advance in the quest for a simple, scalable and affordable full-color LED. Red, green and blue LEDs are integrated alongside a driver chip into a tiny surface-mount package controlled through a single wire. They can be used individually, chained into longer strings or assembled into still more interesting form-factors.

NeoPixels don’t just light up on their own; they require a microcontroller, such as Arduino, and some programming. We provide some sample code to get you started. To create your own effects and animation, you’ll need some programming practice. If this is a new experience, work through some of the beginning Arduino tutorials to get a feel for the language.

NeoPixel Stick – 8 x 5050 RGB LED

Make your own little LED strip arrangement with this stick of NeoPixel LEDs. We crammed 8 of the tiny 5050 smart RGB LEDs onto a PCB with mounting holes and a chainable design. Use only one microcontroller pin to control as many as you can chain together. Each LED is addressable as the driver chip is inside the LED. Each one has constant current drive so the color will be very consistent even if the voltage varies, and no external choke resistors are required making the design slim. Power the whole thing with 5VDC and you’re ready to rock. The LEDs are “Chainable” by connecting the output of one stick into the input of another. There is a single data line with a very timing-specific protocol.

DL2401Mk01

1 x Arduino Pro Mini 328 – 3.3V/8MHz
2 x NeoPixel Stick – 8 x 5050 RGB LED
2 x Rotary Potentiometer – 10k Ohm
1 x Potentiometer Knob – Soft Touch T18 – Blue
1 x Potentiometer Knob – Soft Touch T18 – Red
1 x Mountable Slide Switch
1 x SparkFun USB Mini-B Breakout
1 x Enclosure
1 x SparkFun Cerberus USB Cable

Arduino Pro Mini 328 – 3.3V/8MHz

NPX – Digital 8
BRI – Analog A0
COL – Analog A3
VIN – +3.3V
VIN – +5V
GND – GND

——

DL2401Mk01p.ino

/****** Don Luc Electronics © ******
Software Version Information
Project #05: Lamps - NeoPixels - Mk02
05-02
DL2401Mk01p.ino
1 x Arduino Pro Mini 328 - 3.3V/8MHz
2 x NeoPixel Stick - 8 x 5050 RGB LED
2 x Rotary Potentiometer - 10k Ohm
1 x Potentiometer Knob - Soft Touch T18 - Blue
1 x Potentiometer Knob - Soft Touch T18 - Red
1 x Mountable Slide Switch
1 x SparkFun USB Mini-B Breakout
1 x Enclosure
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// NeoPixel
#include <Adafruit_NeoPixel.h>

// NeoPixels
#define PIN 8
// How many NeoPixels are attached to the Arduino => 16
#define NUMPIXELS 16
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

// Color
// Red
int red = 0;
// Green
int green = 0;
// Blue
int blue = 0;

// 2 x Panel Mount 1K potentiometer
// Brighten
const int iSensorBrighten = A0;
int BrightenValue = 0;
int sensorMin = 1023;        // minimum sensor value
int sensorMax = 0;           // maximum sensor value

// Color
const int iSensorColor = A3;
int y = 0;
int ColorVal = 0;

// Software Version Information
String sver = "05-02";

void loop() {

  // Color
  isRangeColor();

  // Brighten
  isNeopix();

}

getNeopix.ino

// Neopix
void isNeopix() {
  
  for(int i=0; i<NUMPIXELS; i++){

    // Neopix
    BrightenValue = analogRead( iSensorBrighten );

    // Apply the calibration to the sensor reading
    BrightenValue = map(BrightenValue, sensorMin, sensorMax, 0, 255);

    // In case the sensor value is outside the range seen during calibration
    BrightenValue = constrain(BrightenValue, 0, 255); 
    
    pixels.setBrightness( BrightenValue );

    // The pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor(i, pixels.Color(red,green,blue));
    
    // This sends the updated pixel color to the hardware
    pixels.show();
 
  }
  
}
// Range Color
void isRangeColor() {

  // Range Color
  ColorVal = analogRead( iSensorColor );
  y = (ColorVal / 127);
  
  switch ( y ) {
    case  0:
      // White
      red = 255;
      green = 255;
      blue = 255; 
      break;
    case 1:
      // Yellow
      red = 255;
      green = 255;
      blue = 0;        
      isNeopix();
      break;
    case 2:
      // Pink
      red = 255;
      green = 153;
      blue = 203;        
      isNeopix();
      break;
    case 3:
      // Blue
      red = 0;
      green = 102;
      blue = 204;        
      isNeopix();       
      isNeopix();
      break;  
    case 4:
      // Green
      red = 0;
      green = 255;
      blue = 0;        
      isNeopix();
      break;
    case 5:
      // Orange
      red = 255;
      green = 102;
      blue = 0;        
      isNeopix();
      break;
    case 6:
      // Violet
      red = 204;
      green = 102;
      blue = 204;        
      isNeopix();
      break;     
    case 7:
      // Red
      red = 255;
      green = 0;
      blue = 0;        
      isNeopix();
      break; 
  }
  
}

setup.ino

// Setup
void setup()
{

  // This initializes the NeoPixel library
  pixels.begin();
  delay(50);

}

——

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

Teacher, Instructor, E-Mentor, 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
  • 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/

Don Luc

Project #16: Sound – Microphone and SD Card – Mk24

——

#DonLucElectronics #DonLuc #Sound #Mic #SD #Adafruit #SparkFun #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

Microphone and SD Card

——

Microphone and SD Card

——

Microphone and SD Card

——

SparkFun Electret Microphone

This small breakout board couples an Electret microphone (100Hz–10kHz) with a 60x mic preamplifier to amplify the sounds of voice, claps, door knocks or any sounds loud enough to be picked up by a microcontroller’s analog-to-digital converter. Each breakout comes fully assembled and works from 2.7 Volt up to 5.5 Volt.

The Electret Mic Breakout translates amplitude, not volume, by capturing sound waves between two conducting plates in the microphone and converting them into electrical waves. These electrical signals are then amplified and picked up by your microcontroller’s ADC.

DL2310Mk02

1 x SparkFun RedBoard Qwiic
1 x SparkFun Electret Microphone Breakout
1 x MicroSD card breakout board+
1 x SD Card 8 GB
1 x LED Green
2 x Buttom
2 x Resistor 10K Ohm
1 x ProtoScrewShield
1 x SparkFun Cerberus USB Cable

SparkFun RedBoard Qwiic

CLK – Digital 13
DO – Digital 12
DI – Digital 11
CS – Digital 10
LED – Digital 6
BSA – Digital 2
BUO – Digital 3
VIN – +3.3V
VIN – +5V
GND – GND

——

DL2310Mk02p.ino

/****** Don Luc Electronics © ******
Software Version Information
Project #16: Sound - Microphone and SD Card - Mk24
16-24
DL2310Mk02p.ino
1 x SparkFun RedBoard Qwiic
1 x SparkFun Electret Microphone Breakout
1 x MicroSD card breakout board+
1 x SD Card 8 GB
1 x LED Green
2 x Buttom
2 x Resistor 10K Ohm
1 x ProtoScrewShield
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// SD Library and SD Card
#include <SD.h>
// SPI Devices
#include <SPI.h>
// TMRpcm  playback/recording of PCM/WAV files direct from SD card
#include <pcmConfig.h>
#include <pcmRF.h>
#include <TMRpcm.h>

// SD Library and SD Card
#define SD_ChipSelectPin 10

// TMRpcm  playback/recording of PCM/WAV files direct from SD card
TMRpcm audio;
int audiofile = 0;

// Uno
#define buffSize 128
#define ENABLE_RECORDING
#define BLOCK_COUNT 10000UL

// SparkFun Electret Microphone
int iAUD = A0;

// LED Green
int iLEDG = 6;

// Buttom
// Start Recording
int iStartRecording = 2;
int iStartState = 0;
// Stop Recording
int iStopRecording = 3;
int iStopState = 0;

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

void loop() {

  // Buttom
  // Start Recording
  isStartRecording();

  // Buttom
  // Stop Recording
  isStopRecording();
  
}

getAudio.ino

// TMRpcm playback/recording of PCM/WAV files direct from SD card
// Start Recording
void isStartRecording() {

  // Read the state of the Switch value:
  iStartState = digitalRead(iStartRecording);

  // Check if the button is pressed. If it is, the SwitchState is HIGH:
  if (iStartState == HIGH) {

    // Led Green HIGH
    digitalWrite(iLEDG, HIGH);

    // Audio File
    audiofile++;

    switch (audiofile) {
      case 1: audio.startRecording("File01.wav", 16000, iAUD); break;
      case 2: audio.startRecording("File02.wav", 16000, iAUD); break;
      case 3: audio.startRecording("File03.wav", 16000, iAUD); break;
      case 4: audio.startRecording("File04.wav", 16000, iAUD); break;
      case 5: audio.startRecording("File05.wav", 16000, iAUD); break;
      case 6: audio.startRecording("File06.wav", 16000, iAUD); break;
      case 7: audio.startRecording("File07.wav", 16000, iAUD); break;
      case 8: audio.startRecording("File08.wav", 16000, iAUD); break;
      case 9: audio.startRecording("File09.wav", 16000, iAUD); break;
      case 10: audio.startRecording("File10.wav", 16000, iAUD); break;
    }

  }
  
}
// Stop Recording
void isStopRecording(){

  // Read the state of the Switch value:
  iStopState = digitalRead(iStopRecording);

  // Check if the button is pressed. If it is, the SwitchState is HIGH:
  if (iStopState == HIGH) {

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

    // Audio File
    switch (audiofile) {
      case 1: audio.stopRecording("File01.wav"); break;
      case 2: audio.stopRecording("File02.wav"); break;
      case 3: audio.stopRecording("File03.wav"); break;
      case 4: audio.stopRecording("File04.wav"); break;
      case 5: audio.stopRecording("File05.wav"); break;
      case 6: audio.stopRecording("File06.wav"); break;
      case 7: audio.stopRecording("File07.wav"); break;
      case 8: audio.stopRecording("File08.wav"); break;
      case 9: audio.stopRecording("File09.wav"); break;
      case 10: audio.stopRecording("File10.wav"); break;
    }  

  }

}

setup.ino

// Setup
void setup() {

  // SparkFun Electret Microphone
  pinMode(iAUD, INPUT);

  // LED Green
  pinMode(iLEDG, OUTPUT);
  
  // Buttom
  // Start Recording
  pinMode(iStartRecording, INPUT);
  // Stop Recording
  pinMode(iStopRecording, INPUT);

  // TMRpcm playback/recording of PCM/WAV files direct from SD card
  SD.begin(SD_ChipSelectPin);
  audio.CSPin = SD_ChipSelectPin;

}

——

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

Teacher, Instructor, E-Mentor, 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
  • eHealth Sensors, Biosensor, and Biometric
  • Research & Development (R & D)
  • Consulting

Follow Us

Luc Paquin – Curriculum Vitae – 2023
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/

Don Luc

1 2 3 32
Categories
Archives