The Alpha Geek – Geeking Out

Adafruit

Project #15: Environment – SparkFun Rotary Switch – 10 Position – Mk05

——

#DonLuc #Environment #Microcontrollers #ESP32 #Adalogger #GPS #RotarySwitch #SparkFun #Fritzing #Programming #Adafruit #Arduino #Electronics #Consultant #Vlog #Aphasia

——

Environment

——

Environment

——

Environment

——

DL2004Mk13

1 x SparkFun Thing Plus – ESP32 WROOM
1 x Adafruit SHARP Memory Display
1 x SparkFun Environmental Combo Breakout – CCS811/BME280
1 x Adafruit Adalogger FeatherWing – RTC + SD
1 x SparkFun GPS Receiver – GP-20U7
1 x CR1220 12mm Lithium Battery
1 x 32Gb microSD Card
1 x Mountable Slide Switch
1 x SparkFun Rotary Switch – 10 Position
1 x Black Knob
1 x Breadboard Solderable
1 x Qwiic Cable – 100mm
1 x LED Green
11 x 1K Ohm
1 x 10K Ohm
2 x Jumper Wires 3in M/M
5 x Jumper Wires 6in M/M
16 x Wire Solid Core – 22 AWG
1 x Full-Size Breadboard
1 x SparkFun Cerberus USB Cable

SparkFun Thing Plus – ESP32 WROOM

LEG – Digital 21
SCK – Digital 13
MOS – Digital 12
SSD – Digital 27
SDA – Digital 23
SCL – Digital 22
SD1 – Digital 33
SC2 – Digital 5
MO2 – Digital 18
MI2 – Digital 19
SS1 – Digital 16
ROT – Digital A1
GPS – Digital 4
VIN – +3.3V
GND – GND

DL2004Mk13p.ino

// ***** Don Luc Electronics © *****
// Software Version Information
// Project #15: Environment - SparkFun Rotary Switch - 10 Position - Mk05
// 04-13
// DL2004Mk13p.ino 15-05
// EEPROM with Unique ID
// 1 x SparkFun Thing Plus - ESP32 WROOM
// 1 x Adafruit SHARP Memory Display
// 1 x SparkFun Environmental Combo Breakout - CCS811/BME280
// 1 x Adafruit Adalogger FeatherWing - RTC + SD
// 1 x SparkFun GPS Receiver - GP-20U7
// 1 x CR1220 12mm Lithium Battery
// 1 x 32Gb microSD Card
// 1 x Mountable Slide Switch
// 1 x SparkFun Rotary Switch - 10 Position
// 1 x Black Knob
// 1 x Breadboard Solderable
// 1 x Qwiic Cable - 100mm
// 1 x LED Green
// 11 x 1K Ohm
// 1 x 10K Ohm
// 2 x Jumper Wires 3in M/M
// 5 x Jumper Wires 6in M/M
// 16 x Wire Solid Core - 22 AWG
// 1 x Full-Size Breadboard
// 1 x SparkFun Cerberus USB Cable

// Include the Library Code
// EEPROM Library to Read and Write EEPROM with Unique ID for Unit
#include "EEPROM.h"
// Wire
#include <Wire.h>
// SHARP Memory Display
#include <Adafruit_SharpMem.h>
#include <Adafruit_GFX.h>
// SparkFun CCS811 - eCO2 & tVOC
#include <SparkFunCCS811.h>
// SparkFun BME280 - Humidity, Temperature, Altitude and Barometric Pressure
#include <SparkFunBME280.h>
// Date and Time
#include "RTClib.h"
// SD Card
#include "FS.h"
#include "SD.h"
#include "SPI.h"
// GPS Receiver
#include <TinyGPS++.h>
// Hardware Serial
#include <HardwareSerial.h>

// LED Green
int iLEDGreen = 21;

// SHARP Memory Display
// any pins can be used
#define SHARP_SCK  13
#define SHARP_MOSI 12
#define SHARP_SS   27
// Set the size of the display here - 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
// 1/2 of lesser of display width or height
int minorHalfSize; 

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

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

// Date and Time
// PCF8523 Precision RTC 
RTC_PCF8523 rtc;
String dateRTC = "";
String timeRTC = "";

// microSD Card
const int chipSelect = 33;
String zzzzzz = "";

// Mountable Slide Switch
int iSS1 = 16;
// State
int iSS1State = 0;

// ESP32 HardwareSerial
HardwareSerial tGPS(2);

// GPS Receiver
#define gpsRXPIN 4
// This one is unused and doesnt have a conection
#define gpsTXPIN 36
// The TinyGPS++ object
TinyGPSPlus gps;
float TargetLat;
float TargetLon;
int GPSStatus = 0;

// Rotary Switch - 10 Position
// Number 1 => 10
int iRotNum = A1;
// iRotVal - Value 
int iRotVal = 0;
// Number
int z = 0;

// Software Version Information
String sver = "15-05";
// EEPROM Unique ID Information
#define EEPROM_SIZE 64
String uid = "";

void loop() {

  // Receives NEMA data from GPS receiver
  isGPS();
  
  // Date and Time 
  isRTC();
  
  // SparkFun BME280 - Humidity, Temperature, Altitude and Barometric Pressure
  isBME280();

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

  // Rotary Switch
  isRot();

  // Slide Switch
  // Read the state of the iSS1 value
  iSS1State = digitalRead(iSS1);
  
  // If it is the Slide Switch State is HIGH
  if (iSS1State == HIGH) {

    // iLEDGreen
    digitalWrite(iLEDGreen,  HIGH );
    
    // microSD Card
    isSD();

  } else {

    // iLEDGreen
    digitalWrite(iLEDGreen,  LOW );
  
  }

  delay( 1000 );
  
}

getBME280.ino

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

  // Temperature Celsius
  BMEtempC = myBME280.readTempC();
  // Humidity
  BMEhumid = myBME280.readFloatHumidity();
  // Altitude Meters
  BMEaltitudeM = (myBME280.readFloatAltitudeMeters(), 2);
  // 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

// 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,100);   
    display.println( sver );
    // EEPROM Unique ID
    display.setTextSize(1);
    display.setCursor(0,130);
    display.println( "EEPROM Unique ID" );
    display.setTextSize(2);
    display.setCursor(0,145);
    display.println( uid );
    // Refresh
    display.refresh();
    delay( 100 );
    
}
// Display Environmental
void isDisplayEnvironmental(){

    // Text Display Environmental
    // Clear Display
    display.clearDisplay();
    display.setRotation(4);
    display.setTextSize(1);
    display.setTextColor(BLACK);
    // Temperature Celsius
    display.setCursor(0,0);
    display.println( "Temperature Celsius" );
    display.setCursor(0,10);
    display.print( BMEtempC );
    display.println( " C" );
    // Humidity
    display.setCursor(0,20);
    display.println( "Humidity" );
    display.setCursor(0,30);
    display.print( BMEhumid );
    display.println( "%" );
    // Altitude Meters
    display.setCursor(0,40);
    display.println( "Altitude Meters" );
    display.setCursor(0,50);
    display.print( BMEaltitudeM );
    display.println( " m" );
    // Pressure
    display.setCursor(0,60);    
    display.println( "Barometric Pressure" );
    display.setCursor(0,70);
    display.print( BMEpressure );
    display.println( " Pa" );
    // eCO2 Concentration
    display.setCursor(0,80);
    display.println( "eCO2 Concentration" );
    display.setCursor(0,90);
    display.print( CCS811CO2 );
    display.println( " ppm" );
    // tVOC Concentration
    display.setCursor(0,100);
    display.println( "tVOC Concentration" );
    display.setCursor(0,110);
    display.print( CCS811TVOC );
    display.println( " ppb" );
    // Date
    display.setCursor(0,120);
    display.println( dateRTC );
    // Time
    display.setCursor(0,130);
    display.println( timeRTC );
    // GPS Status
    display.setCursor(0,140);
    display.println( GPSStatus );
    // Target Latitude
    display.setCursor(0,150);
    display.println( TargetLat );
    // Target Longitude
    display.setCursor(0,160);
    display.println( TargetLon );
    // Refresh
    display.refresh();
    delay( 100 );

}
// Display Date
void isDisplayDate() {

    // Text Display Date
    // Clear Display
    display.clearDisplay();
    display.setRotation(4);
    display.setTextSize(2);
    display.setTextColor(BLACK);
    // Date
    display.setCursor(0,5);
    display.println( dateRTC );
    // Time
    display.setCursor(0,30);
    display.println( timeRTC );
    // GPS Status
    display.setCursor(0,60);
    display.print( "GPS: " );
    display.println( GPSStatus );
    // Target Latitude
    display.setCursor(0,80);
    display.println( "Latitude" );
    display.setCursor(0,100);
    display.println( TargetLat );
    // Target Longitude
    display.setCursor(0,120);
    display.println( "Longitude" );
    display.setCursor(0,140);
    display.println( TargetLon );
    // Refresh
    display.refresh();
    delay( 100 );

}
// Display BME280
void isDisplayBME280() {

     // Text Display BME280
    // Clear Display
    display.clearDisplay();
    display.setRotation(4);
    display.setTextSize(2);
    display.setTextColor(BLACK);
    // Temperature Celsius
    display.setCursor(0,10);
    display.println( "Temperature" );
    display.setCursor(0,30);
    display.print( BMEtempC );
    display.println( " C" );
    // Humidity
    display.setCursor(0,50);
    display.println( "Humidity" );
    display.setCursor(0,70);
    display.print( BMEhumid );
    display.println( "%" );
    // Altitude Meters
    display.setCursor(0,90);
    display.println( "Altitude M" );
    display.setCursor(0,110);
    display.print( BMEaltitudeM );
    display.println( " m" );
    // Pressure
    display.setCursor(0,130);    
    display.println( "Barometric" );
    display.setCursor(0,150);
    display.print( BMEpressure );
    display.println( "Pa" );
    // Refresh
    display.refresh();
    delay( 100 );

}
// Display CCS811 - eCO2 & tVOC
void isDisplayCCS811() {

    // Text Display CCS811
    // Clear Display
    display.clearDisplay();
    display.setRotation(4);
    display.setTextSize(2);
    display.setTextColor(BLACK);
    // eCO2 Concentration
    display.setCursor(0,10);
    display.println( "eCO2" );
    display.setCursor(0,30);
    display.print( CCS811CO2 );
    display.println( " ppm" );
    // tVOC Concentration
    display.setCursor(0,60);
    display.println( "tVOC" );
    display.setCursor(0,80);
    display.print( CCS811TVOC );
    display.println( " ppb" );
    // Refresh
    display.refresh();
    delay( 100 );

}
// Display Z
void isDisplayZ() {

    // Text Display Z
    // Clear Display
    display.clearDisplay();
    display.setRotation(4);
    display.setTextSize(3);
    display.setTextColor(BLACK);
    // Z
    display.setCursor(0,10);
    display.print( "Z: " );
    display.println( z );
    // Refresh
    display.refresh();
    delay( 100 );

}

getEEPROM.ino

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

getGPS.ino

// GPS Receiver
// Setup GPS
void setupGPS() {

  // 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() ))
    {
     displayInfo();
    }
  
  if (millis() > 5000 && gps.charsProcessed() < 10)
  {
    while(true);
  }

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

  // Location
  if (gps.location.isValid())
  {
    
    TargetLat = gps.location.lat();
    TargetLon = gps.location.lng();
    GPSStatus = 2;
    
  }
  else
  {

    GPSStatus = 0;
    
  }

}

getRTC.ino

// Date & Time
// PCF8523 Precision RTC 
void setupRTC() {

  // Date & Time
  // pcf8523 Precision RTC   
  if (! rtc.begin()) {
    while (1);
  }  
  
  if (! rtc.initialized()) {
    // 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(2018, 9, 29, 12, 17, 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;
  
}

getRot.ino

// Rotary Switch
// isRot - iRotVal - Value
void isRot() {

  // Rotary Switch
  z = analogRead( iRotNum );
  
  // Rotary Switch - 10 Position
  // Number 1 => 10
  if ( z >= 3600 ) {

    // Z
    iRotVal = 10;
    
  } else if ( z >= 3200 ) {

    // Z
    iRotVal = 9;
    
  } else if ( z >= 2700 ) {

    // Z
    iRotVal = 8;
    
  } else if ( z >= 2400 ) {

    // Z
    iRotVal = 7;
    
  } else if ( z >= 2000 ) {

    // Z
    iRotVal = 6;
    
  } else if ( z >= 1600 ) {

    // Z
    iRotVal = 5;
    
  } else if ( z >= 1200 ) {

    // Z
    iRotVal = 4;
    
  } else if ( z >= 900 ) {

    // Z
    iRotVal = 3;
    
  } else if ( z >= 500 ) {

    // Z
    iRotVal = 2;
    
  } else {

    // Z
    iRotVal = 1;
    
  }

  // Range Value
  switch ( iRotVal ) {
    case 1:

      // Display Environmental
      isDisplayEnvironmental();
      
      break;
    case 2:

      // Display Date
      isDisplayDate();
      
      break;
    case 3:

      // Display BME280
      isDisplayBME280();
      
      break;  
    case 4:

      // Display CCS811 - eCO2 & tVOC
      isDisplayCCS811();
      
      break;
    case 5:

      // Display UID
      isDisplayUID();
      
      break;
    case 6:

      // Z
      isDisplayZ();
      
      break;       
    case 7:

      // Z
      isDisplayZ();
      
      break; 
    case 8:
         
      // Z
      isDisplayZ();
      
      break; 
    case 9:

      // Z
      isDisplayZ();
      
      break;
    case 10:

      // Z
      isDisplayZ();
      
      break;
  }

}

getSD.ino

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

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

    if(cardType == CARD_NONE){
        ; 
        return;
    }

    //Serial.print("SD Card Type: ");
    if(cardType == CARD_MMC){
        ; 
    } else if(cardType == CARD_SD){
        ; 
    } else if(cardType == CARD_SDHC){
        ; 
    } else {
        ; 
    } 

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

  zzzzzz = "";

  // EEPROM Unique ID|Version|Date|Time|GPS Status|Target Latitude|Target Longitude|Temperature Celsius|Humidity|Altitude Meters|Barometric Pressure|eCO2 Concentration|tVOC Concentration
  zzzzzz = uid + "|" + sver + "|" + dateRTC + "|" + timeRTC + "|" + GPSStatus + "|" + TargetLat + "|" + TargetLon + "|" + BMEtempC + "|" + BMEhumid + "|" + BMEaltitudeM + "|" + BMEpressure + "|" + CCS811CO2 + "|" + CCS811TVOC + "|\r";

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

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

  appendFile(SD, "/espdata.txt", msg );
  
}
// List Dir
void listDir(fs::FS &fs, const char * dirname, uint8_t levels){
    
    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){
    
    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){
    
    path;
    
    File file = fs.open(path, FILE_APPEND);
    
    if(!file){
        return;
    }
    
    if(file.print(message)){
        ;  
    } else {
        ;  
    }
    
    file.close();
    
}

setup.ino

// Setup
void setup() {

  // EEPROM Size
  EEPROM.begin(EEPROM_SIZE);
  
  // EEPROM Unique ID
  isUID();
  
  // GPS Receiver
  // Setup GPS
  setupGPS();
  
  // SHARP Display Start & Clear the Display
  display.begin();
  // Clear Display
  display.clearDisplay();
  
  // Display UID
  isDisplayUID();

  // Wire - Inialize I2C Hardware
  Wire.begin();

  // SparkFun BME280 - Humidity, Temperature, Altitude and Barometric Pressure
  myBME280.begin();
  
  // CCS811 - eCO2 & tVOC
  myCCS811.begin();

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

  // Date & Time RTC
  // PCF8523 Precision RTC 
  setupRTC();
  
  // Date & Time
  isRTC();
  
  // microSD Card
  setupSD();

  // Slide Switch
  pinMode(iSS1, INPUT);

  delay( 5000 );

}

Technology Experience

  • Research & Development (R & D)
  • Desktop Applications (Windows, OSX, Linux, Multi-OS, Multi-Tier, etc…)
  • Mobile Applications (Android, iOS, Blackberry, Windows Mobile, Windows CE, etc…)
  • Web Applications (LAMP, Scripting, Java, ASP, ASP.NET, RoR, Wakanda, etc…)
  • Social Media Programming & Integration (Facebook, Twitter, YouTube, Pinterest, etc…)
  • Content Management Systems (WordPress, Drupal, Joomla, Moodle, etc…)
  • Bulletin Boards (phpBB, SMF, Vanilla, jobberBase, etc…)
  • eCommerce (WooCommerce, OSCommerce, ZenCart, PayPal Shopping Cart, etc…)

Instructor

  • DOS, Windows, OSX, Linux, iOS, Android, Multi-OS
  • Linux-Apache-PHP-MySQL
  • Robotics
  • Arduino
  • Raspberry Pi
  • Espressif

Follow Us

The Alpha Geek

Why “The Alpha Geek”?

Aphasia
https://www.donluc.com/?page_id=2149

J. Luc Paquin – Curriculum Vitae
https://www.donluc.com/DLHackster/LucPaquinCVEngMk2020a.pdf

Web: https://www.donluc.com/
Web: http://www.jlpconsultants.com/
Web: https://www.donluc.com/DLHackster/
Web: https://www.hackster.io/neosteam-labs
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/

Don Luc

Project #15: Environment – SparkFun GPS Receiver – GP-20U7 – Mk04

——

#DonLuc #Environment #Microcontrollers #ESP32 #Adalogger #GPS #SparkFun #Fritzing #Programming #Adafruit #Arduino #Electronics #Consultant #Vlog #Aphasia

——

Environment

——

Environment

——

Environment

——

DL2004Mk11

1 x SparkFun Thing Plus – ESP32 WROOM
1 x Adafruit SHARP Memory Display
1 x SparkFun Environmental Combo Breakout – CCS811/BME280
1 x Adafruit Adalogger FeatherWing – RTC + SD
1 x SparkFun GPS Receiver – GP-20U7
1 x CR1220 12mm Lithium Battery
1 x 32Gb microSD Card
1 x Mountable Slide Switch
1 x Qwiic Cable – 100mm
1 x LED Green
1 x 10K Ohm
2 x Jumper Wires 3in M/M
5 x Jumper Wires 6in M/M
13 x Wire Solid Core – 22 AWG
1 x Full-Size Breadboard
1 x SparkFun Cerberus USB Cable

SparkFun Thing Plus – ESP32 WROOM

LEG – Digital 21
SCK – Digital 13
MOS – Digital 12
SSD – Digital 27
SDA – Digital 23
SCL – Digital 22
SD1 – Digital 33
SC2 – Digital 5
MO2 – Digital 18
MI2 – Digital 19
SS1 – Digital 16
GPS – Digital 4
VIN – +3.3V
GND – GND

DL2004Mk11p.ino

// ***** Don Luc Electronics © *****
// Software Version Information
// Project #15: Environment - Adafruit Adalogger FeatherWing - RTC + SD - Mk04
// 04-11
// DL2004Mk11p.ino 15-04
// EEPROM with Unique ID
// 1 x SparkFun Thing Plus - ESP32 WROOM
// 1 x Adafruit SHARP Memory Display
// 1 x SparkFun Environmental Combo Breakout - CCS811/BME280
// 1 x Adafruit Adalogger FeatherWing - RTC + SD
// 1 x SparkFun GPS Receiver - GP-20U7
// 1 x CR1220 12mm Lithium Battery
// 1 x 32Gb microSD Card
// 1 x Mountable Slide Switch
// 1 x Qwiic Cable - 100mm
// 1 x LED Green
// 1 x 10K Ohm
// 2 x Jumper Wires 3in M/M
// 5 x Jumper Wires 6in M/M
// 13 x Wire Solid Core - 22 AWG
// 1 x Full-Size Breadboard
// 1 x SparkFun Cerberus USB Cable

// Include the Library Code
// EEPROM Library to Read and Write EEPROM with Unique ID for Unit
#include "EEPROM.h"
// Wire
#include <Wire.h>
// SHARP Memory Display
#include <Adafruit_SharpMem.h>
#include <Adafruit_GFX.h>
// SparkFun CCS811 - eCO2 & tVOC
#include <SparkFunCCS811.h>
// SparkFun BME280 - Humidity, Temperature, Altitude and Barometric Pressure
#include <SparkFunBME280.h>
// Date and Time
#include "RTClib.h"
// SD Card
#include "FS.h"
#include "SD.h"
#include "SPI.h"
// GPS Receiver
#include <TinyGPS++.h>
// Hardware Serial
#include <HardwareSerial.h>

// LED Green
int iLEDGreen = 21;

// SHARP Memory Display
// any pins can be used
#define SHARP_SCK  13
#define SHARP_MOSI 12
#define SHARP_SS   27
// Set the size of the display here - 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
// 1/2 of lesser of display width or height
int minorHalfSize; 

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

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

// Date and Time
// PCF8523 Precision RTC 
RTC_PCF8523 rtc;
String dateRTC = "";
String timeRTC = "";

// microSD Card
const int chipSelect = 33;
String zzzzzz = "";

// Mountable Slide Switch
int iSS1 = 16;
// State
int iSS1State = 0;

// ESP32 HardwareSerial
HardwareSerial tGPS(2);

// GPS Receiver
#define gpsRXPIN 4
// This one is unused and doesnt have a conection
#define gpsTXPIN 36
// The TinyGPS++ object
TinyGPSPlus gps;
float TargetLat;
float TargetLon;
int GPSStatus = 0;

// Software Version Information
String sver = "15-04";
// EEPROM Unique ID Information
#define EEPROM_SIZE 64
String uid = "";

void loop() {

  // Receives NEMA data from GPS receiver
  isGPS();
  
  // Date and Time 
  isRTC();
  
  // SparkFun BME280 - Humidity, Temperature, Altitude and Barometric Pressure
  isBME280();

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

  // Display Environmental
  isDisplayEnvironmental();

  // Slide Switch
  // Read the state of the iSS1 value
  iSS1State = digitalRead(iSS1);
  
  // If it is the Slide Switch State is HIGH
  if (iSS1State == HIGH) {

    // iLEDGreen
    digitalWrite(iLEDGreen,  HIGH );
    
    // microSD Card
    isSD();

  } else {

    // iLEDGreen
    digitalWrite(iLEDGreen,  LOW );
  
  }

  delay( 1000 );
  
}

getBME280.ino

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

  // Temperature Celsius
  BMEtempC = myBME280.readTempC();
  // Humidity
  BMEhumid = myBME280.readFloatHumidity();
  // Altitude Meters
  BMEaltitudeM = (myBME280.readFloatAltitudeMeters(), 2);
  // 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

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

    // Text Display 
    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,100);   
    display.println( sver );
    // EEPROM Unique ID
    display.setTextSize(1);
    display.setCursor(0,130);
    display.println( "EEPROM Unique ID" );
    display.setTextSize(2);
    display.setCursor(0,145);
    display.println( uid );
    // Refresh
    display.refresh();
    delay( 100 );
    
}
// Display Environmental
void isDisplayEnvironmental(){

    // Text Display Environmental
    // Clear Display
    display.clearDisplay();
    display.setRotation(4);
    display.setTextSize(1);
    display.setTextColor(BLACK);
    // Temperature Celsius
    display.setCursor(0,0);
    display.println( "Temperature Celsius" );
    display.setCursor(0,10);
    display.print( BMEtempC );
    display.println( " C" );
    // Humidity
    display.setCursor(0,20);
    display.println( "Humidity" );
    display.setCursor(0,30);
    display.print( BMEhumid );
    display.println( "%" );
    // Altitude Meters
    display.setCursor(0,40);
    display.println( "Altitude Meters" );
    display.setCursor(0,50);
    display.print( BMEaltitudeM );
    display.println( " m" );
    // Pressure
    display.setCursor(0,60);    
    display.println( "Barometric Pressure" );
    display.setCursor(0,70);
    display.print( BMEpressure );
    display.println( " Pa" );
    // eCO2 Concentration
    display.setCursor(0,80);
    display.println( "eCO2 Concentration" );
    display.setCursor(0,90);
    display.print( CCS811CO2 );
    display.println( " ppm" );
    // tVOC Concentration
    display.setCursor(0,100);
    display.println( "tVOC Concentration" );
    display.setCursor(0,110);
    display.print( CCS811TVOC );
    display.println( " ppb" );
    // Date
    display.setCursor(0,120);
    display.println( dateRTC );
    // Time
    display.setCursor(0,130);
    display.println( timeRTC );
    // GPS Status
    display.setCursor(0,140);
    display.println( GPSStatus );
    // Target Latitude
    display.setCursor(0,150);
    display.println( TargetLat );
    // Target Longitude
    display.setCursor(0,160);
    display.println( TargetLon );
    // Refresh
    display.refresh();
    delay( 100 );

}

getEEPROM.ino

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

getGPS.ino

// GPS Receiver
// Setup GPS
void setupGPS() {

  // 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() ))
    {
     displayInfo();
    }
  
  if (millis() > 5000 && gps.charsProcessed() < 10)
  {
    while(true);
  }

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

  // Location
  if (gps.location.isValid())
  {
    
    TargetLat = gps.location.lat();
    TargetLon = gps.location.lng();
    GPSStatus = 2;
    
  }
  else
  {

    GPSStatus = 0;
    
  }

}

getRTC.ino

// Date & Time
// PCF8523 Precision RTC 
void setupRTC() {

  // Date & Time
  // pcf8523 Precision RTC   
  if (! rtc.begin()) {
    while (1);
  }  
  
  if (! rtc.initialized()) {
    // 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(2018, 9, 29, 12, 17, 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;
  
}

getSD.ino

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

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

    if(cardType == CARD_NONE){
        ; 
        return;
    }

    //Serial.print("SD Card Type: ");
    if(cardType == CARD_MMC){
        ; 
    } else if(cardType == CARD_SD){
        ; 
    } else if(cardType == CARD_SDHC){
        ; 
    } else {
        ; 
    } 

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

  zzzzzz = "";

  // EEPROM Unique ID|Version|Date|Time|GPS Status|Target Latitude|Target Longitude|Temperature Celsius|Humidity|Altitude Meters|Barometric Pressure|eCO2 Concentration|tVOC Concentration
  zzzzzz = uid + "|" + sver + "|" + dateRTC + "|" + timeRTC + "|" + GPSStatus + "|" + TargetLat + "|" + TargetLon + "|" + BMEtempC + "|" + BMEhumid + "|" + BMEaltitudeM + "|" + BMEpressure + "|" + CCS811CO2 + "|" + CCS811TVOC + "|\r";

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

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

  appendFile(SD, "/espdata.txt", msg );
  
}
// List Dir
void listDir(fs::FS &fs, const char * dirname, uint8_t levels){
    
    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){
    
    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){
    
    path;
    
    File file = fs.open(path, FILE_APPEND);
    
    if(!file){
        return;
    }
    
    if(file.print(message)){
        ;  
    } else {
        ;  
    }
    
    file.close();
    
}

setup.ino

// Setup
void setup() {

  // EEPROM Size
  EEPROM.begin(EEPROM_SIZE);
  
  // EEPROM Unique ID
  isUID();
  
  // GPS Receiver
  // Setup GPS
  setupGPS();
  
  // SHARP Display Start & Clear the Display
  display.begin();
  // Clear Display
  display.clearDisplay();
  
  // Display UID
  isDisplayUID();

  // Wire - Inialize I2C Hardware
  Wire.begin();

  // SparkFun BME280 - Humidity, Temperature, Altitude and Barometric Pressure
  myBME280.begin();
  
  // CCS811 - eCO2 & tVOC
  myCCS811.begin();

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

  // Date & Time RTC
  // PCF8523 Precision RTC 
  setupRTC();
  
  // Date & Time
  isRTC();
  
  // microSD Card
  setupSD();

  // Slide Switch
  pinMode(iSS1, INPUT);
  
  delay( 10000 );

}

Technology Experience

  • Research & Development (R & D)
  • Desktop Applications (Windows, OSX, Linux, Multi-OS, Multi-Tier, etc…)
  • Mobile Applications (Android, iOS, Blackberry, Windows Mobile, Windows CE, etc…)
  • Web Applications (LAMP, Scripting, Java, ASP, ASP.NET, RoR, Wakanda, etc…)
  • Social Media Programming & Integration (Facebook, Twitter, YouTube, Pinterest, etc…)
  • Content Management Systems (WordPress, Drupal, Joomla, Moodle, etc…)
  • Bulletin Boards (phpBB, SMF, Vanilla, jobberBase, etc…)
  • eCommerce (WooCommerce, OSCommerce, ZenCart, PayPal Shopping Cart, etc…)

Instructor

  • DOS, Windows, OSX, Linux, iOS, Android, Multi-OS
  • Linux-Apache-PHP-MySQL
  • Robotics
  • Arduino
  • Raspberry Pi
  • Espressif

Follow Us

The Alpha Geek

Why “The Alpha Geek”?

Aphasia
https://www.donluc.com/?page_id=2149

J. Luc Paquin – Curriculum Vitae
https://www.donluc.com/DLHackster/LucPaquinCVEngMk2020a.pdf

Web: https://www.donluc.com/
Web: http://www.jlpconsultants.com/
Web: https://www.donluc.com/DLHackster/
Web: https://www.hackster.io/neosteam-labs
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/

Don Luc

Project #15: Environment – Adafruit Adalogger FeatherWing – RTC + SD – Mk03

——

#DonLuc #Environment #Microcontrollers #ESP32 #Adalogger #SparkFun #Fritzing #Programming #Adafruit #Arduino #Electronics #Consultant #Vlog #Aphasia

——

Environment

——

Environment

——

Environment

——

Environment

——

Environment

——

DL2004Mk09

1 x SparkFun Thing Plus – ESP32 WROOM
1 x Adafruit SHARP Memory Display
1 x SparkFun Environmental Combo Breakout – CCS811/BME280
1 x Adafruit Adalogger FeatherWing – RTC + SD
1 x CR1220 12mm Lithium Battery
1 x 32Gb microSD Card
1 x Mountable Slide Switch
1 x Qwiic Cable – 100mm
1 x LED Green
1 x 10K Ohm
2 x Jumper Wires 3in M/M
5 x Jumper Wires 6in M/M
10 x Wire Solid Core – 22 AWG
1 x Full-Size Breadboard
1 x SparkFun Cerberus USB Cable

SparkFun Thing Plus – ESP32 WROOM

LEG – Digital 21
SCK – Digital 13
MOS – Digital 12
SSD – Digital 27
SDA – Digital 23
SCL – Digital 22
SD1 – Digital 33
SC2 – Digital 5
MO2 – Digital 18
MI2 – Digital 19
SS1 – Digital 16
VIN – +3.3V
GND – GND

DL2004Mk09p.ino

// ***** Don Luc Electronics © *****
// Software Version Information
// Project #15: Environment - Adafruit Adalogger FeatherWing - RTC + SD - Mk03
// 04-09
// DL2004Mk09p.ino 15-03
// EEPROM with Unique ID
// 1 x SparkFun Thing Plus - ESP32 WROOM
// 1 x Adafruit SHARP Memory Display
// 1 x SparkFun Environmental Combo Breakout - CCS811/BME280
// 1 x Adafruit Adalogger FeatherWing - RTC + SD
// 1 x CR1220 12mm Lithium Battery
// 1 x 32Gb microSD Card
// 1 x Mountable Slide Switch
// 1 x Qwiic Cable - 100mm
// 1 x LED Green
// 1 x 10K Ohm
// 2 x Jumper Wires 3in M/M
// 5 x Jumper Wires 6in M/M
// 10 x Wire Solid Core - 22 AWG
// 1 x Full-Size Breadboard
// 1 x SparkFun Cerberus USB Cable

// Include the Library Code
// EEPROM Library to Read and Write EEPROM with Unique ID for Unit
#include "EEPROM.h"
// Wire
#include <Wire.h>
// SHARP Memory Display
#include <Adafruit_SharpMem.h>
#include <Adafruit_GFX.h>
// SparkFun CCS811 - eCO2 & tVOC
#include <SparkFunCCS811.h>
// SparkFun BME280 - Humidity, Temperature, Altitude and Barometric Pressure
#include <SparkFunBME280.h>
// Date and Time
#include "RTClib.h"
// SD Card
#include "FS.h"
#include "SD.h"
#include "SPI.h"

// LED Green
int iLEDGreen = 21;

// SHARP Memory Display
// any pins can be used
#define SHARP_SCK  13
#define SHARP_MOSI 12
#define SHARP_SS   27
// Set the size of the display here - 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
// 1/2 of lesser of display width or height
int minorHalfSize; 

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

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

// Date and Time
// PCF8523 Precision RTC 
RTC_PCF8523 rtc;
String dateRTC = "";
String timeRTC = "";

// microSD Card
const int chipSelect = 33;
String zzzzzz = "";

// Mountable Slide Switch
int iSS1 = 16;
// State
int iSS1State = 0;

// Software Version Information
String sver = "15-03";
// EEPROM Unique ID Information
#define EEPROM_SIZE 64
String uid = "";

void loop() {

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

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

  // Display Environmental
  isDisplayEnvironmental();

  // Slide Switch
  // Read the state of the iSS1 value
  iSS1State = digitalRead(iSS1);
  
  // If it is the Slide Switch State is HIGH
  if (iSS1State == HIGH) {

    // iLEDGreen
    digitalWrite(iLEDGreen,  HIGH );
    
    // microSD Card
    isSD();

  } else {

    // iLEDGreen
    digitalWrite(iLEDGreen,  LOW );
  
  }

  delay( 1000 );
  
}

getBME280.ino

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

  // Temperature Celsius
  BMEtempC = myBME280.readTempC();
  // Humidity
  BMEhumid = myBME280.readFloatHumidity();
  // Altitude Meters
  BMEaltitudeM = (myBME280.readFloatAltitudeMeters(), 2);
  // 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

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

    // Text Display 
    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,100);   
    display.println( sver );
    // EEPROM Unique ID
    display.setTextSize(1);
    display.setCursor(0,130);
    display.println( "EEPROM Unique ID" );
    display.setTextSize(2);
    display.setCursor(0,145);
    display.println( uid );
    // Refresh
    display.refresh();
    delay( 100 );
    
}
// Display Environmental
void isDisplayEnvironmental(){

    // Text Display Environmental
    // Clear Display
    display.clearDisplay();
    display.setRotation(4);
    display.setTextSize(1);
    display.setTextColor(BLACK);
    // Temperature Celsius
    display.setCursor(0,0);
    display.println( "Temperature Celsius" );
    display.setCursor(0,10);
    display.print( BMEtempC );
    display.println( " C" );
    // Humidity
    display.setCursor(0,20);
    display.println( "Humidity" );
    display.setCursor(0,30);
    display.print( BMEhumid );
    display.println( "%" );
    // Altitude Meters
    display.setCursor(0,40);
    display.println( "Altitude Meters" );
    display.setCursor(0,50);
    display.print( BMEaltitudeM );
    display.println( " m" );
    // Pressure
    display.setCursor(0,60);    
    display.println( "Barometric Pressure" );
    display.setCursor(0,70);
    display.print( BMEpressure );
    display.println( " Pa" );
    // eCO2 Concentration
    display.setCursor(0,80);
    display.println( "eCO2 Concentration" );
    display.setCursor(0,90);
    display.print( CCS811CO2 );
    display.println( " ppm" );
    // tVOC Concentration
    display.setCursor(0,100);
    display.println( "tVOC Concentration" );
    display.setCursor(0,110);
    display.print( CCS811TVOC );
    display.println( " ppb" );
    // Date
    display.setCursor(0,120);
    display.println( dateRTC );
    // Time
    display.setCursor(0,130);
    display.println( timeRTC );
    // Refresh
    display.refresh();
    delay( 100 );

}

getEEPROM.ino

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

getRTC.ino

// Date & Time
// PCF8523 Precision RTC 
void setupRTC() {

  // Date & Time
  // pcf8523 Precision RTC   
  if (! rtc.begin()) {
    while (1);
  }  
  
  if (! rtc.initialized()) {
    // 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(2018, 9, 29, 12, 17, 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;
  
}

getSD.ino

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

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

    if(cardType == CARD_NONE){
        ; 
        return;
    }

    //Serial.print("SD Card Type: ");
    if(cardType == CARD_MMC){
        ; 
    } else if(cardType == CARD_SD){
        ; 
    } else if(cardType == CARD_SDHC){
        ; 
    } else {
        ; 
    } 

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

  zzzzzz = "";

  // EEPROM Unique ID|Version|Date|Time|Temperature Celsius|Humidity|Altitude Meters|Barometric Pressure|eCO2 Concentration|tVOC Concentration
  zzzzzz = uid + "|" + sver + "|" + dateRTC + "|" + timeRTC + "|" + BMEtempC + "|" + BMEhumid + "|" + BMEaltitudeM + "|" + BMEpressure + "|" + CCS811CO2 + "|" + CCS811TVOC + "|\r";

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

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

  appendFile(SD, "/espdata.txt", msg );
  
}
// List Dir
void listDir(fs::FS &fs, const char * dirname, uint8_t levels){
    
    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){
    
    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){
    
    path;
    
    File file = fs.open(path, FILE_APPEND);
    
    if(!file){
        return;
    }
    
    if(file.print(message)){
        ;  
    } else {
        ;  
    }
    
    file.close();
    
}

setup.ino

// Setup
void setup() {

  // EEPROM Size
  EEPROM.begin(EEPROM_SIZE);
  
  // EEPROM Unique ID
  isUID();
  
  // SHARP Display Start & Clear the Display
  display.begin();
  // Clear Display
  display.clearDisplay();
  
  // Display UID
  isDisplayUID();

  // Wire - Inialize I2C Hardware
  Wire.begin();

  // SparkFun BME280 - Humidity, Temperature, Altitude and Barometric Pressure
  myBME280.begin();
  
  // CCS811 - eCO2 & tVOC
  myCCS811.begin();

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

  // Date & Time RTC
  // PCF8523 Precision RTC 
  setupRTC();
  
  // Date & Time
  isRTC();
  
  // microSD Card
  setupSD();

  // Slide Switch
  pinMode(iSS1, INPUT);
  
  delay( 10000 );

}

Technology Experience

  • Research & Development (R & D)
  • Desktop Applications (Windows, OSX, Linux, Multi-OS, Multi-Tier, etc…)
  • Mobile Applications (Android, iOS, Blackberry, Windows Mobile, Windows CE, etc…)
  • Web Applications (LAMP, Scripting, Java, ASP, ASP.NET, RoR, Wakanda, etc…)
  • Social Media Programming & Integration (Facebook, Twitter, YouTube, Pinterest, etc…)
  • Content Management Systems (WordPress, Drupal, Joomla, Moodle, etc…)
  • Bulletin Boards (phpBB, SMF, Vanilla, jobberBase, etc…)
  • eCommerce (WooCommerce, OSCommerce, ZenCart, PayPal Shopping Cart, etc…)

Instructor

  • DOS, Windows, OSX, Linux, iOS, Android, Multi-OS
  • Linux-Apache-PHP-MySQL
  • Robotics
  • Arduino
  • Raspberry Pi
  • Espressif

Follow Us

The Alpha Geek

Why “The Alpha Geek”?

Aphasia
https://www.donluc.com/?page_id=2149

J. Luc Paquin – Curriculum Vitae
https://www.donluc.com/DLHackster/LucPaquinCVEngMk2020a.pdf

Web: https://www.donluc.com/
Web: http://www.jlpconsultants.com/
Web: https://www.donluc.com/DLHackster/
Web: https://www.hackster.io/neosteam-labs
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/

Don Luc

Project #14: Components – Adafruit Adalogger FeatherWing – RTC + SD – Mk10

——

#DonLuc #Electronics #Components #Microcontrollers #Environment #Adafruit #Consultant #Vlog #Aphasia

——

Components

——

Components

——

Components

——

Adafruit Adalogger FeatherWing – RTC + SD

Adafruit Item: 2922

This is the Adafruit Adalogger FeatherWing it adds both a battery-backed Real Time Clock and microSD card storage to any Feather main board. This FeatherWing will make it real easy to add datalogging. You get both an I2C real time clock (PCF8523) with 32KHz crystal and battery backup, and a microSD socket that connects to the SPI port pins. Does not come with a microSD card. A CR1220 coin cell is required to use the RTC battery-backup capabilities.

Technology Experience

  • Research & Development (R & D)
  • Desktop Applications (Windows, OSX, Linux, Multi-OS, Multi-Tier, etc…)
  • Mobile Applications (Android, iOS, Blackberry, Windows Mobile, Windows CE, etc…)
  • Web Applications (LAMP, Scripting, Java, ASP, ASP.NET, RoR, Wakanda, etc…)
  • Social Media Programming & Integration (Facebook, Twitter, YouTube, Pinterest, etc…)
  • Content Management Systems (WordPress, Drupal, Joomla, Moodle, etc…)
  • Bulletin Boards (phpBB, SMF, Vanilla, jobberBase, etc…)
  • eCommerce (WooCommerce, OSCommerce, ZenCart, PayPal Shopping Cart, etc…)

Instructor

  • DOS, Windows, OSX, Linux, iOS, Android, Multi-OS
  • Linux-Apache-PHP-MySQL
  • Robotics
  • Arduino
  • Raspberry Pi
  • Espressif

Follow Us

The Alpha Geek

Why “The Alpha Geek”?

Aphasia
https://www.donluc.com/?page_id=2149

J. Luc Paquin – Curriculum Vitae
https://www.donluc.com/DLHackster/LucPaquinCVEngMk2020a.pdf

Web: https://www.donluc.com/
Web: http://www.jlpconsultants.com/
Web: https://www.donluc.com/DLHackster/
Web: https://www.hackster.io/neosteam-labs
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/

Don Luc

Project #15: Environment – SparkFun Environmental CCS811/BME280 – Mk02

——

#DonLuc #Environment #Microcontrollers #ESP32 #SparkFun #Fritzing #Programming #Adafruit #Arduino #Electronics #Consultant #Vlog #Aphasia

——

Environment

——

Environment

——

Environment

——

Environment

——

DL2004Mk05

1 x SparkFun Thing Plus – ESP32 WROOM
1 x Adafruit SHARP Memory Display
1 x SparkFun Environmental Combo Breakout – CCS811/BME280
1 x Qwiic Cable – 100mm
1 x LED Green
4 x Jumper Wires 3in M/M
5 x Wire Solid Core – 22 AWG
1 x Full-Size Breadboard
1 x SparkFun Cerberus USB Cable

SparkFun Thing Plus – ESP32 WROOM

LEG – Digital 21
SCK – Digital 13
MOS – Digital 12
SSD – Digital 27
VIN – +3.3V
GND – GND

DL2004Mk05p.ino

// ***** Don Luc Electronics © *****
// Software Version Information
// Project #15: Environment - SparkFun Environmental Combo Breakout - CCS811/BME280 - Mk02
// 04-05
// DL2004Mk05p.ino 15-02
// EEPROM with Unique ID
// 1 x SparkFun Thing Plus - ESP32 WROOM
// 1 x Adafruit SHARP Memory Display
// 1 x SparkFun Environmental Combo Breakout - CCS811/BME280
// 1 x Qwiic Cable - 100mm
// 1 x LED Green
// 4 x Jumper Wires 3in M/M
// 5 x Wire Solid Core - 22 AWG
// 1 x Full-Size Breadboard
// 1 x SparkFun Cerberus USB Cable

// Include the Library Code
// EEPROM Library to Read and Write EEPROM with Unique ID for Unit
#include "EEPROM.h"
// Wire
#include <Wire.h>
// SHARP Memory Display
#include <Adafruit_SharpMem.h>
#include <Adafruit_GFX.h>
// SparkFun CCS811 - eCO2 & tVOC
#include <SparkFunCCS811.h>
// SparkFun BME280 - Humidity, Temperature, Altitude and Barometric Pressure
#include <SparkFunBME280.h>

// LED Green
int iLEDGreen = 21;

// SHARP Memory Display
// any pins can be used
#define SHARP_SCK  13
#define SHARP_MOSI 12
#define SHARP_SS   27
// Set the size of the display here - 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
// 1/2 of lesser of display width or height
int minorHalfSize; 

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

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

// Software Version Information
String sver = "15-02";
// EEPROM Unique ID Information
#define EEPROM_SIZE 64
String uid = "";

void loop() {

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

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

  // Display Environmental
  isDisplayEnvironmental();

  delay( 1000 );
  
}

getBME280.ino

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

  // Temperature Celsius
  BMEtempC = myBME280.readTempC();
  // Humidity
  BMEhumid = myBME280.readFloatHumidity();
  // Altitude Meters
  BMEaltitudeM = (myBME280.readFloatAltitudeMeters(), 2);
  // 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

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

    // Text Display 
    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,100);   
    display.println( sver );
    // EEPROM Unique ID
    display.setTextSize(1);
    display.setCursor(0,130);
    display.println( "EEPROM Unique ID" );
    display.setTextSize(2);
    display.setCursor(0,145);
    display.println( uid );
    // Refresh
    display.refresh();
    delay( 100 );
    
}
// Display Environmental
void isDisplayEnvironmental(){

    // Text Display Environmental
    // Clear Display
    display.clearDisplay();
    display.setRotation(4);
    display.setTextSize(1);
    display.setTextColor(BLACK);
    // Temperature Celsius
    display.setCursor(0,0);
    display.println( "Temperature Celsius" );
    display.setCursor(0,10);
    display.print( BMEtempC );
    display.println( " C" );
    // Humidity
    display.setCursor(0,20);
    display.println( "Humidity" );
    display.setCursor(0,30);
    display.print( BMEhumid );
    display.println( "%" );
    // Altitude Meters
    display.setCursor(0,40);
    display.println( "Altitude Meters" );
    display.setCursor(0,50);
    display.print( BMEaltitudeM );
    display.println( " m" );
    // Pressure
    display.setCursor(0,60);    
    display.println( "Barometric Pressure" );
    display.setCursor(0,70);
    display.print( BMEpressure );
    display.println( " Pa" );
    // eCO2 Concentration
    display.setCursor(0,80);
    display.println( "eCO2 Concentration" );
    display.setCursor(0,90);
    display.print( CCS811CO2 );
    display.println( " ppm" );
    // tVOC Concentration
    display.setCursor(0,100);
    display.println( "tVOC Concentration" );
    display.setCursor(0,110);
    display.print( CCS811TVOC );
    display.println( " ppb" );
    // Refresh
    display.refresh();
    delay( 100 );

}

getEEPROM.ino

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

setup.ino

// Setup
void setup() {

  // EEPROM Size
  EEPROM.begin(EEPROM_SIZE);
  
  // EEPROM Unique ID
  isUID();
  
  // SHARP Display Start & Clear the Display
  display.begin();
  // Clear Display
  display.clearDisplay();
  
  // Display UID
  isDisplayUID();

  // Wire - Inialize I2C Hardware
  Wire.begin();

  // SparkFun BME280 - Humidity, Temperature, Altitude and Barometric Pressure
  myBME280.begin();
  
  // CCS811 - eCO2 & tVOC
  myCCS811.begin();

  delay( 10000 );
  
  // LED Green
  pinMode(iLEDGreen, OUTPUT);
  digitalWrite(iLEDGreen, HIGH);

}

Technology Experience

  • Research & Development (R & D)
  • Desktop Applications (Windows, OSX, Linux, Multi-OS, Multi-Tier, etc…)
  • Mobile Applications (Android, iOS, Blackberry, Windows Mobile, Windows CE, etc…)
  • Web Applications (LAMP, Scripting, Java, ASP, ASP.NET, RoR, Wakanda, etc…)
  • Social Media Programming & Integration (Facebook, Twitter, YouTube, Pinterest, etc…)
  • Content Management Systems (WordPress, Drupal, Joomla, Moodle, etc…)
  • Bulletin Boards (phpBB, SMF, Vanilla, jobberBase, etc…)
  • eCommerce (WooCommerce, OSCommerce, ZenCart, PayPal Shopping Cart, etc…)

Instructor

  • DOS, Windows, OSX, Linux, iOS, Android, Multi-OS
  • Linux-Apache-PHP-MySQL
  • Robotics
  • Arduino
  • Raspberry Pi
  • Espressif

Follow Us

The Alpha Geek

Why “The Alpha Geek”?

Aphasia
https://www.donluc.com/?page_id=2149

J. Luc Paquin – Curriculum Vitae
https://www.donluc.com/DLHackster/LucPaquinCVEngMk2020a.pdf

Web: https://www.donluc.com/
Web: http://www.jlpconsultants.com/
Web: https://www.donluc.com/DLHackster/
Web: https://www.hackster.io/neosteam-labs
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/

Don Luc

Project #15: Environment – SparkFun Thing Plus – ESP32 WROOM – Mk01

——

#DonLuc #Environment #Electronics #Microcontrollers #ESP32 #SparkFun #Fritzing #Programming #Adafruit #Arduino #Consultant #Vlog #Aphasia

——

Environment

——

Environment

——

Environment

——

Environment

——

DL2004Mk04

1 x SparkFun Thing Plus – ESP32 WROOM
1 x Adafruit SHARP Memory Display
1 x LED Green
4 x Jumper Wires 3in M/M
5 x Wire Solid Core – 22 AWG
1 x Half-Size Breadboard
1 x SparkFun Cerberus USB Cable

SparkFun Thing Plus – ESP32 WROOM

LEG – Digital 21
SCK – Digital 13
MOS – Digital 12
SSD – Digital 27
VIN – +3.3V
GND – GND

DL2004Mk04p.ino

// ***** Don Luc Electronics © *****
// Software Version Information
// Project #15: Environment - SparkFun Thing Plus - ESP32 WROOM - Mk01
// 04-04
// DL2004Mk04p.ino 15-01
// EEPROM with Unique ID
// 1 x SparkFun Thing Plus - ESP32 WROOM
// 1 x Adafruit SHARP Memory Display
// 1 x LED Green
// 4 x Jumper Wires 3in M/M
// 5 x Wire Solid Core - 22 AWG
// 1 x Half-Size Breadboard
// 1 x SparkFun Cerberus USB Cable

// Include the library code:
// EEPROM library to read and write EEPROM with unique ID for unit
#include "EEPROM.h"
#include <Adafruit_SharpMem.h>
#include <Adafruit_GFX.h>

// LED Green
int iLEDGreen = 21;

// SHARP Memory Display
// any pins can be used
#define SHARP_SCK  13
#define SHARP_MOSI 12
#define SHARP_SS   27
// Set the size of the display here - 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
int minorHalfSize; // 1/2 of lesser of display width or height

// Software Version Information
#define EEPROM_SIZE 64
String sver = "15-01";
// Unit ID information
String uid = "";

void loop() {

  // Return
  
}

getDisplay.ino

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

    // text display EEPROM
    display.setRotation(4);
    display.setTextSize(3);
    display.setTextColor(BLACK);
    display.setCursor(0,20);
    display.println( "Don Luc" );
    display.setTextSize(2);
    display.setCursor(0,50);
    display.println( "Electronics" );
    display.setTextSize(3);
    display.setCursor(0,80);   
    display.println( sver );
    display.setCursor(0,120);
    display.println( uid );
    display.refresh();
    delay( 100 );
    
}

getEEPROM.ino

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

setup.ino

// Setup
void setup() {

  // EEPROM with unique ID
  EEPROM.begin(EEPROM_SIZE);
  
  // EEPROM Unit ID
  isUID();
  
  // SHARP Display start & clear the display
  display.begin();
  display.clearDisplay();

  isDisplayUID();

  delay( 5000 );
  
  // LED Green
  pinMode(iLEDGreen, OUTPUT);
  digitalWrite(iLEDGreen, HIGH);

}

Technology Experience

  • Research & Development (R & D)
  • Desktop Applications (Windows, OSX, Linux, Multi-OS, Multi-Tier, etc…)
  • Mobile Applications (Android, iOS, Blackberry, Windows Mobile, Windows CE, etc…)
  • Web Applications (LAMP, Scripting, Java, ASP, ASP.NET, RoR, Wakanda, etc…)
  • Social Media Programming & Integration (Facebook, Twitter, YouTube, Pinterest, etc…)
  • Content Management Systems (WordPress, Drupal, Joomla, Moodle, etc…)
  • Bulletin Boards (phpBB, SMF, Vanilla, jobberBase, etc…)
  • eCommerce (WooCommerce, OSCommerce, ZenCart, PayPal Shopping Cart, etc…)

Instructor

  • DOS, Windows, OSX, Linux, iOS, Android, Multi-OS
  • Linux-Apache-PHP-MySQL
  • Robotics
  • Arduino
  • Raspberry Pi
  • Espressif

Follow Us

The Alpha Geek

Why “The Alpha Geek”?

Aphasia
https://www.donluc.com/?page_id=2149

J. Luc Paquin – Curriculum Vitae
https://www.donluc.com/DLHackster/LucPaquinCVEngMk2020a.pdf

Web: https://www.donluc.com/
Web: http://www.jlpconsultants.com/
Web: https://www.donluc.com/DLHackster/
Web: https://www.hackster.io/neosteam-labs
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/

Don Luc

Project #12: Robotics – Unmanned Vehicles 1f – Mk10

——

Robotics

——

Robotics

——

Robotics

——

Robotics

——

Robotics

——

Robotics

——

Robotics

——

Robotics

——

Transmitter

DL2002Mk07

1 x Arduino UNO – R3
1 x ProtoScrewShield
1 x Adafruit RGB LCD Shield 16×2 Character Display
1 x XBee S1
1 x SparkFun XBee Explorer Regulated
1 x Slide Pot (Small)
1 x Knob
1 x Acrylic Blue 5.75in x 3.75in x 1/8in
24 x Screw – 4-40
12 x Standoff – Metal 4-40 – 3/8″
7 x Wire Solid Core – 22 AWG
1 x SparkFun XBee Explorer USB
1 x DIGI XCTU Software
1 x SparkFun Cerberus USB Cable

Arduino UNO

TX0 – Digital 1
RX0 – Digital 0
LP1 – Analog A0
VIN – +5V
GND – GND

XBee S1: Transmitter

CH Channel: C
PAN Id: 3333
SH Serial Number: 13A200
SL Serial Number: 40717A1F
CE Coordinator: Coordinator
BD: 9600

DL2002Mk07p.ino

// ***** Don Luc Electronics © *****
// Software Version Information
// Project #12: Robotics - Unmanned Vehicles 1f - Mk10
// 02-07
// DL2002Mk01p.ino 12-10
// Arduino UNO - R3
// ProtoScrewShield
// Adafruit RGB LCD Shield 16×2 Character Display
// EEPROM with Unique ID
// Transmitter
// XBee S1
// Stepper
// Slide Pot (Small)
// Knob

// Include the library code:
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>
// Adafruit RGB LCD Shield
#include <Adafruit_RGBLCDShield.h>

// Adafruit RGB LCD Shield
Adafruit_RGBLCDShield RGBLCDShield = Adafruit_RGBLCDShield();

// These #defines make it easy to set the backlight color
#define OFF 0x0
#define RED 0x1
#define YELLOW 0x3
#define GREEN 0x2
#define TEAL 0x6
#define BLUE 0x4
#define VIOLET 0x5
#define WHITE 0x7

// Momentary Button
int yy = 0;
uint8_t momentaryButton = 0;

// Communication
unsigned long dTime = 50;

// Slide Pot (Small)
int iSP1 = A0;                           // Select the input pin for the slide pot
int iValue = 0;                          // Variable to store the value

// The current address in the EEPROM (i.e. which byte we're going to  read to next)
// Version
String sver = "12-10.p";
// Unit ID Information
String uid = "";

void loop() {

  // Clear
  RGBLCDShield.clear();

  // set the cursor to column 0, line 0
  RGBLCDShield.setCursor(0,0);
  RGBLCDShield.print("Robotics");         // Robotics 

  // Momentary Button
  momentaryButton = RGBLCDShield.readButtons();

  switch ( yy ) {
    case 1:
    
      // Forward
      isSwitch1();
      
      break;
    case 2:
    
      // Reverse
      isSwitch2();
      
      break;
    case 3:

      // Right
      isSwitch3();
      
      break;
    case 4:

      // Left
      isSwitch4();
      
      break;
    case 5:

      // Stop
      isSwitch5();
      
      break;
    default:

      // Stop
      yy = 5;
      RGBLCDShield.setBacklight(RED);
      isSwitch5();

   }
   
   if ( momentaryButton ) {
    
    if ( momentaryButton & BUTTON_UP ) {
      
      yy = 1;
      // Forward
      RGBLCDShield.setBacklight(GREEN);
      
    }
    
    if ( momentaryButton & BUTTON_DOWN ) {
      
      yy = 2;
      // Reverse
      RGBLCDShield.setBacklight(VIOLET);
      
    }
    
    if ( momentaryButton & BUTTON_LEFT ) {
      
      yy = 3;
      // Right
      RGBLCDShield.setBacklight(TEAL);
      
    }
    
    if ( momentaryButton & BUTTON_RIGHT ) {

      yy = 4;
      // Left
      RGBLCDShield.setBacklight(YELLOW);
    }
    
    if ( momentaryButton & BUTTON_SELECT ) {

      yy = 5;
      // Stop
      RGBLCDShield.setBacklight(RED);
   
    }
    
  }

  // Read the value
  iValue = analogRead( iSP1 );

  // Process Message
  isProcessMessage();

  delay( dTime );
   
}

getEEPROM.ino

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

getProcessMessage.ino

// ProcessMessage
// isProcessMessage
void isProcessMessage() {
  
    // Loop through serial buffer
    while ( Serial.available() ) 
   {

      // Print = "<" + yy + "|" + sver + "|" + iValue + "*"
      
      Serial.print( '<'  );
      Serial.print( yy );
      Serial.print( '|' );
      Serial.print( iValue );
      Serial.println( '*' );
         
   }
     
}

getSwitch.ino

// Switch
// Switch 1
void isSwitch1(){

   yy = 1;

   // Stepper 
   // Forward
   RGBLCDShield.setCursor(0,1);    
   RGBLCDShield.print("Forward");  
   
}
// Switch 2
void isSwitch2(){

   yy = 2;

   // Stepper 
   // Reverse
   RGBLCDShield.setCursor(0,1);    
   RGBLCDShield.print("Reverse");    
      
}
// Switch 3
void isSwitch3(){

   yy = 3;

   // Stepper 
   // Right
   RGBLCDShield.setCursor(0,1);    
   RGBLCDShield.print("Right");    
      
}
// Switch 4
void isSwitch4(){

   yy = 4;

   // Stepper 
   // Left
   RGBLCDShield.setCursor(0,1);    
   RGBLCDShield.print("Left"); 
      
}
// Switch 5
void isSwitch5(){

   yy = 5;
   
   // Stepper 
   // Stop
   RGBLCDShield.setCursor(0,1);    
   RGBLCDShield.print("Stop");
       
}

setup.ino

// Setup
void setup() {
  
  // Open serial port at 9600 baud
  Serial.begin( 9600 );

  // Pause
  delay(5);

  // EEPROM Unit ID
  isUID();
  
  // Pause
  delay(5);
  
  // Adafruit RGB LCD Shield
  // Set up the LCD's number of columns and rows: 
  RGBLCDShield.begin(16, 2);
  RGBLCDShield.setBacklight(GREEN);
  
  // Display
  // Set the cursor to column 0, line 0  
  RGBLCDShield.setCursor(0,0);  
  RGBLCDShield.print("Don Luc Electron");         // Don luc Electron
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  RGBLCDShield.print("Robotics");                 // Robotics

  delay(5000);

  // Clear
  RGBLCDShield.clear();

  // Display
  // Set the cursor to column 0, line 0  
  RGBLCDShield.setCursor(0,0);  
  RGBLCDShield.print("Version: ");                // Version
  RGBLCDShield.print( sver );
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  RGBLCDShield.print("UID: ");                    // Unit ID Information
  RGBLCDShield.print( uid );

  delay(5000);

  // Clear
  RGBLCDShield.clear();

}

Follow Us

J. Luc Paquin – Curriculum Vitae
https://www.donluc.com/DLHackster/LucPaquinCVEngMk2020a.pdf

Web: https://www.donluc.com/
Web: http://www.jlpconsultants.com/
Web: https://www.donluc.com/DLHackster/
Web: https://www.hackster.io/neosteam-labs
Web: http://neosteamlabs.com/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Facebook: https://www.facebook.com/neosteam.labs.9/
Instagram: https://www.instagram.com/neosteamlabs/
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Twitter: https://twitter.com/labs_steam
Etsy: https://www.etsy.com/shop/NeoSteamLabs

Don Luc

Project #12: Robotics – Unmanned Vehicles 1e – Mk09

——

Robotics

——

Robotics

——

Robotics

——

Robotics

——

Robotics

——

DL2002Mk05

1 x Arduino UNO – R3
1 x Arduino UNO – SparkFun RedBoard
1 x ProtoScrewShield
1 x Adafruit RGB LCD Shield 16×2 Character Display
2 x XBee S1
1 x SparkFun XBee Explorer Regulated
1 x Breakout Board for XBee Module
2 x EasyDriver
2 x Small Stepper
1 x Adafruit PowerBoost 500 Shield
1 x Lithium Ion Battery – 2Ah
1 x LED Green
1 x Slide Pot (Small)
1 x Knob
7 x Jumper Wires 3″ M/M
16 x Jumper Wires 6″ M/M
1 x Full-Size Breadboard
1 x SparkFun XBee Explorer USB
1 x DIGI XCTU Software
1 x SparkFun USB Mini-B Cable
1 x SparkFun Cerberus USB Cable

Arduino UNO

TX0 – Digital 1
RX0 – Digital 0
LP1 – Analog A0
VIN – +5V
GND – GND

XBee S1: Transmitter

CH Channel: C
PAN Id: 3333
SH Serial Number: 13A200
SL Serial Number: 40717A1F
CE Coordinator: Coordinator
BD: 9600

DL2002Mk05p.ino

// ***** Don Luc Electronics © *****
// Software Version Information
// Project #12: Robotics - Unmanned Vehicles 1d - Mk09
// 02-05
// DL2002Mk01p.ino 12-09
// Arduino UNO - R3
// ProtoScrewShield
// Adafruit RGB LCD Shield 16×2 Character Display
// EEPROM with Unique ID
// Transmitter
// XBee S1
// Stepper
// Slide Pot (Small)
// Knob

// Include the library code:
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>
// Adafruit RGB LCD Shield
#include <Adafruit_RGBLCDShield.h>

// Adafruit RGB LCD Shield
Adafruit_RGBLCDShield RGBLCDShield = Adafruit_RGBLCDShield();

// These #defines make it easy to set the backlight color
#define OFF 0x0
#define RED 0x1
#define YELLOW 0x3
#define GREEN 0x2
#define TEAL 0x6
#define BLUE 0x4
#define VIOLET 0x5
#define WHITE 0x7

// Momentary Button
int yy = 0;
uint8_t momentaryButton = 0;

// Communication
unsigned long dTime = 50;

// Slide Pot (Small)
int iSP1 = A0;                           // Select the input pin for the slide pot
int iValue = 0;                          // Variable to store the value

// The current address in the EEPROM (i.e. which byte we're going to  read to next)
// Version
String sver = "12-9.p";
// Unit ID Information
String uid = "";

void loop() {

  // Clear
  RGBLCDShield.clear();

  // set the cursor to column 0, line 0
  RGBLCDShield.setCursor(0,0);
  RGBLCDShield.print("Robotics");         // Robotics 

  // Momentary Button
  momentaryButton = RGBLCDShield.readButtons();

  switch ( yy ) {
    case 1:
    
      // Up
      isSwitch1();
      
      break;
    case 2:
    
      // Down
      isSwitch2();
      
      break;
    case 3:

      // Right
      isSwitch3();
      
      break;
    case 4:

      // Left
      isSwitch4();
      
      break;
    case 5:

      // Stop
      isSwitch5();
      
      break;
    default:

      // Stop
      yy = 5;
      RGBLCDShield.setBacklight(RED);
      isSwitch5();

   }
   
   if ( momentaryButton ) {
    
    if ( momentaryButton & BUTTON_UP ) {
      
      yy = 1;
      // Up
      RGBLCDShield.setBacklight(GREEN);
      
    }
    
    if ( momentaryButton & BUTTON_DOWN ) {
      
      yy = 2;
      // Down
      RGBLCDShield.setBacklight(VIOLET);
      
    }
    
    if ( momentaryButton & BUTTON_LEFT ) {
      
      yy = 3;
      // Right
      RGBLCDShield.setBacklight(TEAL);
      
    }
    
    if ( momentaryButton & BUTTON_RIGHT ) {

      yy = 4;
      // Left
      RGBLCDShield.setBacklight(YELLOW);
    }
    
    if ( momentaryButton & BUTTON_SELECT ) {

      yy = 5;
      // Stop
      RGBLCDShield.setBacklight(RED);
   
    }
    
  }

  // Read the value
  iValue = analogRead( iSP1 );

  // Process Message
  isProcessMessage();

  delay( dTime );
   
}

getEEPROM.ino

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

getProcessMessage.ino

// ProcessMessage
// isProcessMessage
void isProcessMessage() {

   // String msg = "";
  
   /// Loop through serial buffer one byte at a time until you reach * which will be end of message
   //while ( Serial.available() ) 
  // {

      // Print => XBEE + Unit ID + Version + *
      // msg = "XBEE|" + uid + "|" + sver + "|" + yy + "|*";
      
      Serial.print( '<'  );
      Serial.print( yy );
      Serial.print( '|' );
      Serial.print( iValue );
      Serial.println( '*' );
         
  // }
     
}

getSwitch.ino

// Switch
// Switch 1
void isSwitch1(){

   yy = 1;

   // Stepper 
   // Up
   RGBLCDShield.setCursor(0,1);    
   RGBLCDShield.print("Up");  
   
}
// Switch 2
void isSwitch2(){

   yy = 2;

   // Stepper 
   // Down
   RGBLCDShield.setCursor(0,1);    
   RGBLCDShield.print("Down");    
      
}
// Switch 3
void isSwitch3(){

   yy = 3;

   // Stepper 
   // Right
   RGBLCDShield.setCursor(0,1);    
   RGBLCDShield.print("Right");    
      
}
// Switch 4
void isSwitch4(){

   yy = 4;

   // Stepper 
   // Left
   RGBLCDShield.setCursor(0,1);    
   RGBLCDShield.print("Left"); 
      
}
// Switch 5
void isSwitch5(){

   yy = 5;
   
   // Stepper 
   // Stop
   RGBLCDShield.setCursor(0,1);    
   RGBLCDShield.print("Stop");
       
}

setup.ino

// Setup
void setup() {
  
  // Open serial port at 9600 baud
  Serial.begin( 9600 );

  // Pause
  delay(5);

  // EEPROM Unit ID
  isUID();
  
  // Pause
  delay(5);
  
  // Adafruit RGB LCD Shield
  // Set up the LCD's number of columns and rows: 
  RGBLCDShield.begin(16, 2);
  RGBLCDShield.setBacklight(GREEN);
  
  // Display
  // Set the cursor to column 0, line 0  
  RGBLCDShield.setCursor(0,0);  
  RGBLCDShield.print("Don Luc Electron");         // Don luc Electron
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  RGBLCDShield.print("Robotics");                 // Robotics

  // Serial
  // Serial.println( "Don Luc Electronics");
  // Serial.println( "Robotics");

  delay(5000);

  // Clear
  RGBLCDShield.clear();

  // Display
  // Set the cursor to column 0, line 0  
  RGBLCDShield.setCursor(0,0);  
  RGBLCDShield.print("Version: ");                // Version
  RGBLCDShield.print( sver );
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  RGBLCDShield.print("UID: ");                    // Unit ID Information
  RGBLCDShield.print( uid );

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

  delay(5000);

  // Clear
  RGBLCDShield.clear();

}

Arduino UNO – SparkFun RedBoard

LEG – Digital 6
SP1 – Digital 3
DI1 – Digital 2
SP2 – Digital 5
DI2 – Digital 4
TX0 – Digital 1
RX0 – Digital 0
VIN – +5V
GND – GND

XBee S1: Receiver

CH Channel: C
PAN Id: 3333
SH Serial Number: 13A200
SL Serial Number: 4076E2C5
CE Coordinator: End Device
BD: 9600

DL2002Mk05Rp.ino

// ***** Don Luc Electronics © *****
// Software Version Information
// Project #12: Robotics - Unmanned Vehicles 1e - Mk09
// 02-05
// DL2002Mk05Rp.ino 12-09
// Arduino UNO - SparkFun RedBoard
// EEPROM with Unique ID
// Receiver
// Breakout Board for XBee Module
// XBee S1
// 2 x EasyDriver
// 2 x Small Stepper
// Adafruit PowerBoost 500 Shield
// Lithium Ion Battery - 2Ah
// LED Green
// delayMicroseconds

// Include the library code:
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>

// Momentary Button
int yy = "";

// 2 x EasyDriver - 2 x Stepper
int dirPinR = 2;                           // EasyDriver Right
int stepPinR = 3;                          // stepPin Right
int dirPinL = 4;                           // EasyDriver Left
int stepPinL = 5;                          // stepPin Left
int i = 0;

// LED Green
int iLEDGreen = 6;

// Process Message
bool bStart = false;                       // Start
bool bEnd   = false;                       // End
int incb = 0;                              // Variable to store the incoming byte
String msg = "";                           // Message 
String zzz = "";                          
byte in = 0;                               // Index
int x = 0;

// delayMicroseconds
int dMicro = 0;

// Software Version Information
String sver = "12-09";
// Unit ID information
String uid = "";

void loop() {

  // Check for serial messages
  if ( Serial.available() ) 
  {
    
    isProcessMessage();
    
  }

  // Switch
  isSwitch();
  
}

getEEPROM.ino

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

getProcessMessage.ino

// ProcessMessage
// isProcessMessage
void isProcessMessage() {
   
  // Loop through serial buffer one byte at a time until you reach * which will be end of message
  while ( Serial.available() ) 
  {
      
      // Read the incoming byte:
      incb = Serial.read();
      
      // Start the message when the '<' symbol is received
      if(incb == '<')
      {
        
        bStart = true;
        in = 0;
        msg = "";
        
      }
      // End the message when the '*' symbol is received
      else if(incb == '*')
      {
        bEnd = true;
        x = msg.length();
        msg.remove( x , 1);
        break;                                  // Done reading
      }
      // Read the message
      else
      {
        if(in < 8)                              // Make sure there is room
        {

           msg = msg + char(incb);
           in++;
          
        }
      }
      
   }

   if( bStart && bEnd)
   {
    
      // Stepper
      zzz = msg.charAt( 0 );
      yy = zzz.toInt();
      
      msg.remove( 0 , 2);
      
      // delayMicroseconds
      dMicro = msg.toInt() + 300;

      in = 0;
      zzz = "";
      msg = "";
      bStart = false;
      bEnd = false;
      
   }

}

getStepper.ino

// Stepper
// isStepperSetup
void isStepperSetup() {

  // 2 x EasyDriver
  pinMode(dirPinR, OUTPUT);
  pinMode(stepPinR, OUTPUT);
  pinMode(dirPinL, OUTPUT);
  pinMode(stepPinL, OUTPUT);

}
// isStepper1
void isStepper1(){

   // 2 x EasyDriver - Up
   digitalWrite(dirPinR, LOW);              // Set the direction.
   digitalWrite(dirPinL, LOW);              // Set the direction.

   digitalWrite(stepPinR, LOW);             // This LOW to HIGH change is what creates the
   digitalWrite(stepPinR, HIGH);            // "Rising Edge" so the easydriver knows to when to step.
   delayMicroseconds(dMicro);               // This delay time is close to top speed.
   digitalWrite(stepPinL, LOW);             // This LOW to HIGH change is what creates the
   digitalWrite(stepPinL, HIGH);            // "Rising Edge" so the easydriver knows to when to step.
   delayMicroseconds(dMicro);               // This delay time is close to top speed.
 
}
// isStepper2
void isStepper2(){

   // 2 x EasyDriver
   digitalWrite(dirPinR, HIGH);              // Set the direction.
   digitalWrite(dirPinL, HIGH);              // Set the direction.

   digitalWrite(stepPinR, LOW);             // This LOW to HIGH change is what creates the
   digitalWrite(stepPinR, HIGH);            // "Rising Edge" so the easydriver knows to when to step.
   delayMicroseconds(dMicro);               // This delay time is close to top speed.
   digitalWrite(stepPinL, LOW);             // This LOW to HIGH change is what creates the
   digitalWrite(stepPinL, HIGH);            // "Rising Edge" so the easydriver knows to when to step.
   delayMicroseconds(dMicro);               // This delay time is close to top speed.
   
}
// Switch 3
void isStepper3(){

   // Right

   // 2 x EasyDriver
   digitalWrite(dirPinR, LOW);              // Set the direction.
   digitalWrite(dirPinL, HIGH);             // Set the direction.   delay(5);

   digitalWrite(stepPinR, LOW);             // This LOW to HIGH change is what creates the
   digitalWrite(stepPinR, HIGH);            // "Rising Edge" so the easydriver knows to when to step.
   delayMicroseconds(dMicro);               // This delay time is close to top speed.
   digitalWrite(stepPinL, LOW);             // This LOW to HIGH change is what creates the
   digitalWrite(stepPinL, HIGH);            // "Rising Edge" so the easydriver knows to when to step.
   delayMicroseconds(dMicro);               // This delay time is close to top speed.

}
// Switch 4
void isStepper4(){

   // Left
   // 2 x EasyDriver
   digitalWrite(dirPinR, HIGH);             // Set the direction.
   digitalWrite(dirPinL, LOW);              // Set the direction.

   digitalWrite(stepPinR, LOW);             // This LOW to HIGH change is what creates the
   digitalWrite(stepPinR, HIGH);            // "Rising Edge" so the easydriver knows to when to step.
   delayMicroseconds(dMicro);               // This delay time is close to top speed.
   digitalWrite(stepPinL, LOW);             // This LOW to HIGH change is what creates the
   digitalWrite(stepPinL, HIGH);            // "Rising Edge" so the easydriver knows to when to step.
   delayMicroseconds(dMicro);               // This delay time is close to top speed.
  
}
// isStepperStop
void isStepperStop() {

   // 2 x EasyDriver
   digitalWrite(dirPinR, LOW);              // Set the direction.
   delay(5);
   digitalWrite(dirPinL, LOW);              // Set the direction.
   delay(5);
   digitalWrite(stepPinR, LOW);             // This LOW to HIGH change is what creates the
   digitalWrite(stepPinL, LOW);             // This LOW to HIGH change is what creates the 

}

getSwitch.ino

// Switch
// isSwitch
void isSwitch(){
  
  switch ( yy ) {
    case 1:

      // Stepper 1 - Up
      isStepper1();

      break;
    case 2:
      
      // Stepper 2 - Back
      isStepper2();
      
      break;
    case 3:

      // Stepper 3 - Right
      isStepper3();
      
      break;
    case 4:
      
      // Stepper 4 - Left
      isStepper4();
      
      break;
    case 5:
      
      // Stepper Stop
      isStepperStop();
       
      break;
    default:

     // Stepper Stop
     isStepperStop();

   }
  
}

setup.ino

// Setup
void setup() {

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

  // Pause
  delay(5);

  // EEPROM Unit ID
  isUID();
  
  // Pause
  delay(5);
  
  // 2 x EasyDriver
  isStepperSetup();

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

}

Follow Us

J. Luc Paquin – Curriculum Vitae
https://www.donluc.com/DLHackster/LucPaquinCVEngMk2020a.pdf

Web: https://www.donluc.com/
Web: http://www.jlpconsultants.com/
Web: https://www.donluc.com/DLHackster/
Web: https://www.hackster.io/neosteam-labs
Web: http://neosteamlabs.com/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Facebook: https://www.facebook.com/neosteam.labs.9/
Instagram: https://www.instagram.com/neosteamlabs/
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Twitter: https://twitter.com/labs_steam
Etsy: https://www.etsy.com/shop/NeoSteamLabs

Don Luc

Project #12: Robotics – Unmanned Vehicles 1d – Mk08

——

Robotics

——

Robotics

——

Robotics

——

Robotics

——

Robotics

——

DL2002Mk03

1 x Arduino UNO – R3
1 x Arduino UNO – SparkFun RedBoard
1 x ProtoScrewShield
1 x Adafruit RGB LCD Shield 16×2 Character Display
2 x XBee S1
1 x SparkFun XBee Explorer Regulated
1 x Breakout Board for XBee Module
2 x EasyDriver
2 x Small Stepper
1 x Adafruit PowerBoost 500 Shield
1 x Lithium Ion Battery – 2Ah
1 x LED Green
7 x Jumper Wires 3″ M/M
13 x Jumper Wires 6″ M/M
1 x Full-Size Breadboard
1 x SparkFun XBee Explorer USB
1 x DIGI XCTU Software
1 x SparkFun USB Mini-B Cable
1 x SparkFun Cerberus USB Cable

Arduino UNO

TX0 – Digital 1
RX0 – Digital 0
VIN – +5V
GND – GND

XBee S1: Transmitter

CH Channel: C
PAN Id: 3333
SH Serial Number: 13A200
SL Serial Number: 40717A1F
CE Coordinator: Coordinator
BD: 9600

DL2002Mk03p.ino

// ***** Don Luc Electronics © *****
// Software Version Information
// Project #12: Robotics - Unmanned Vehicles 1d - Mk08
// 02-03
// DL2002Mk01p.ino 12-08
// Arduino UNO - R3
// ProtoScrewShield
// Adafruit RGB LCD Shield 16×2 Character Display
// EEPROM with Unique ID
// Transmitter
// XBee S1
// Stepper

// Include the library code:
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>
// Adafruit RGB LCD Shield
#include <Adafruit_RGBLCDShield.h>

// Adafruit RGB LCD Shield
Adafruit_RGBLCDShield RGBLCDShield = Adafruit_RGBLCDShield();

// These #defines make it easy to set the backlight color
#define OFF 0x0
#define RED 0x1
#define YELLOW 0x3
#define GREEN 0x2
#define TEAL 0x6
#define BLUE 0x4
#define VIOLET 0x5
#define WHITE 0x7

// Momentary Button
int yy = 0;
uint8_t momentaryButton = 0;

// Communication
unsigned long dTime = 50;

// The current address in the EEPROM (i.e. which byte we're going to  read to next)
// Version
String sver = "12-7.p";
// Unit ID Information
String uid = "";

void loop() {

  // Clear
  RGBLCDShield.clear();

  // set the cursor to column 0, line 0
  RGBLCDShield.setCursor(0,0);
  RGBLCDShield.print("Robotics");         // Robotics 

  // Momentary Button
  momentaryButton = RGBLCDShield.readButtons();

  switch ( yy ) {
    case 1:
    
      // Up
      isSwitch1();
      
      break;
    case 2:
    
      // Down
      isSwitch2();
      
      break;
    case 3:

      // Right
      isSwitch3();
      
      break;
    case 4:

      // Left
      isSwitch4();
      
      break;
    case 5:

      // Stop
      isSwitch5();
      
      break;
    default:

      // Stop
      yy = 5;
      RGBLCDShield.setBacklight(RED);
      isSwitch5();

   }
   
   if ( momentaryButton ) {
    
    if ( momentaryButton & BUTTON_UP ) {
      
      yy = 1;
      // Up
      RGBLCDShield.setBacklight(GREEN);
      
    }
    
    if ( momentaryButton & BUTTON_DOWN ) {
      
      yy = 2;
      // Down
      RGBLCDShield.setBacklight(VIOLET);
      
    }
    
    if ( momentaryButton & BUTTON_LEFT ) {
      
      yy = 3;
      // Right
      RGBLCDShield.setBacklight(TEAL);
      
    }
    
    if ( momentaryButton & BUTTON_RIGHT ) {

      yy = 4;
      // Left
      RGBLCDShield.setBacklight(YELLOW);
    }
    
    if ( momentaryButton & BUTTON_SELECT ) {

      yy = 5;
      // Stop
      RGBLCDShield.setBacklight(RED);
   
    }
    
  }

  // Process Message
  isProcessMessage();

  delay( dTime );
   
}

getEEPROM.ino

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

getProcessMessage.ino

// ProcessMessage
// isProcessMessage
void isProcessMessage() {

   // String msg = "";
  
   /// Loop through serial buffer one byte at a time until you reach * which will be end of message
   //while ( Serial.available() ) 
  // {

      // Print => XBEE + Unit ID + Version + *
      // msg = "XBEE|" + uid + "|" + sver + "|" + yy + "|*";
      
      Serial.print( '<'  );
      Serial.print( yy );
      Serial.println( '*' );
         
  // }
     
}

getSwitch.ino

// Switch
// Switch 1
void isSwitch1(){

   yy = 1;

   // Stepper 
   // Up
   RGBLCDShield.setCursor(0,1);    
   RGBLCDShield.print("Up");  
   
}
// Switch 2
void isSwitch2(){

   yy = 2;

   // Stepper 
   // Down
   RGBLCDShield.setCursor(0,1);    
   RGBLCDShield.print("Down");    
      
}
// Switch 3
void isSwitch3(){

   yy = 3;

   // Stepper 
   // Right
   RGBLCDShield.setCursor(0,1);    
   RGBLCDShield.print("Right");    
      
}
// Switch 4
void isSwitch4(){

   yy = 4;

   // Stepper 
   // Left
   RGBLCDShield.setCursor(0,1);    
   RGBLCDShield.print("Left"); 
      
}
// Switch 5
void isSwitch5(){

   yy = 5;
   
   // Stepper 
   // Stop
   RGBLCDShield.setCursor(0,1);    
   RGBLCDShield.print("Stop");
       
}

setup.ino

// Setup
void setup() {
  
  // Open serial port at 9600 baud
  Serial.begin( 9600 );

  // Pause
  delay(5);

  // EEPROM Unit ID
  isUID();
  
  // Pause
  delay(5);
  
  // Adafruit RGB LCD Shield
  // Set up the LCD's number of columns and rows: 
  RGBLCDShield.begin(16, 2);
  RGBLCDShield.setBacklight(GREEN);
  
  // Display
  // Set the cursor to column 0, line 0  
  RGBLCDShield.setCursor(0,0);  
  RGBLCDShield.print("Don Luc Electron");         // Don luc Electron
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  RGBLCDShield.print("Robotics");                 // Robotics

  // Serial
  // Serial.println( "Don Luc Electronics");
  // Serial.println( "Robotics");

  delay(5000);

  // Clear
  RGBLCDShield.clear();

  // Display
  // Set the cursor to column 0, line 0  
  RGBLCDShield.setCursor(0,0);  
  RGBLCDShield.print("Version: ");                // Version
  RGBLCDShield.print( sver );
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  RGBLCDShield.print("UID: ");                    // Unit ID Information
  RGBLCDShield.print( uid );

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

  delay(5000);

  // Clear
  RGBLCDShield.clear();

}

Arduino UNO – SparkFun RedBoard

LEG – Digital 6
SP1 – Digital 3
DI1 – Digital 2
SP2 – Digital 5
DI2 – Digital 4
TX0 – Digital 1
RX0 – Digital 0
VIN – +3.3V
GND – GND

XBee S1: Receiver

CH Channel: C
PAN Id: 3333
SH Serial Number: 13A200
SL Serial Number: 4076E2C5
CE Coordinator: End Device
BD: 9600

DL2002Mk03Rp.ino

// ***** Don Luc Electronics © *****
// Software Version Information
// Project #12: Robotics - Unmanned Vehicles 1d - Mk08
// 02-03
// DL2002Mk01Rp.ino 12-08
// Arduino UNO - SparkFun RedBoard
// EEPROM with Unique ID
// Receiver
// Breakout Board for XBee Module
// XBee S1
// 2 x EasyDriver
// 2 x Small Stepper
// Adafruit PowerBoost 500 Shield
// Lithium Ion Battery - 2Ah
// LED Green

// Include the library code:
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>

// Momentary Button
int yy = "";

// 2 x EasyDriver - 2 x Stepper
int dirPinR = 2;                           // EasyDriver Right
int stepPinR = 3;                          // stepPin Right
int dirPinL = 4;                           // EasyDriver Left
int stepPinL = 5;                          // stepPin Left
int i = 0;

// LED Green
int iLEDGreen = 6;

// Software Version Information
String sver = "12-08";
// Unit ID information
String uid = "";

void loop() {

  // Check for serial messages
  if ( Serial.available() ) 
  {
    
    isProcessMessage();
    
  }

  // Switch
  isSwitch();
  
}

getEEPROM.ino

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

getProcessMessage.ino

// ProcessMessage
// isProcessMessage
void isProcessMessage() {

   int incb = 0;  
   String msg = "";
   String zzz = "";
   
  // Loop through serial buffer one byte at a time until you reach * which will be end of message
  while ( Serial.available() ) 
  {
      
      // Read the incoming byte:
      incb = Serial.read();
      // Add character to string
      msg = msg + char(incb);
      
      // Check if receive character is the end of message *
      if ( incb == 42 ) 
      {
         
         // Serial.println(msg);

         zzz = msg.charAt( 1 );
         
         // Serial.println(zzz);
         
         yy = zzz.toInt();
         
         // Serial.println( yy );
        
      }
   }
     
}

getStepper.ino

// Stepper
// isStepperSetup
void isStepperSetup() {

  // 2 x EasyDriver
  pinMode(dirPinR, OUTPUT);
  pinMode(stepPinR, OUTPUT);
  pinMode(dirPinL, OUTPUT);
  pinMode(stepPinL, OUTPUT);

}
// isStepper1
void isStepper1(){

   // 2 x EasyDriver - Up
   digitalWrite(dirPinR, LOW);              // Set the direction.
   delay(5);
   digitalWrite(dirPinL, LOW);              // Set the direction.
   delay(5);

   for (i = 0; i<300; i++)                 // Iterate for 1000 microsteps.
   { 
     digitalWrite(stepPinR, LOW);           // This LOW to HIGH change is what creates the
     digitalWrite(stepPinR, HIGH);          // "Rising Edge" so the easydriver knows to when to step.
     delayMicroseconds(300);                // This delay time is close to top speed.
     digitalWrite(stepPinL, LOW);           // This LOW to HIGH change is what creates the
     digitalWrite(stepPinL, HIGH);          // "Rising Edge" so the easydriver knows to when to step.
     delayMicroseconds(300);                // This delay time is close to top speed.
   } 
   
}
// isStepper2
void isStepper2(){

   // 2 x EasyDriver
   digitalWrite(dirPinR, HIGH);              // Set the direction.
   delay(5);
   digitalWrite(dirPinL, HIGH);              // Set the direction.
   delay(5);

   for (i = 0; i<1000; i++)                 // Iterate for 1000 microsteps.
   { 
     digitalWrite(stepPinR, LOW);           // This LOW to HIGH change is what creates the
     digitalWrite(stepPinR, HIGH);          // "Rising Edge" so the easydriver knows to when to step.
     delayMicroseconds(300);                // This delay time is close to top speed.
     digitalWrite(stepPinL, LOW);           // This LOW to HIGH change is what creates the
     digitalWrite(stepPinL, HIGH);          // "Rising Edge" so the easydriver knows to when to step.
     delayMicroseconds(300);                // This delay time is close to top speed.
   } 
   
}
// Switch 3
void isStepper3(){

   // Right

   // 2 x EasyDriver
   digitalWrite(dirPinR, LOW);               // Set the direction.
   delay(5);
   digitalWrite(dirPinL, HIGH);              // Set the direction.
   delay(5);

   for (i = 0; i<300; i++)                 // Iterate for 1000 microsteps.
   {
     digitalWrite(stepPinR, LOW);           // This LOW to HIGH change is what creates the
     digitalWrite(stepPinR, HIGH);          // "Rising Edge" so the easydriver knows to when to step.
     delayMicroseconds(300);                // This delay time is close to top speed.
     digitalWrite(stepPinL, LOW);           // This LOW to HIGH change is what creates the
     digitalWrite(stepPinL, HIGH);          // "Rising Edge" so the easydriver knows to when to step.
     delayMicroseconds(300);                // This delay time is close to top speed.
   }    
  
}
// Switch 4
void isStepper4(){

   // Left
   // 2 x EasyDriver
   digitalWrite(dirPinR, HIGH);             // Set the direction.
   delay(5);
   digitalWrite(dirPinL, LOW);              // Set the direction.
   delay(5);

   for (i = 0; i<300; i++)                 // Iterate for 1000 microsteps.
   {
     digitalWrite(stepPinR, LOW);           // This LOW to HIGH change is what creates the
     digitalWrite(stepPinR, HIGH);          // "Rising Edge" so the easydriver knows to when to step.
     delayMicroseconds(300);                // This delay time is close to top speed.
     digitalWrite(stepPinL, LOW);           // This LOW to HIGH change is what creates the
     digitalWrite(stepPinL, HIGH);          // "Rising Edge" so the easydriver knows to when to step.
     delayMicroseconds(300);                // This delay time is close to top speed.
   }    
    
}
// isStepperStop
void isStepperStop() {

   // 2 x EasyDriver
   digitalWrite(dirPinR, LOW);              // Set the direction.
   delay(5);
   digitalWrite(dirPinL, LOW);              // Set the direction.
   delay(5);
   digitalWrite(stepPinR, LOW);             // This LOW to HIGH change is what creates the
   digitalWrite(stepPinL, LOW);             // This LOW to HIGH change is what creates the 

}

getSwitch.ino

// Switch
// isSwitch
void isSwitch(){
  
  switch ( yy ) {
    case 1:

      // Stepper 1 - Up
      isStepper1();

      break;
    case 2:
      
      // Stepper 2 - Back
      isStepper2();
      
      break;
    case 3:

      // Stepper 3 - Right
      isStepper3();
      
      break;
    case 4:
      
      // Stepper 4 - Left
      isStepper4();
      
      break;
    case 5:
      
      // Stepper Stop
      isStepperStop();
       
      break;
    default:

      // Stepper Stop
      isStepperStop();

   }
  
}

setup.ino

// Setup
void setup() {

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

  // Pause
  delay(5);

  // EEPROM Unit ID
  isUID();
  
  // Pause
  delay(5);
  
  // Serial
  // Serial.print( "Software Version Information: ");
  // Serial.println( sver );
  // Serial.print( "Unit ID Information: ");
  // Serial.println( uid );
  
  // delay(5000);

  // 2 x EasyDriver
  isStepperSetup();

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

}

Follow Us

J. Luc Paquin – Curriculum Vitae
https://www.donluc.com/DLHackster/LucPaquinCVEngMk2020a.pdf

Web: https://www.donluc.com/
Web: http://www.jlpconsultants.com/
Web: https://www.donluc.com/DLHackster/
Web: https://www.hackster.io/neosteam-labs
Web: http://neosteamlabs.com/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Facebook: https://www.facebook.com/neosteam.labs.9/
Instagram: https://www.instagram.com/neosteamlabs/
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Twitter: https://twitter.com/labs_steam
Etsy: https://www.etsy.com/shop/NeoSteamLabs

Don Luc

Project #14: Components – Adafruit PowerBoost 500 Shield – Mk02

——

Components

——

Components

——

Components

——

Adafruit Item: 2078

Adafruit PowerBoost 500 Shield – Rechargeable 5V Power Shield

Compatible with Arduino Uno basically any Arduino-pinout-shaped Arduino as only the GND and 5V pins are used. You can stack shields on top, or stack the PowerBoost on top. The PowerBoost shield can run off of any Lithium Ion or Lithium Polymer battery but we suggest our 1200mAh capacity or 2000mAh capacity batteries, both of which fits very nicely in the empty space of the shield. Plug in the battery and recharge it via the microUSB jack. When you’re ready to go, just unplug the Arduino from USB or the wall adapter and it will automatically switch over to shield power. Use only Lipoly batteries with protection circuitry.

Follow Us

J. Luc Paquin – Curriculum Vitae
https://www.donluc.com/DLHackster/LucPaquinCVEngMk2020a.pdf

Web: https://www.donluc.com/
Web: http://www.jlpconsultants.com/
Web: https://www.donluc.com/DLHackster/
Web: https://www.hackster.io/neosteam-labs
Web: http://neosteamlabs.com/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Facebook: https://www.facebook.com/neosteam.labs.9/
Instagram: https://www.instagram.com/neosteamlabs/
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Twitter: https://twitter.com/labs_steam
Etsy: https://www.etsy.com/shop/NeoSteamLabs

Don Luc

Categories
Archives