Display
Project #29 – DFRobot – L3G4200D – Mk18
——
#DonLucElectronics #DonLuc #DFRobot #L3G4200D #HMC5883L #ADXL335 #GPS #FireBeetle2ESP32E #EEPROM #RTC #SD #Display #SparkFun #ESP32 #IoT #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant
——
——
——
——
SparkFun Tri-Axis Gyroscope – L3G4200D
This is a breakout board for the L3G4200D low-power three-axis angular rate sensor. The L3G4200D is a MEMS motion sensor and has a full scale of dps and is capable of measuring rates with a user-selectable bandwidth. These work great in gaming and virtual reality input devices, motion control with MMI, GPS navigation systems, appliances and robotics. The L3G4200D is a low-power three-axis angular rate sensor able to provide unprecedented stablility of zero rate level and sensitivity over temperature and time. It includes a sensing element and an IC interface capable of providing the measured angular rate to the external world through a digital interface.
DL2406Mk05
1 x DFRobot FireBeetle 2 ESP32-E
1 x Adafruit SHARP Memory Display
1 x Adafruit MicroSD card breakout board+
1 x MicroSD 16 GB
1 x SparkFun Triple Axis Accelerometer ADXL335
1 x SparkFun Triple Axis Magnetometer HMC5883L
1 x SparkFun Tri-Axis Gyroscope L3G4200D
1 x GPS Receiver – GP-20U7
2 x Switch
1 x 1K Ohm
1 x 1 x Lithium Ion Battery – 1000mAh
1 x Green LED
1 x USB 3.1 Cable A to C
DFRobot FireBeetle 2 ESP32-E
LED – 2
DSCK – 4
DMOSI – 16
DSS – 17
SCK – 22
MOSI – 23
MISO – 19
CS – 13
GPR – 26
GPT – 25
SCL – 21
SDA – 22
LED – 14
SWI – 3
XAC – A0
YAC – A1
ZAC – A2
VIN – +3.3V
GND – GND
——
DL2406Mk05p.ino
/****** Don Luc Electronics © ****** Software Version Information Project #29 - DFRobot - L3G4200D - Mk18 29-18 DL2406Mk05p.ino DL2406Mk05 1 x DFRobot FireBeetle 2 ESP32-E 1 x Adafruit SHARP Memory Display 1 x Adafruit MicroSD card breakout board+ 1 x MicroSD 16 GB 1 x SparkFun Triple Axis Magnetometer HMC5883L 1 x SparkFun Triple Axis Accelerometer ADXL335 1 x SparkFun Tri-Axis Gyroscope L3G4200D 1 x GPS Receiver - GP-20U7 2 x Switch 1 x 1K Ohm 1 x 1 x Lithium Ion Battery - 1000mAh 1 x Green LED 1 x USB 3.1 Cable A to C */ // Include the Library Code // EEPROM Library to Read and Write EEPROM // with Unique ID for Unit #include "EEPROM.h" // Wire #include <Wire.h> // SD Card #include "FS.h" #include "SD.h" #include "SPI.h" // SHARP Memory Display #include <Adafruit_SharpMem.h> #include <Adafruit_GFX.h> // GPS Receiver #include <TinyGPS++.h> // ESP32 Hardware Serial #include <HardwareSerial.h> // Triple Axis Magnetometer #include <HMC5883L.h> // Gyroscope #include <L3G4200D.h> // Gyroscope L3G4200D gyroscope; // Timers unsigned long timer = 0; float timeStep = 0.01; // Pitch, Roll and Yaw values float pitch = 0; float roll = 0; float yaw = 0; // Triple Axis Magnetometer HMC5883L compass; // Triple Axis Magnetometer int mX = 0; int mY = 0; int mZ = 0; // Accelerometer ADXL335 int iX = A0; int iY = A1; int iZ = A2; // Accelerometer int X = 0; int Y = 0; int Z = 0; // ESP32 HardwareSerial HardwareSerial tGPS(2); // GPS Receiver #define gpsRXPIN 26 // This one is unused and doesnt have a conection #define gpsTXPIN 25 // The TinyGPS++ object TinyGPSPlus gps; // Latitude float TargetLat; // Longitude float TargetLon; // GPS Date, Time, Speed, Altitude // GPS Date String TargetDat; // GPS Time String TargetTim; // GPS Speeds M/S String TargetSMS; // GPS Speeds Km/h String TargetSKH; // GPS Altitude Meters String TargetALT; // GPS Status String GPSSt = ""; // MicroSD Card const int chipSelect = 13; String zzzzzz = ""; // SHARP Memory Display #define SHARP_SCK 4 #define SHARP_MOSI 16 #define SHARP_SS 17 // Set the size of the display here, e.g. 144x168! Adafruit_SharpMem display(SHARP_SCK, SHARP_MOSI, SHARP_SS, 144, 168); // The currently-available SHARP Memory Display (144x168 pixels) // requires > 4K of microcontroller RAM; it WILL NOT WORK on Arduino Uno // or other <4K "classic" devices. #define BLACK 0 #define WHITE 1 // LED Green int iLEDGreen = 2; // Define LED int iLED = 14; // Switch int iSwitch = 3; // Variable for reading the Switch status int iSwitchState = 0; // EEPROM Unique ID Information #define EEPROM_SIZE 64 String uid = ""; // Software Version Information String sver = "29-18"; void loop() { // isGPS isGPS(); // Accelerometer ADXL335 isADXL335(); // Magnetometer isMagnetometer(); // Gyroscope isGyroscope(); // Read the state of the Switch value iSwitchState = digitalRead(iSwitch); // The Switch is HIGH: if (iSwitchState == HIGH) { // Display Accelerometer ADXL335 isDisplayADXL335(); } else { // Display GPS isDisplayGPS(); } // MicroSD Card isSD(); // iLED HIGH digitalWrite(iLED, HIGH ); // Delay 5 Second delay(5000); }
getAccelerometer.ino
// Accelerometer ADXL335 // ADXL335 void isADXL335() { // Accelerometer ADXL335 // Accelerometer X, Y, Z // X X = analogRead(iX); // Y Y = analogRead(iY); // Z Z = analogRead(iZ); }
getDisplay.ino
// SHARP Memory Display // SHARP Memory Display - UID void isDisplayUID() { // Text Display // Clear Display display.clearDisplay(); display.setRotation(4); display.setTextSize(3); display.setTextColor(BLACK); // Don Luc Electronics display.setCursor(0,10); display.println( "Don Luc" ); display.setTextSize(2); display.setCursor(0,40); display.println( "Electronics" ); // Version //display.setTextSize(3); display.setCursor(0,70); display.println( "Version" ); //display.setTextSize(2); display.setCursor(0,95); display.println( sver ); // EEPROM display.setCursor(0,120); display.println( "EEPROM" ); display.setCursor(0,140); display.println( uid ); // Refresh display.refresh(); delay( 100 ); } // Display Accelerometer ADXL335 void isDisplayADXL335() { // Text Display // Clear Display display.clearDisplay(); display.setRotation(4); display.setTextSize(1); display.setTextColor(BLACK); // Accelerometer X display.setCursor(0,5); display.print( "AX: " ); display.println( X ); // Accelerometer Y display.setCursor(0,20); display.print( "AY: " ); display.println( Y ); // Accelerometer Z display.setCursor(0,35); display.print( "AZ: " ); display.println( Z ); // Magnetometer X display.setCursor(0,50); display.print( "MX: " ); display.println( mX ); // Magnetometer Y display.setCursor(0,65); display.print( "MY: " ); display.println( mY ); // Magnetometer Z display.setCursor(0,80); display.print( "MZ: " ); display.println( mZ ); // Gyroscope Pitch display.setCursor(0,95); display.print( "Pitch: " ); display.println( pitch ); // Gyroscope Roll display.setCursor(0,110); display.print( "Roll: " ); display.println( roll ); // Gyroscope Yaw display.setCursor(0,125); display.print( "Yaw: " ); display.println( yaw ); // Refresh display.refresh(); delay( 100 ); } // Display GPS void isDisplayGPS() { // Text Display Date // Clear Display display.clearDisplay(); display.setRotation(4); display.setTextSize(2); display.setTextColor(BLACK); // Latitude display.setCursor(0,5); display.print( "Lat: " ); display.println( TargetLat ); // Longitude display.setCursor(0,30); display.print( "Lon: " ); display.println( TargetLon ); // GPS Date display.setCursor(0,55); display.println( TargetDat ); // GPS Time display.setCursor(0,80); display.println( TargetTim ); // GPS Speed M/S display.setCursor(0,105); display.print( TargetSMS ); display.println( " M/S" ); // GPS Altitude Meters display.setCursor(0,130); display.print( TargetALT ); display.println( " M" ); // Refresh display.refresh(); delay( 100 ); }
getEEPROM.ino
// EEPROM // isUID EEPROM Unique ID void isUID() { // Is Unit ID uid = ""; for (int x = 0; x < 7; x++) { uid = uid + char(EEPROM.read(x)); } }
getGPS.ino
// GPS Receiver // Setup GPS void isSetupGPS() { // Setup GPS tGPS.begin( 9600 , SERIAL_8N1 , gpsRXPIN , gpsTXPIN ); } // isGPS void isGPS(){ // Receives NEMA data from GPS receiver // This sketch displays information every time a new sentence is correctly encoded while ( tGPS.available() > 0) if (gps.encode( tGPS.read() )) { // GPS Vector Pointer Target displayInfo(); // GPS Date, Time, Speed, Altitude displayDTS(); } if (millis() > 5000 && gps.charsProcessed() < 10) { while(true); } } // GPS Vector Pointer Target void displayInfo(){ // Location if (gps.location.isValid()) { // Latitude TargetLat = gps.location.lat(); // Longitude TargetLon = gps.location.lng(); // GPS Status 2 GPSSt = "Yes"; } else { // GPS Status 0 GPSSt = "No"; } } // GPS Date, Time, Speed, Altitude void displayDTS(){ // Date TargetDat = ""; if (gps.date.isValid()) { // Date // Year TargetDat += String(gps.date.year(), DEC); TargetDat += "/"; // Month TargetDat += String(gps.date.month(), DEC); TargetDat += "/"; // Day TargetDat += String(gps.date.day(), DEC); } // Time TargetTim = ""; if (gps.time.isValid()) { // Time // Hour TargetTim += String(gps.time.hour(), DEC); TargetTim += ":"; // Minute TargetTim += String(gps.time.minute(), DEC); TargetTim += ":"; // Secound TargetTim += String(gps.time.second(), DEC); } // Speed TargetSMS = ""; TargetSKH = ""; if (gps.speed.isValid()) { // Speed // M/S int x = gps.speed.mps(); TargetSMS = String( x, DEC); // Km/h int y = gps.speed.kmph(); TargetSKH = String( y, DEC); } // Altitude TargetALT = ""; if (gps.altitude.isValid()) { // Altitude // Meters int z = gps.altitude.meters(); TargetALT = String( z, DEC); } }
getGyroscope.ino
// L3G4200D Triple Axis Gyroscope // Setup Gyroscope void isSetupGyroscope() { // Setup Gyroscope // Set scale 2000 dps and 400HZ Output data rate (cut-off 50) while(!gyroscope.begin(L3G4200D_SCALE_2000DPS, L3G4200D_DATARATE_400HZ_50)) { // Could not find a valid L3G4200D sensor, check wiring! delay(500); } // Calibrate gyroscope. The calibration must be at rest. // If you don't want calibrate, comment this line. gyroscope.calibrate(100); } // L3G4200D Gyroscope void isGyroscope(){ // Timer timer = millis(); // Read normalized values Vector norm = gyroscope.readNormalize(); // Calculate Pitch, Roll and Yaw pitch = pitch + norm.YAxis * timeStep; roll = roll + norm.XAxis * timeStep; yaw = yaw + norm.ZAxis * timeStep; }
getMagnetometer.ino
// Magnetometer // Setup Magnetometer void isSetupMagnetometer(){ // Magnetometer Serial // Initialize HMC5883L while (!compass.begin()) { delay(500); } // Set measurement range // +/- 1.30 Ga: HMC5883L_RANGE_1_3GA (default) compass.setRange(HMC5883L_RANGE_1_3GA); // Set measurement mode // Continuous-Measurement: HMC5883L_CONTINOUS (default) compass.setMeasurementMode(HMC5883L_CONTINOUS); // Set data rate // 15.00Hz: HMC5883L_DATARATE_15HZ (default) compass.setDataRate(HMC5883L_DATARATE_15HZ); // Set number of samples averaged // 1 sample: HMC5883L_SAMPLES_1 (default) compass.setSamples(HMC5883L_SAMPLES_1); } // Magnetometer void isMagnetometer(){ // Magnetometer Vector Norm Vector norm = compass.readNormalize(); // Vector X, Y, Z // Magnetometer X Normalize mX = norm.XAxis; // Magnetometer Y Normalize mY = norm.YAxis; // Magnetometer Z Normalize mZ = norm.ZAxis; }
getSD.ino
// MicroSD Card // MicroSD Setup void isSetupSD() { // MicroSD Card pinMode( chipSelect , OUTPUT ); if(!SD.begin( chipSelect )){ ; return; } uint8_t cardType = SD.cardType(); // CARD NONE if(cardType == CARD_NONE){ ; return; } // SD Card Type if(cardType == CARD_MMC){ ; } else if(cardType == CARD_SD){ ; } else if(cardType == CARD_SDHC){ ; } else { ; } // Size uint64_t cardSize = SD.cardSize() / (1024 * 1024); } // MicroSD Card void isSD() { zzzzzz = ""; // DFR|EEPROM Unique ID|Version|Date|Time| //Accelerometer X|Accelerometer Y|Accelerometer Z //Magnetometer X|Magnetometer Y|Magnetometer Z //Gyroscope Pitch|Gyroscope Roll|Gyroscope Yaw //|GPS|Latitude|Longitude|GPS Date|GPS Time|GPS Speed M/S|GPS Altitude|*\r zzzzzz = "DFR|" + uid + "|" + sver + "|" + String(X) + "|" + String(Y) + "|" + String(Z) + "|" + String(mX) + "|" + String(mY) + "|" + String(mZ) + "|" + String(pitch) + "|" + String(roll) + "|" + String(yaw) + "|" + String(GPSSt) + "|" + String(TargetLat) + "|" + String(TargetLon) + "|" + String(TargetDat) + "|" + String(TargetTim) + "|" + String(TargetSMS) + "|" + String(TargetALT)+ "|*\r"; // msg + 1 char msg[zzzzzz.length() + 1]; zzzzzz.toCharArray(msg, zzzzzz.length() + 1); // Append File appendFile(SD, "/dfrdata.txt", msg ); } // List Dir void listDir(fs::FS &fs, const char * dirname, uint8_t levels){ // List Dir dirname; File root = fs.open(dirname); if(!root){ return; } if(!root.isDirectory()){ return; } File file = root.openNextFile(); while(file){ if(file.isDirectory()){ file.name(); if(levels){ listDir(fs, file.name(), levels -1); } } else { file.name(); file.size(); } file = root.openNextFile(); } } // Write File void writeFile(fs::FS &fs, const char * path, const char * message){ // Write File path; File file = fs.open(path, FILE_WRITE); if(!file){ return; } if(file.print(message)){ ; } else { ; } file.close(); } // Append File void appendFile(fs::FS &fs, const char * path, const char * message){ // Append File path; File file = fs.open(path, FILE_APPEND); if(!file){ return; } if(file.print(message)){ ; } else { ; } file.close(); }
setup.ino
// Setup void setup() { // Give display time to power on delay(100); // EEPROM Size EEPROM.begin(EEPROM_SIZE); // EEPROM Unique ID isUID(); // Give display delay(100); // Set up I2C bus Wire.begin(); // Give display delay(100); //MicroSD Card isSetupSD(); // SHARP Display Start & Clear the Display display.begin(); // Clear Display display.clearDisplay(); // Delay delay( 100 ); // GPS Receiver // Setup GPS isSetupGPS(); // Delay delay( 100 ); // Setup Triple Axis Magnetometer isSetupMagnetometer(); // L3G4200D Gyroscope isSetupGyroscope(); // Delay delay( 100 ); // Initialize digital pin iLED as an output pinMode(iLED, OUTPUT); // Outputting high, the LED turns on digitalWrite(iLED, HIGH); // Initialize the LED Green pinMode(iLEDGreen, OUTPUT); // iLEDGreen HIGH digitalWrite(iLEDGreen, HIGH ); // Initialize the Switch pinMode(iSwitch, INPUT); // Don Luc Electronics // Version // EEPROM isDisplayUID(); // Delay 5 Second delay( 5000 ); }
——
People can contact us: https://www.donluc.com/?page_id=1927
Teacher, Instructor, E-Mentor, R&D and Consulting
- Programming Language
- Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi, Arm, Silicon Labs, Espressif, Etc…)
- IoT
- Wireless (Radio Frequency, Bluetooth, WiFi, Etc…)
- Robotics
- Automation
- Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
- Unmanned Vehicles Terrestrial and Marine
- Machine Learning
- Artificial Intelligence (AI)
- RTOS
- Sensors, eHealth Sensors, Biosensor, and Biometric
- Research & Development (R & D)
- Consulting
Follow Us
Luc Paquin – Curriculum Vitae – 2024
https://www.donluc.com/luc/
Web: https://www.donluc.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/@thesass2063
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/
LinkedIn: https://www.linkedin.com/in/jlucpaquin/
Don Luc
Project #29 – DFRobot – HMC5883L – Mk17
——
#DonLucElectronics #DonLuc #DFRobot #HMC5883L #ADXL335 #GPS #FireBeetle2ESP32E #EEPROM #RTC #SD #Display #SparkFun #ESP32 #IoT #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant
——
——
——
——
SparkFun Triple Axis Magnetometer Breakout – HMC5883L
This is a breakout board for Honeywell’s HMC5883L, a 3-axis digital compass. Communication with the HMC5883L is simple and all done through an I2C interface. There is no on-board regulator, so a regulated voltage of 2.16-3.6VDC should be supplied. The breakout board includes the HMC5883L sensor and all filtering capacitors as shown. The power and 2-wire interface pins are all broken out to a 0.1 inch pitch header.
DL2406Mk04
1 x DFRobot FireBeetle 2 ESP32-E
1 x Adafruit SHARP Memory Display
1 x Adafruit MicroSD card breakout board+
1 x MicroSD 16 GB
1 x SparkFun Triple Axis Accelerometer ADXL335
1 x SparkFun Triple Axis Magnetometer HMC5883L
1 x GPS Receiver – GP-20U7
2 x Switch
1 x 1K Ohm
1 x 1 x Lithium Ion Battery – 1000mAh
1 x Green LED
1 x USB 3.1 Cable A to C
DFRobot FireBeetle 2 ESP32-E
LED – 2
DSCK – 4
DMOSI – 16
DSS – 17
SCK – 22
MOSI – 23
MISO – 19
CS – 13
GPR – 26
GPT – 25
SCL – 21
SDA – 22
LED – 14
SWI – 3
XAC – A0
YAC – A1
ZAC – A2
VIN – +3.3V
GND – GND
——
DL2406Mk04p.ino
/****** Don Luc Electronics © ****** Software Version Information Project #29 - DFRobot - HMC5883L - Mk17 29-17 DL2406Mk04p.ino DL2406Mk04 1 x DFRobot FireBeetle 2 ESP32-E 1 x Adafruit SHARP Memory Display 1 x Adafruit MicroSD card breakout board+ 1 x MicroSD 16 GB 1 x SparkFun Triple Axis Magnetometer HMC5883L 1 x SparkFun Triple Axis Accelerometer ADXL335 1 x GPS Receiver - GP-20U7 2 x Switch 1 x 1K Ohm 1 x 1 x Lithium Ion Battery - 1000mAh 1 x Green LED 1 x USB 3.1 Cable A to C */ // Include the Library Code // EEPROM Library to Read and Write EEPROM // with Unique ID for Unit #include "EEPROM.h" // Wire #include <Wire.h> // SD Card #include "FS.h" #include "SD.h" #include "SPI.h" // SHARP Memory Display #include <Adafruit_SharpMem.h> #include <Adafruit_GFX.h> // GPS Receiver #include <TinyGPS++.h> // ESP32 Hardware Serial #include <HardwareSerial.h> // Triple Axis Magnetometer #include <HMC5883L.h> // Triple Axis Magnetometer HMC5883L compass; // Triple Axis Magnetometer int mX = 0; int mY = 0; int mZ = 0; // Accelerometer ADXL335 int iX = A0; int iY = A1; int iZ = A2; // Accelerometer int X = 0; int Y = 0; int Z = 0; // ESP32 HardwareSerial HardwareSerial tGPS(2); // GPS Receiver #define gpsRXPIN 26 // This one is unused and doesnt have a conection #define gpsTXPIN 25 // The TinyGPS++ object TinyGPSPlus gps; // Latitude float TargetLat; // Longitude float TargetLon; // GPS Date, Time, Speed, Altitude // GPS Date String TargetDat; // GPS Time String TargetTim; // GPS Speeds M/S String TargetSMS; // GPS Speeds Km/h String TargetSKH; // GPS Altitude Meters String TargetALT; // GPS Status String GPSSt = ""; // MicroSD Card const int chipSelect = 13; String zzzzzz = ""; // SHARP Memory Display #define SHARP_SCK 4 #define SHARP_MOSI 16 #define SHARP_SS 17 // Set the size of the display here, e.g. 144x168! Adafruit_SharpMem display(SHARP_SCK, SHARP_MOSI, SHARP_SS, 144, 168); // The currently-available SHARP Memory Display (144x168 pixels) // requires > 4K of microcontroller RAM; it WILL NOT WORK on Arduino Uno // or other <4K "classic" devices. #define BLACK 0 #define WHITE 1 // LED Green int iLEDGreen = 2; // Define LED int iLED = 14; // Switch int iSwitch = 3; // Variable for reading the Switch status int iSwitchState = 0; // EEPROM Unique ID Information #define EEPROM_SIZE 64 String uid = ""; // Software Version Information String sver = "29-17"; void loop() { // isGPS isGPS(); // Accelerometer ADXL335 isADXL335(); // Magnetometer isMagnetometer(); // Read the state of the Switch value iSwitchState = digitalRead(iSwitch); // The Switch is HIGH: if (iSwitchState == HIGH) { // Display Accelerometer ADXL335 isDisplayADXL335(); } else { // Display GPS isDisplayGPS(); } // MicroSD Card isSD(); // iLED HIGH digitalWrite(iLED, HIGH ); // Delay 5 Second delay(5000); }
getAccelerometer.ino
// Accelerometer ADXL335 // ADXL335 void isADXL335() { // Accelerometer ADXL335 // Accelerometer X, Y, Z // X X = analogRead(iX); // Y Y = analogRead(iY); // Z Z = analogRead(iZ); }
getDisplay.ino
// SHARP Memory Display // SHARP Memory Display - UID void isDisplayUID() { // Text Display // Clear Display display.clearDisplay(); display.setRotation(4); display.setTextSize(3); display.setTextColor(BLACK); // Don Luc Electronics display.setCursor(0,10); display.println( "Don Luc" ); display.setTextSize(2); display.setCursor(0,40); display.println( "Electronics" ); // Version //display.setTextSize(3); display.setCursor(0,70); display.println( "Version" ); //display.setTextSize(2); display.setCursor(0,95); display.println( sver ); // EEPROM display.setCursor(0,120); display.println( "EEPROM" ); display.setCursor(0,140); display.println( uid ); // Refresh display.refresh(); delay( 100 ); } // Display Accelerometer ADXL335 void isDisplayADXL335() { // Text Display // Clear Display display.clearDisplay(); display.setRotation(4); display.setTextSize(2); display.setTextColor(BLACK); // Accelerometer X display.setCursor(0,5); display.print( "AX: " ); display.println( X ); // Accelerometer Y display.setCursor(0,30); display.print( "AY: " ); display.println( Y ); // Accelerometer Z display.setCursor(0,55); display.print( "AZ: " ); display.println( Z ); // Magnetometer X display.setCursor(0,80); display.print( "MX: " ); display.println( mX ); // Magnetometer Y display.setCursor(0,105); display.print( "MY: " ); display.println( mY ); // Magnetometer Z display.setCursor(0,130); display.print( "MZ: " ); display.println( mZ ); // Refresh display.refresh(); delay( 100 ); } // Display GPS void isDisplayGPS() { // Text Display Date // Clear Display display.clearDisplay(); display.setRotation(4); display.setTextSize(2); display.setTextColor(BLACK); // Latitude display.setCursor(0,5); display.print( "Lat: " ); display.println( TargetLat ); // Longitude display.setCursor(0,30); display.print( "Lon: " ); display.println( TargetLon ); // GPS Date display.setCursor(0,55); display.println( TargetDat ); // GPS Time display.setCursor(0,80); display.println( TargetTim ); // GPS Speed M/S display.setCursor(0,105); display.print( TargetSMS ); display.println( " M/S" ); // GPS Altitude Meters display.setCursor(0,130); display.print( TargetALT ); display.println( " M" ); // Refresh display.refresh(); delay( 100 ); }
getEEPROM.ino
// EEPROM // isUID EEPROM Unique ID void isUID() { // Is Unit ID uid = ""; for (int x = 0; x < 7; x++) { uid = uid + char(EEPROM.read(x)); } }
getGPS.ino
// GPS Receiver // Setup GPS void isSetupGPS() { // Setup GPS tGPS.begin( 9600 , SERIAL_8N1 , gpsRXPIN , gpsTXPIN ); } // isGPS void isGPS(){ // Receives NEMA data from GPS receiver // This sketch displays information every time a new sentence is correctly encoded while ( tGPS.available() > 0) if (gps.encode( tGPS.read() )) { // GPS Vector Pointer Target displayInfo(); // GPS Date, Time, Speed, Altitude displayDTS(); } if (millis() > 5000 && gps.charsProcessed() < 10) { while(true); } } // GPS Vector Pointer Target void displayInfo(){ // Location if (gps.location.isValid()) { // Latitude TargetLat = gps.location.lat(); // Longitude TargetLon = gps.location.lng(); // GPS Status 2 GPSSt = "Yes"; } else { // GPS Status 0 GPSSt = "No"; } } // GPS Date, Time, Speed, Altitude void displayDTS(){ // Date TargetDat = ""; if (gps.date.isValid()) { // Date // Year TargetDat += String(gps.date.year(), DEC); TargetDat += "/"; // Month TargetDat += String(gps.date.month(), DEC); TargetDat += "/"; // Day TargetDat += String(gps.date.day(), DEC); } // Time TargetTim = ""; if (gps.time.isValid()) { // Time // Hour TargetTim += String(gps.time.hour(), DEC); TargetTim += ":"; // Minute TargetTim += String(gps.time.minute(), DEC); TargetTim += ":"; // Secound TargetTim += String(gps.time.second(), DEC); } // Speed TargetSMS = ""; TargetSKH = ""; if (gps.speed.isValid()) { // Speed // M/S int x = gps.speed.mps(); TargetSMS = String( x, DEC); // Km/h int y = gps.speed.kmph(); TargetSKH = String( y, DEC); } // Altitude TargetALT = ""; if (gps.altitude.isValid()) { // Altitude // Meters int z = gps.altitude.meters(); TargetALT = String( z, DEC); } }
getMagnetometer.ino
// Magnetometer // Setup Magnetometer void isSetupMagnetometer(){ // Magnetometer Serial // Initialize HMC5883L while (!compass.begin()) { delay(500); } // Set measurement range // +/- 1.30 Ga: HMC5883L_RANGE_1_3GA (default) compass.setRange(HMC5883L_RANGE_1_3GA); // Set measurement mode // Continuous-Measurement: HMC5883L_CONTINOUS (default) compass.setMeasurementMode(HMC5883L_CONTINOUS); // Set data rate // 15.00Hz: HMC5883L_DATARATE_15HZ (default) compass.setDataRate(HMC5883L_DATARATE_15HZ); // Set number of samples averaged // 1 sample: HMC5883L_SAMPLES_1 (default) compass.setSamples(HMC5883L_SAMPLES_1); } // Magnetometer void isMagnetometer(){ // Magnetometer Vector Norm Vector norm = compass.readNormalize(); // Vector X, Y, Z // Magnetometer X Normalize mX = norm.XAxis; // Magnetometer Y Normalize mY = norm.YAxis; // Magnetometer Z Normalize mZ = norm.ZAxis; }
getSD.ino
// MicroSD Card // MicroSD Setup void isSetupSD() { // MicroSD Card pinMode( chipSelect , OUTPUT ); if(!SD.begin( chipSelect )){ ; return; } uint8_t cardType = SD.cardType(); // CARD NONE if(cardType == CARD_NONE){ ; return; } // SD Card Type if(cardType == CARD_MMC){ ; } else if(cardType == CARD_SD){ ; } else if(cardType == CARD_SDHC){ ; } else { ; } // Size uint64_t cardSize = SD.cardSize() / (1024 * 1024); } // MicroSD Card void isSD() { zzzzzz = ""; // DFR|EEPROM Unique ID|Version|Date|Time| //Accelerometer X|Accelerometer Y|Accelerometer Z //Magnetometer X|Magnetometer Y|Magnetometer Z //|GPS|Latitude|Longitude|GPS Date|GPS Time|GPS Speed M/S|GPS Altitude|*\r zzzzzz = "DFR|" + uid + "|" + sver + "|" + String(X) + "|" + String(Y) + "|" + String(Z) + "|" + String(mX) + "|" + String(mY) + "|" + String(mZ) + "|" + String(GPSSt) + "|" + String(TargetLat) + "|" + String(TargetLon) + "|" + String(TargetDat) + "|" + String(TargetTim) + "|" + String(TargetSMS) + "|" + String(TargetALT)+ "|*\r"; // msg + 1 char msg[zzzzzz.length() + 1]; zzzzzz.toCharArray(msg, zzzzzz.length() + 1); // Append File appendFile(SD, "/dfrdata.txt", msg ); } // List Dir void listDir(fs::FS &fs, const char * dirname, uint8_t levels){ // List Dir dirname; File root = fs.open(dirname); if(!root){ return; } if(!root.isDirectory()){ return; } File file = root.openNextFile(); while(file){ if(file.isDirectory()){ file.name(); if(levels){ listDir(fs, file.name(), levels -1); } } else { file.name(); file.size(); } file = root.openNextFile(); } } // Write File void writeFile(fs::FS &fs, const char * path, const char * message){ // Write File path; File file = fs.open(path, FILE_WRITE); if(!file){ return; } if(file.print(message)){ ; } else { ; } file.close(); } // Append File void appendFile(fs::FS &fs, const char * path, const char * message){ // Append File path; File file = fs.open(path, FILE_APPEND); if(!file){ return; } if(file.print(message)){ ; } else { ; } file.close(); }
setup.ino
// Setup void setup() { // Give display time to power on delay(100); // EEPROM Size EEPROM.begin(EEPROM_SIZE); // EEPROM Unique ID isUID(); // Give display delay(100); // Set up I2C bus Wire.begin(); // Give display delay(100); //MicroSD Card isSetupSD(); // SHARP Display Start & Clear the Display display.begin(); // Clear Display display.clearDisplay(); // Delay delay( 100 ); // GPS Receiver // Setup GPS isSetupGPS(); // Delay delay( 100 ); // Setup Triple Axis Magnetometer isSetupMagnetometer(); // Delay delay( 100 ); // Initialize digital pin iLED as an output pinMode(iLED, OUTPUT); // Outputting high, the LED turns on digitalWrite(iLED, HIGH); // Initialize the LED Green pinMode(iLEDGreen, OUTPUT); // iLEDGreen HIGH digitalWrite(iLEDGreen, HIGH ); // Initialize the Switch pinMode(iSwitch, INPUT); // Don Luc Electronics // Version // EEPROM isDisplayUID(); // Delay 5 Second delay( 5000 ); }
——
People can contact us: https://www.donluc.com/?page_id=1927
Teacher, Instructor, E-Mentor, R&D and Consulting
- Programming Language
- Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi, Arm, Silicon Labs, Espressif, Etc…)
- IoT
- Wireless (Radio Frequency, Bluetooth, WiFi, Etc…)
- Robotics
- Automation
- Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
- Unmanned Vehicles Terrestrial and Marine
- Machine Learning
- Artificial Intelligence (AI)
- RTOS
- Sensors, eHealth Sensors, Biosensor, and Biometric
- Research & Development (R & D)
- Consulting
Follow Us
Luc Paquin – Curriculum Vitae – 2024
https://www.donluc.com/luc/
Web: https://www.donluc.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/@thesass2063
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/
LinkedIn: https://www.linkedin.com/in/jlucpaquin/
Don Luc
Project #29 – DFRobot – ADXL335 – Mk16
——
#DonLucElectronics #DonLuc #DFRobot #ADXL335 #GPS #FireBeetle2ESP32E #EEPROM #RTC #SD #Display #Adafruit #SparkFun #ESP32 #IoT #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant
——
——
——
——
SparkFun Triple Axis Accelerometer Breakout – ADXL335
Breakout board for the 3 axis ADXL335 from Analog Devices. This is the latest in a long, proven line of analog sensors – the holy grail of accelerometers. The ADXL335 is a triple axis MEMS accelerometer with extremely low noise and power consumption only 320 uA. The sensor has a full sensing range of +/- 3g. There is no on-board regulation, provided power should be between 1.8 and 3.6 Volt. Board comes fully assembled and tested with external components installed. The included 0.1 uF capacitors set the bandwidth of each axis to 50 Hz.
DL2406Mk03
1 x DFRobot FireBeetle 2 ESP32-E
1 x Adafruit SHARP Memory Display
1 x Adafruit MicroSD card breakout board+
1 x MicroSD 16 GB
1 x Adafruit DS3231 Precision RTC FeatherWing – RTC
1 x Battery CR1220
1 x SparkFun Triple Axis Accelerometer ADXL335
1 x GPS Receiver – GP-20U7
2 x Switch
1 x 1K Ohm
1 x 1 x Lithium Ion Battery – 1000mAh
1 x Green LED
1 x USB 3.1 Cable A to C
DFRobot FireBeetle 2 ESP32-E
LED – 2
DSCK – 4
DMOSI – 16
DSS – 17
SCK – 22
MOSI – 23
MISO – 19
CS – 13
GPR – 26
GPT – 25
SCL – 21
SDA – 22
LED – 14
SWI – 3
XAC – A0
YAC – A1
ZAC – A2
VIN – +3.3V
GND – GND
——
DL2406Mk03p.ino
/****** Don Luc Electronics © ****** Software Version Information Project #29 - DFRobot - ADXL335 - Mk16 29-16 DL2406Mk03p.ino DL2406Mk03 1 x DFRobot FireBeetle 2 ESP32-E 1 x Adafruit SHARP Memory Display 1 x Adafruit MicroSD card breakout board+ 1 x MicroSD 16 GB 1 x Adafruit DS3231 Precision RTC FeatherWing - RTC 1 x Battery CR1220 1 x SparkFun Triple Axis Accelerometer ADXL335 1 x GPS Receiver - GP-20U7 2 x Switch 1 x 1K Ohm 1 x 1 x Lithium Ion Battery - 1000mAh 1 x Green LED 1 x USB 3.1 Cable A to C */ // Include the Library Code // EEPROM Library to Read and Write EEPROM // with Unique ID for Unit #include "EEPROM.h" // Wire #include <Wire.h> // DS3231 RTC Date and Time #include <RTClib.h> // SD Card #include "FS.h" #include "SD.h" #include "SPI.h" // SHARP Memory Display #include <Adafruit_SharpMem.h> #include <Adafruit_GFX.h> // GPS Receiver #include <TinyGPS++.h> // ESP32 Hardware Serial #include <HardwareSerial.h> // Accelerometer ADXL335 int iX = A0; int iY = A1; int iZ = A2; // Accelerometer int X = 0; int Y = 0; int Z = 0; // ESP32 HardwareSerial HardwareSerial tGPS(2); // GPS Receiver #define gpsRXPIN 26 // This one is unused and doesnt have a conection #define gpsTXPIN 25 // The TinyGPS++ object TinyGPSPlus gps; // Latitude float TargetLat; // Longitude float TargetLon; // GPS Date, Time, Speed, Altitude // GPS Date String TargetDat; // GPS Time String TargetTim; // GPS Speeds M/S String TargetSMS; // GPS Speeds Km/h String TargetSKH; // GPS Altitude Meters String TargetALT; // GPS Status String GPSSt = ""; // DS3231 RTC Date and Time RTC_DS3231 rtc; String sDate; String sTime; // MicroSD Card const int chipSelect = 13; String zzzzzz = ""; // SHARP Memory Display #define SHARP_SCK 4 #define SHARP_MOSI 16 #define SHARP_SS 17 // Set the size of the display here, e.g. 144x168! Adafruit_SharpMem display(SHARP_SCK, SHARP_MOSI, SHARP_SS, 144, 168); // The currently-available SHARP Memory Display (144x168 pixels) // requires > 4K of microcontroller RAM; it WILL NOT WORK on Arduino Uno // or other <4K "classic" devices. #define BLACK 0 #define WHITE 1 // LED Green int iLEDGreen = 2; // Define LED int iLED = 14; // Switch int iSwitch = 3; // Variable for reading the Switch status int iSwitchState = 0; // EEPROM Unique ID Information #define EEPROM_SIZE 64 String uid = ""; // Software Version Information String sver = "29-16"; void loop() { // DS3231 RTC Date and Time isRTC(); // isGPS isGPS(); // Accelerometer ADXL335 isADXL335(); // Read the state of the Switch value iSwitchState = digitalRead(iSwitch); // The Switch is HIGH: if (iSwitchState == HIGH) { // Display Accelerometer ADXL335 isDisplayADXL335(); } else { // Display GPS isDisplayGPS(); } // MicroSD Card isSD(); // iLED HIGH digitalWrite(iLED, HIGH ); // Delay 5 Second delay(5000); }
getAccelerometer.ino
// Accelerometer ADXL335 // ADXL335 void isADXL335() { // Accelerometer ADXL335 // Accelerometer X, Y, Z // X X = analogRead(iX); // Y Y = analogRead(iY); // Z Z = analogRead(iZ); }
getDisplay.ino
// SHARP Memory Display // SHARP Memory Display - UID void isDisplayUID() { // Text Display // Clear Display display.clearDisplay(); display.setRotation(4); display.setTextSize(3); display.setTextColor(BLACK); // Don Luc Electronics display.setCursor(0,10); display.println( "Don Luc" ); display.setTextSize(2); display.setCursor(0,40); display.println( "Electronics" ); // Version //display.setTextSize(3); display.setCursor(0,70); display.println( "Version" ); //display.setTextSize(2); display.setCursor(0,95); display.println( sver ); // EEPROM display.setCursor(0,120); display.println( "EEPROM" ); display.setCursor(0,140); display.println( uid ); // Refresh display.refresh(); delay( 100 ); } // Display Accelerometer ADXL335 void isDisplayADXL335() { // Text Display // Clear Display display.clearDisplay(); display.setRotation(4); display.setTextSize(2); display.setTextColor(BLACK); // Date display.setCursor(0,5); display.println( sDate ); // Time display.setCursor(0,30); display.println( sTime ); // X display.setCursor(0,55); display.print( "X: " ); display.println( X ); // Y display.setCursor(0,80); display.print( "Y: " ); display.println( Y ); // Z display.setCursor(0,105); display.print( "Z: " ); display.println( Z ); // Refresh display.refresh(); delay( 100 ); } // Display GPS void isDisplayGPS() { // Text Display Date // Clear Display display.clearDisplay(); display.setRotation(4); display.setTextSize(2); display.setTextColor(BLACK); // Latitude display.setCursor(0,5); display.print( "Lat: " ); display.println( TargetLat ); // Longitude display.setCursor(0,30); display.print( "Lon: " ); display.println( TargetLon ); // GPS Date display.setCursor(0,55); display.println( TargetDat ); // GPS Time display.setCursor(0,80); display.println( TargetTim ); // GPS Speed M/S display.setCursor(0,105); display.print( TargetSMS ); display.println( " M/S" ); // GPS Altitude Meters display.setCursor(0,130); display.print( TargetALT ); display.println( " M" ); // Refresh display.refresh(); delay( 100 ); }
getEEPROM.ino
// EEPROM // isUID EEPROM Unique ID void isUID() { // Is Unit ID uid = ""; for (int x = 0; x < 7; x++) { uid = uid + char(EEPROM.read(x)); } }
getGPS.ino
// GPS Receiver // Setup GPS void isSetupGPS() { // Setup GPS tGPS.begin( 9600 , SERIAL_8N1 , gpsRXPIN , gpsTXPIN ); } // isGPS void isGPS(){ // Receives NEMA data from GPS receiver // This sketch displays information every time a new sentence is correctly encoded while ( tGPS.available() > 0) if (gps.encode( tGPS.read() )) { // GPS Vector Pointer Target displayInfo(); // GPS Date, Time, Speed, Altitude displayDTS(); } if (millis() > 5000 && gps.charsProcessed() < 10) { while(true); } } // GPS Vector Pointer Target void displayInfo(){ // Location if (gps.location.isValid()) { // Latitude TargetLat = gps.location.lat(); // Longitude TargetLon = gps.location.lng(); // GPS Status 2 GPSSt = "Yes"; } else { // GPS Status 0 GPSSt = "No"; } } // GPS Date, Time, Speed, Altitude void displayDTS(){ // Date TargetDat = ""; if (gps.date.isValid()) { // Date // Year TargetDat += String(gps.date.year(), DEC); TargetDat += "/"; // Month TargetDat += String(gps.date.month(), DEC); TargetDat += "/"; // Day TargetDat += String(gps.date.day(), DEC); } // Time TargetTim = ""; if (gps.time.isValid()) { // Time // Hour TargetTim += String(gps.time.hour(), DEC); TargetTim += ":"; // Minute TargetTim += String(gps.time.minute(), DEC); TargetTim += ":"; // Secound TargetTim += String(gps.time.second(), DEC); } // Speed TargetSMS = ""; TargetSKH = ""; if (gps.speed.isValid()) { // Speed // M/S int x = gps.speed.mps(); TargetSMS = String( x, DEC); // Km/h int y = gps.speed.kmph(); TargetSKH = String( y, DEC); } // Altitude TargetALT = ""; if (gps.altitude.isValid()) { // Altitude // Meters int z = gps.altitude.meters(); TargetALT = String( z, DEC); } }
getRTC.ino
// DS3231 RTC Date and Time // Setup DS3231 RTC void isSetupRTC() { if (! rtc.begin()) { while (1); } if (rtc.lostPower()) { // Following line sets the RTC to the date & time this sketch was compiled rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); // This line sets the RTC with an explicit date & time, for example to set // January 21, 2014 at 3am you would call: // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0)); } } // DS3231 RTC Date and Time void isRTC(){ // Date and Time sDate = ""; sTime = ""; // Date Time DateTime now = rtc.now(); // sData sDate += String(now.year(), DEC); sDate += "/"; sDate += String(now.month(), DEC); sDate += "/"; sDate += String(now.day(), DEC); // sTime sTime += String(now.hour(), DEC); sTime += ":"; sTime += String(now.minute(), DEC); sTime += ":"; sTime += String(now.second(), DEC); }
getSD.ino
// MicroSD Card // MicroSD Setup void isSetupSD() { // MicroSD Card pinMode( chipSelect , OUTPUT ); if(!SD.begin( chipSelect )){ ; return; } uint8_t cardType = SD.cardType(); // CARD NONE if(cardType == CARD_NONE){ ; return; } // SD Card Type if(cardType == CARD_MMC){ ; } else if(cardType == CARD_SD){ ; } else if(cardType == CARD_SDHC){ ; } else { ; } // Size uint64_t cardSize = SD.cardSize() / (1024 * 1024); } // MicroSD Card void isSD() { zzzzzz = ""; // DFR|EEPROM Unique ID|Version|Date|Time| //Accelerometer X|Accelerometer Y|Accelerometer Z //|GPS|Latitude|Longitude|GPS Date|GPS Time|GPS Speed M/S|GPS Altitude|*\r zzzzzz = "DFR|" + uid + "|" + sver + "|" + String(sDate) + "|" + String(sTime) + "|" + String(X) + "|" + String(Y) + "|" + String(Z) + "|" + String(GPSSt) + "|" + String(TargetLat) + "|" + String(TargetLon) + "|" + String(TargetDat) + "|" + String(TargetTim) + "|" + String(TargetSMS) + "|" + String(TargetALT)+ "|*\r"; // msg + 1 char msg[zzzzzz.length() + 1]; zzzzzz.toCharArray(msg, zzzzzz.length() + 1); // Append File appendFile(SD, "/dfrdata.txt", msg ); } // List Dir void listDir(fs::FS &fs, const char * dirname, uint8_t levels){ // List Dir dirname; File root = fs.open(dirname); if(!root){ return; } if(!root.isDirectory()){ return; } File file = root.openNextFile(); while(file){ if(file.isDirectory()){ file.name(); if(levels){ listDir(fs, file.name(), levels -1); } } else { file.name(); file.size(); } file = root.openNextFile(); } } // Write File void writeFile(fs::FS &fs, const char * path, const char * message){ // Write File path; File file = fs.open(path, FILE_WRITE); if(!file){ return; } if(file.print(message)){ ; } else { ; } file.close(); } // Append File void appendFile(fs::FS &fs, const char * path, const char * message){ // Append File path; File file = fs.open(path, FILE_APPEND); if(!file){ return; } if(file.print(message)){ ; } else { ; } file.close(); }
setup.ino
// Setup void setup() { // Give display time to power on delay(100); // EEPROM Size EEPROM.begin(EEPROM_SIZE); // EEPROM Unique ID isUID(); // Give display delay(100); // Set up I2C bus Wire.begin(); // Give display delay(100); // Setup DS3231 RTC isSetupRTC(); //MicroSD Card isSetupSD(); // SHARP Display Start & Clear the Display display.begin(); // Clear Display display.clearDisplay(); // Delay delay( 100 ); // GPS Receiver // Setup GPS isSetupGPS(); // Initialize digital pin iLED as an output pinMode(iLED, OUTPUT); // Outputting high, the LED turns on digitalWrite(iLED, HIGH); // Initialize the LED Green pinMode(iLEDGreen, OUTPUT); // iLEDGreen HIGH digitalWrite(iLEDGreen, HIGH ); // Initialize the Switch pinMode(iSwitch, INPUT); // Don Luc Electronics // Version // EEPROM isDisplayUID(); // Delay 5 Second delay( 5000 ); }
——
People can contact us: https://www.donluc.com/?page_id=1927
Teacher, Instructor, E-Mentor, R&D and Consulting
- Programming Language
- Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi, Arm, Silicon Labs, Espressif, Etc…)
- IoT
- Wireless (Radio Frequency, Bluetooth, WiFi, Etc…)
- Robotics
- Automation
- Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
- Unmanned Vehicles Terrestrial and Marine
- Machine Learning
- Artificial Intelligence (AI)
- RTOS
- Sensors, eHealth Sensors, Biosensor, and Biometric
- Research & Development (R & D)
- Consulting
Follow Us
Luc Paquin – Curriculum Vitae – 2024
https://www.donluc.com/luc/
Web: https://www.donluc.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/@thesass2063
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/
LinkedIn: https://www.linkedin.com/in/jlucpaquin/
Don Luc
Project #29 – DFRobot – GPS Receiver – Mk15
——
#DonLucElectronics #DonLuc #DFRobot #GPS #BME280 #CCS811 #FireBeetle2ESP32E #EEPROM #RTC #SD #Display #Adafruit #SparkFun #ESP32 #IoT #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant
——
——
——
——
Global Positioning System (GPS)
The Global Positioning System (GPS) is a satellite-based radionavigation system owned by the United States government and operated by the United States Space Force. It is one of the global navigation satellite systems (GNSS) that provides geolocation and time information to a GPS receiver anywhere on or near the Earth where there is an unobstructed line of sight to four or more GPS satellites. Obstacles such as mountains and buildings block the relatively weak GPS signals.
GPS Receiver – GP-20U7
The GP-20U7 is a compact GPS receiver with a built-in high performances All-In-One GPS chipset. The GP-20U7 accurately provides position, velocity, and time readings as well possessing high sensitivity and tracking capabilities. Thanks to the low power consumption this receiver requires, the GP-20U7 is ideal for portable applications such as tablet PCs, smart phones, and other devices requiring positioning capability.
DL2406Mk02
1 x DFRobot FireBeetle 2 ESP32-E
1 x Adafruit SHARP Memory Display
1 x Adafruit MicroSD card breakout board+
1 x MicroSD 16 GB
1 x Adafruit DS3231 Precision RTC FeatherWing – RTC
1 x Battery CR1220
1 x SparkFun Environmental Combo CCS811/BME280
1 x GPS Receiver – GP-20U7
3 x Switch
2 x 1K Ohm
1 x 1 x Lithium Ion Battery – 1000mAh
1 x Green LED
1 x USB 3.1 Cable A to C
DFRobot FireBeetle 2 ESP32-E
LED – 2
DSCK – 4
DMOSI – 16
DSS – 17
SCK – 22
MOSI – 23
MISO – 19
CS – 13
GPR – 26
GPT – 25
SCL – 21
SDA – 22
LED – 14
SWI – 3
SWG – 1
VIN – +3.3V
GND – GND
——
DL2406Mk02p.ino
/****** Don Luc Electronics © ****** Software Version Information Project #29 - DFRobot - GPS Receiver - Mk15 29-15 DL2406Mk02p.ino DL2406Mk02 1 x DFRobot FireBeetle 2 ESP32-E 1 x Adafruit SHARP Memory Display 1 x Adafruit MicroSD card breakout board+ 1 x MicroSD 16 GB 1 x Adafruit DS3231 Precision RTC FeatherWing - RTC 1 x Battery CR1220 1 x SparkFun Environmental Combo CCS811/BME280 1 x GPS Receiver - GP-20U7 3 x Switch 2 x 1K Ohm 1 x 1 x Lithium Ion Battery - 1000mAh 1 x Green LED 1 x USB 3.1 Cable A to C */ // Include the Library Code // EEPROM Library to Read and Write EEPROM // with Unique ID for Unit #include "EEPROM.h" // Wire #include <Wire.h> // DS3231 RTC Date and Time #include <RTClib.h> // SD Card #include "FS.h" #include "SD.h" #include "SPI.h" // SHARP Memory Display #include <Adafruit_SharpMem.h> #include <Adafruit_GFX.h> // SparkFun BME280 - Humidity, Temperature, Altitude and Barometric Pressure #include <SparkFunBME280.h> // SparkFun CCS811 - eCO2 & tVOC #include <SparkFunCCS811.h> // GPS Receiver #include <TinyGPS++.h> // ESP32 Hardware Serial #include <HardwareSerial.h> // ESP32 HardwareSerial HardwareSerial tGPS(2); // GPS Receiver #define gpsRXPIN 26 // This one is unused and doesnt have a conection #define gpsTXPIN 25 // The TinyGPS++ object TinyGPSPlus gps; // Latitude float TargetLat; // Longitude float TargetLon; // GPS Date, Time, Speed, Altitude // GPS Date String TargetDat; // GPS Time String TargetTim; // GPS Speeds M/S String TargetSMS; // GPS Speeds Km/h String TargetSKH; // GPS Altitude Meters String TargetALT; // GPS Status String GPSSt = ""; // SparkFun BME280 - Temperature, Humidity, Altitude and Barometric Pressure BME280 myBME280; // Temperature Celsius float BMEtempC = 0; // Humidity float BMEhumid = 0; // Altitude Meters float BMEaltitudeM = 0; // Barometric Pressure float BMEpressure = 0; // SparkFun CCS811 - eCO2 & tVOC // Default I2C Address #define CCS811_ADDR 0x5B CCS811 myCCS811(CCS811_ADDR); // eCO2 float CCS811CO2 = 0; // TVOC float CCS811TVOC = 0; // DS3231 RTC Date and Time RTC_DS3231 rtc; String sDate; String sTime; // MicroSD Card const int chipSelect = 13; String zzzzzz = ""; // SHARP Memory Display #define SHARP_SCK 4 #define SHARP_MOSI 16 #define SHARP_SS 17 // Set the size of the display here, e.g. 144x168! Adafruit_SharpMem display(SHARP_SCK, SHARP_MOSI, SHARP_SS, 144, 168); // The currently-available SHARP Memory Display (144x168 pixels) // requires > 4K of microcontroller RAM; it WILL NOT WORK on Arduino Uno // or other <4K "classic" devices. #define BLACK 0 #define WHITE 1 // LED Green int iLEDGreen = 2; // Define LED int iLED = 14; // Switch int iSwitch = 3; // Variable for reading the Switch status int iSwitchState = 0; // Switch GPS int iSwitchGPS = 1; // Variable for reading the Switch GPS status int iSwitchGPSState = 0; // EEPROM Unique ID Information #define EEPROM_SIZE 64 String uid = ""; // Software Version Information String sver = "29-15"; void loop() { // DS3231 RTC Date and Time isRTC(); // SparkFun BME280 - Temperature, Humidity, Altitude and Barometric Pressure isBME280(); // SparkFun CCS811 - eCO2 & tVOC isCCS811(); // isGPS isGPS(); // Read the state of the Switch value iSwitchState = digitalRead(iSwitch); // The Switch is HIGH: if (iSwitchState == HIGH) { // Display Date, Time, Temperature, Humidity isDisplayDTTH(); } else { // Read the state of the Switch value iSwitchGPSState = digitalRead(iSwitchGPS); if (iSwitchGPSState == HIGH) { // Display GPS isDisplayGPS(); } else { // Display Date, Time, eCO2 Concentration, tVOC Concentration isDisplayDTCOVO(); } } // MicroSD Card isSD(); // iLED HIGH digitalWrite(iLED, HIGH ); // Delay 5 Second delay(5000); }
getBME280.ino
// SparkFun BME280 - Temperature, Humidity, Altitude and Barometric Pressure // isBME280 - Temperature, Humidity, Altitude and Barometric Pressure void isBME280(){ // Temperature Celsius BMEtempC = myBME280.readTempC(); // Humidity BMEhumid = myBME280.readFloatHumidity() ; // Altitude Meters BMEaltitudeM = myBME280.readFloatAltitudeMeters(); // Barometric Pressure BMEpressure = myBME280.readFloatPressure(); }
getCCS811.ino
// CCS811 - eCO2 & tVOC // isCCS811 - eCO2 & tVOC void isCCS811(){ // This sends the temperature & humidity data to the CCS811 myCCS811.setEnvironmentalData(BMEhumid, BMEtempC); // Calling this function updates the global tVOC and eCO2 variables myCCS811.readAlgorithmResults(); // eCO2 Concentration CCS811CO2 = myCCS811.getCO2(); // tVOC Concentration CCS811TVOC = myCCS811.getTVOC(); }
getDisplay.ino
// SHARP Memory Display // SHARP Memory Display - UID void isDisplayUID() { // Text Display // Clear Display display.clearDisplay(); display.setRotation(4); display.setTextSize(3); display.setTextColor(BLACK); // Don Luc Electronics display.setCursor(0,10); display.println( "Don Luc" ); display.setTextSize(2); display.setCursor(0,40); display.println( "Electronics" ); // Version //display.setTextSize(3); display.setCursor(0,70); display.println( "Version" ); //display.setTextSize(2); display.setCursor(0,95); display.println( sver ); // EEPROM display.setCursor(0,120); display.println( "EEPROM" ); display.setCursor(0,140); display.println( uid ); // Refresh display.refresh(); delay( 100 ); } // Display Date, Time, Temperature, Humidity, Altitude and Barometric Pressure void isDisplayDTTH() { // Text Display Date // Clear Display display.clearDisplay(); display.setRotation(4); display.setTextSize(2); display.setTextColor(BLACK); // Date display.setCursor(0,5); display.println( sDate ); // Time display.setCursor(0,30); display.println( sTime ); // Temperature display.setCursor(0,55); display.print( BMEtempC ); display.println( "C" ); // Humidity display.setCursor(0,80); display.print( BMEhumid ); display.println( "%" ); // Altitude Meters display.setCursor(0,105); display.print( BMEaltitudeM ); display.println( "M" ); // Barometric Pressure display.setCursor(0,130); display.println( BMEpressure ); // Refresh display.refresh(); delay( 100 ); } // Display Display Date, Time, eCO2 Concentration, tVOC Concentration void isDisplayDTCOVO() { // Text Display Date // Clear Display display.clearDisplay(); display.setRotation(4); display.setTextSize(2); display.setTextColor(BLACK); // Date display.setCursor(0,5); display.println( sDate ); // Time display.setCursor(0,30); display.println( sTime ); // eCO2 Concentration display.setCursor(0,55); display.println( "eCO2" ); display.setCursor(0,80); display.println( CCS811CO2 ); // tVOC Concentration display.setCursor(0,105); display.println( "tVOC" ); display.setCursor(0,130); display.println( CCS811TVOC ); // Refresh display.refresh(); delay( 100 ); } // Display GPS void isDisplayGPS() { // Text Display Date // Clear Display display.clearDisplay(); display.setRotation(4); display.setTextSize(2); display.setTextColor(BLACK); // Latitude display.setCursor(0,5); display.print( "Lat: " ); display.println( TargetLat ); // Longitude display.setCursor(0,30); display.print( "Lon: " ); display.println( TargetLon ); // GPS Date display.setCursor(0,55); display.println( TargetDat ); // GPS Time display.setCursor(0,80); display.println( TargetTim ); // GPS Speed M/S display.setCursor(0,105); display.print( TargetSMS ); display.println( " M/S" ); // GPS Altitude Meters display.setCursor(0,130); display.print( TargetALT ); display.println( " M" ); // Refresh display.refresh(); delay( 100 ); }
getEEPROM.ino
// EEPROM // isUID EEPROM Unique ID void isUID() { // Is Unit ID uid = ""; for (int x = 0; x < 7; x++) { uid = uid + char(EEPROM.read(x)); } }
getGPS.ino
// GPS Receiver // Setup GPS void isSetupGPS() { // Setup GPS tGPS.begin( 9600 , SERIAL_8N1 , gpsRXPIN , gpsTXPIN ); } // isGPS void isGPS(){ // Receives NEMA data from GPS receiver // This sketch displays information every time a new sentence is correctly encoded while ( tGPS.available() > 0) if (gps.encode( tGPS.read() )) { // GPS Vector Pointer Target displayInfo(); // GPS Date, Time, Speed, Altitude displayDTS(); } if (millis() > 5000 && gps.charsProcessed() < 10) { while(true); } } // GPS Vector Pointer Target void displayInfo(){ // Location if (gps.location.isValid()) { // Latitude TargetLat = gps.location.lat(); // Longitude TargetLon = gps.location.lng(); // GPS Status 2 GPSSt = "Yes"; } else { // GPS Status 0 GPSSt = "No"; } } // GPS Date, Time, Speed, Altitude void displayDTS(){ // Date TargetDat = ""; if (gps.date.isValid()) { // Date // Year TargetDat += String(gps.date.year(), DEC); TargetDat += "/"; // Month TargetDat += String(gps.date.month(), DEC); TargetDat += "/"; // Day TargetDat += String(gps.date.day(), DEC); } // Time TargetTim = ""; if (gps.time.isValid()) { // Time // Hour TargetTim += String(gps.time.hour(), DEC); TargetTim += ":"; // Minute TargetTim += String(gps.time.minute(), DEC); TargetTim += ":"; // Secound TargetTim += String(gps.time.second(), DEC); } // Speed TargetSMS = ""; TargetSKH = ""; if (gps.speed.isValid()) { // Speed // M/S int x = gps.speed.mps(); TargetSMS = String( x, DEC); // Km/h int y = gps.speed.kmph(); TargetSKH = String( y, DEC); } // Altitude TargetALT = ""; if (gps.altitude.isValid()) { // Altitude // Meters int z = gps.altitude.meters(); TargetALT = String( z, DEC); } }
getRTC.ino
// DS3231 RTC Date and Time // Setup DS3231 RTC void isSetupRTC() { if (! rtc.begin()) { while (1); } if (rtc.lostPower()) { // Following line sets the RTC to the date & time this sketch was compiled rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); // This line sets the RTC with an explicit date & time, for example to set // January 21, 2014 at 3am you would call: // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0)); } } // DS3231 RTC Date and Time void isRTC(){ // Date and Time sDate = ""; sTime = ""; // Date Time DateTime now = rtc.now(); // sData sDate += String(now.year(), DEC); sDate += "/"; sDate += String(now.month(), DEC); sDate += "/"; sDate += String(now.day(), DEC); // sTime sTime += String(now.hour(), DEC); sTime += ":"; sTime += String(now.minute(), DEC); sTime += ":"; sTime += String(now.second(), DEC); }
getSD.ino
// MicroSD Card // MicroSD Setup void isSetupSD() { // MicroSD Card pinMode( chipSelect , OUTPUT ); if(!SD.begin( chipSelect )){ ; return; } uint8_t cardType = SD.cardType(); // CARD NONE if(cardType == CARD_NONE){ ; return; } // SD Card Type if(cardType == CARD_MMC){ ; } else if(cardType == CARD_SD){ ; } else if(cardType == CARD_SDHC){ ; } else { ; } // Size uint64_t cardSize = SD.cardSize() / (1024 * 1024); } // MicroSD Card void isSD() { zzzzzz = ""; // DFR|EEPROM Unique ID|Version|Date|Time|Temperature Celsius|Humidity //|Altitude Meters|Barometric Pressure|eCO2 Concentration|tVOC Concentration //|GPS|Latitude|Longitude|GPS Date|GPS Time|GPS Speed M/S|GPS Altitude|*\r zzzzzz = "DFR|" + uid + "|" + sver + "|" + sDate + "|" + sTime + "|" + String(BMEtempC) + "C|" + String(BMEhumid) + "%|" + String(BMEaltitudeM) + " M|" + String(BMEpressure) + "|" + String(CCS811CO2) + "|" + String(CCS811TVOC) + "|" + String(GPSSt) + "|" + String(TargetLat) + "|" + String(TargetLon) + "|" + String(TargetDat) + "|" + String(TargetTim) + "|" + String(TargetSMS) + "|" + String(TargetALT)+ "|*\r"; // msg + 1 char msg[zzzzzz.length() + 1]; zzzzzz.toCharArray(msg, zzzzzz.length() + 1); // Append File appendFile(SD, "/dfrdata.txt", msg ); } // List Dir void listDir(fs::FS &fs, const char * dirname, uint8_t levels){ // List Dir dirname; File root = fs.open(dirname); if(!root){ return; } if(!root.isDirectory()){ return; } File file = root.openNextFile(); while(file){ if(file.isDirectory()){ file.name(); if(levels){ listDir(fs, file.name(), levels -1); } } else { file.name(); file.size(); } file = root.openNextFile(); } } // Write File void writeFile(fs::FS &fs, const char * path, const char * message){ // Write File path; File file = fs.open(path, FILE_WRITE); if(!file){ return; } if(file.print(message)){ ; } else { ; } file.close(); } // Append File void appendFile(fs::FS &fs, const char * path, const char * message){ // Append File path; File file = fs.open(path, FILE_APPEND); if(!file){ return; } if(file.print(message)){ ; } else { ; } file.close(); }
setup.ino
// Setup void setup() { // Give display time to power on delay(100); // EEPROM Size EEPROM.begin(EEPROM_SIZE); // EEPROM Unique ID isUID(); // Give display delay(100); // Set up I2C bus Wire.begin(); // Give display delay(100); // Setup DS3231 RTC isSetupRTC(); //MicroSD Card isSetupSD(); // SHARP Display Start & Clear the Display display.begin(); // Clear Display display.clearDisplay(); // Delay delay( 100 ); // SparkFun BME280 - Temperature, Humidity, Altitude and Barometric Pressure myBME280.begin(); // CCS811 - eCO2 & tVOC myCCS811.begin(); // Delay delay( 100 ); // GPS Receiver // Setup GPS isSetupGPS(); // Initialize digital pin iLED as an output pinMode(iLED, OUTPUT); // Outputting high, the LED turns on digitalWrite(iLED, HIGH); // Initialize the LED Green pinMode(iLEDGreen, OUTPUT); // iLEDGreen HIGH digitalWrite(iLEDGreen, HIGH ); // Initialize the Switch pinMode(iSwitch, INPUT); // Initialize the Switch GPS pinMode(iSwitchGPS, INPUT); // Don Luc Electronics // Version // EEPROM isDisplayUID(); // Delay 5 Second delay( 5000 ); }
——
People can contact us: https://www.donluc.com/?page_id=1927
Teacher, Instructor, E-Mentor, R&D and Consulting
- Programming Language
- Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi, Arm, Silicon Labs, Espressif, Etc…)
- IoT
- Wireless (Radio Frequency, Bluetooth, WiFi, Etc…)
- Robotics
- Automation
- Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
- Unmanned Vehicles Terrestrial and Marine
- Machine Learning
- Artificial Intelligence (AI)
- RTOS
- Sensors, eHealth Sensors, Biosensor, and Biometric
- Research & Development (R & D)
- Consulting
Follow Us
Luc Paquin – Curriculum Vitae – 2024
https://www.donluc.com/luc/
Web: https://www.donluc.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/@thesass2063
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/
LinkedIn: https://www.linkedin.com/in/jlucpaquin/
Don Luc
Project #29 – DFRobot – Environmental Combo – Mk14
——
#DonLucElectronics #DonLuc #DFRobot #BME280 #CCS811 #FireBeetle2ESP32E #EEPROM #RTC #SD #Display #Adafruit #SparkFun #ESP32 #IoT #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant
——
——
——
——
SparkFun Environmental Combo Breakout – CCS811/BME280
The SparkFun CCS811/BME280 Environmental Combo Breakout takes care of all your atmospheric-quality sensing needs with the popular CCS811 and BME280 ICs. This unique breakout provides a variety of environmental data, including barometric pressure, humidity, temperature, TVOCs and equivalent eCO2 levels. To make it even easier to use this breakout, all communication is enacted exclusively via I2C, utilizing our handy Qwiic system.
The CCS811 is an exceedingly popular sensor, providing readings for equivalent eCO2 in the parts per million (PPM) and total volatile organic compounds in the parts per billion (PPB). The CCS811 also has a feature that allows it to fine-tune its readings if it has access to the current humidity and temperature. Luckily for us, the BME280 provides humidity, temperature and barometric pressure. This allows the sensors to work together to give us more accurate readings than they’d be able to provide on their own. We also made it easy to interface with them via I2C.
DL2406Mk01
1 x DFRobot FireBeetle 2 ESP32-E
1 x Adafruit SHARP Memory Display
1 x Adafruit MicroSD card breakout board+
1 x MicroSD 16 GB
1 x Adafruit DS3231 Precision RTC FeatherWing – RTC
1 x Battery CR1220
1 x SparkFun Environmental Combo CCS811/BME280
2 x Switch
1 x 1K Ohm
1 x 1 x Lithium Ion Battery – 1000mAh
1 x Green LED
1 x Slide Switch
1 x USB 3.1 Cable A to C
DFRobot FireBeetle 2 ESP32-E
LED – 2
DSCK – 4
DMOSI – 16
DSS – 17
SCK – 22
MOSI – 23
MISO – 19
CS – 13
SCL – 21
SDA – 22
LED – 14
SWI – 3
VIN – +3.3V
GND – GND
——
DL2406Mk01p.ino
/****** Don Luc Electronics © ****** Software Version Information Project #29 - DFRobot - Environmental Combo - Mk14 29-14 DL2406Mk01p.ino 1 x DFRobot FireBeetle 2 ESP32-E 1 x Adafruit SHARP Memory Display 1 x Adafruit MicroSD card breakout board+ 1 x MicroSD 16 GB 1 x Adafruit DS3231 Precision RTC FeatherWing - RTC 1 x Battery CR1220 1 x SparkFun Environmental Combo CCS811/BME280 2 x Switch 1 x 1K Ohm 1 x 1 x Lithium Ion Battery - 1000mAh 1 x Green LED 1 x Slide Switch 1 x USB 3.1 Cable A to C */ // Include the Library Code // EEPROM Library to Read and Write EEPROM // with Unique ID for Unit #include "EEPROM.h" // Wire #include <Wire.h> // DS3231 RTC Date and Time #include <RTClib.h> // SD Card #include "FS.h" #include "SD.h" #include "SPI.h" // SHARP Memory Display #include <Adafruit_SharpMem.h> #include <Adafruit_GFX.h> // SparkFun BME280 - Humidity, Temperature, Altitude and Barometric Pressure #include <SparkFunBME280.h> // SparkFun CCS811 - eCO2 & tVOC #include <SparkFunCCS811.h> // SparkFun BME280 - Temperature, Humidity, Altitude and Barometric Pressure BME280 myBME280; // Temperature Celsius float BMEtempC = 0; // Humidity float BMEhumid = 0; // Altitude Meters float BMEaltitudeM = 0; // Barometric Pressure float BMEpressure = 0; // SparkFun CCS811 - eCO2 & tVOC // Default I2C Address #define CCS811_ADDR 0x5B CCS811 myCCS811(CCS811_ADDR); // eCO2 float CCS811CO2 = 0; // TVOC float CCS811TVOC = 0; // DS3231 RTC Date and Time RTC_DS3231 rtc; String sDate; String sTime; // MicroSD Card const int chipSelect = 13; String zzzzzz = ""; // SHARP Memory Display #define SHARP_SCK 4 #define SHARP_MOSI 16 #define SHARP_SS 17 // Set the size of the display here, e.g. 144x168! Adafruit_SharpMem display(SHARP_SCK, SHARP_MOSI, SHARP_SS, 144, 168); // The currently-available SHARP Memory Display (144x168 pixels) // requires > 4K of microcontroller RAM; it WILL NOT WORK on Arduino Uno // or other <4K "classic" devices. #define BLACK 0 #define WHITE 1 // LED Green int iLEDGreen = 2; // Define LED int iLED = 14; // Switch int iSwitch = 3; // Variable for reading the Switch status int iSwitchState = 0; // EEPROM Unique ID Information #define EEPROM_SIZE 64 String uid = ""; // Software Version Information String sver = "29-14"; void loop() { // DS3231 RTC Date and Time isRTC(); // SparkFun BME280 - Temperature, Humidity, Altitude and Barometric Pressure isBME280(); // SparkFun CCS811 - eCO2 & tVOC isCCS811(); // Read the state of the Switch value iSwitchState = digitalRead(iSwitch); // The Switch is HIGH: if (iSwitchState == HIGH) { // Display Date, Time, Temperature, Humidity isDisplayDTTH(); } else { // Display Date, Time, eCO2 Concentration, tVOC Concentration isDisplayDTCOVO(); } // MicroSD Card isSD(); // iLED HIGH digitalWrite(iLED, HIGH ); // Delay 1 Second delay(1000); }
getBME280.ino
// SparkFun BME280 - Temperature, Humidity, Altitude and Barometric Pressure // isBME280 - Temperature, Humidity, Altitude and Barometric Pressure void isBME280(){ // Temperature Celsius BMEtempC = myBME280.readTempC(); // Humidity BMEhumid = myBME280.readFloatHumidity() ; // Altitude Meters BMEaltitudeM = myBME280.readFloatAltitudeMeters(); // Barometric Pressure BMEpressure = myBME280.readFloatPressure(); }
getCCS811.ino
// CCS811 - eCO2 & tVOC // isCCS811 - eCO2 & tVOC void isCCS811(){ // This sends the temperature & humidity data to the CCS811 myCCS811.setEnvironmentalData(BMEhumid, BMEtempC); // Calling this function updates the global tVOC and eCO2 variables myCCS811.readAlgorithmResults(); // eCO2 Concentration CCS811CO2 = myCCS811.getCO2(); // tVOC Concentration CCS811TVOC = myCCS811.getTVOC(); }
getDisplay.ino
// SHARP Memory Display // SHARP Memory Display - UID void isDisplayUID() { // Text Display // Clear Display display.clearDisplay(); display.setRotation(4); display.setTextSize(3); display.setTextColor(BLACK); // Don Luc Electronics display.setCursor(0,10); display.println( "Don Luc" ); display.setTextSize(2); display.setCursor(0,40); display.println( "Electronics" ); // Version //display.setTextSize(3); display.setCursor(0,70); display.println( "Version" ); //display.setTextSize(2); display.setCursor(0,95); display.println( sver ); // EEPROM display.setCursor(0,120); display.println( "EEPROM" ); display.setCursor(0,140); display.println( uid ); // Refresh display.refresh(); delay( 100 ); } // Display Date, Time, Temperature, Humidity, Altitude and Barometric Pressure void isDisplayDTTH() { // Text Display Date // Clear Display display.clearDisplay(); display.setRotation(4); display.setTextSize(2); display.setTextColor(BLACK); // Date display.setCursor(0,5); display.println( sDate ); // Time display.setCursor(0,30); display.println( sTime ); // Temperature display.setCursor(0,55); display.print( BMEtempC ); display.println( "C" ); // Humidity display.setCursor(0,80); display.print( BMEhumid ); display.println( "%" ); // Altitude Meters display.setCursor(0,105); display.print( BMEaltitudeM ); display.println( "M" ); // Barometric Pressure display.setCursor(0,130); display.println( BMEpressure ); // Refresh display.refresh(); delay( 100 ); } // Display Display Date, Time, eCO2 Concentration, tVOC Concentration void isDisplayDTCOVO() { // Text Display Date // Clear Display display.clearDisplay(); display.setRotation(4); display.setTextSize(2); display.setTextColor(BLACK); // Date display.setCursor(0,5); display.println( sDate ); // Time display.setCursor(0,30); display.println( sTime ); // eCO2 Concentration display.setCursor(0,55); display.println( "eCO2" ); display.setCursor(0,80); display.println( CCS811CO2 ); // tVOC Concentration display.setCursor(0,105); display.println( "tVOC" ); display.setCursor(0,130); display.println( CCS811TVOC ); // Refresh display.refresh(); delay( 100 ); }
getEEPROM.ino
// EEPROM // isUID EEPROM Unique ID void isUID() { // Is Unit ID uid = ""; for (int x = 0; x < 7; x++) { uid = uid + char(EEPROM.read(x)); } }
getRTC.ino
// DS3231 RTC Date and Time // Setup DS3231 RTC void isSetupRTC() { if (! rtc.begin()) { while (1); } if (rtc.lostPower()) { // Following line sets the RTC to the date & time this sketch was compiled rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); // This line sets the RTC with an explicit date & time, for example to set // January 21, 2014 at 3am you would call: // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0)); } } // DS3231 RTC Date and Time void isRTC(){ // Date and Time sDate = ""; sTime = ""; // Date Time DateTime now = rtc.now(); // sData sDate += String(now.year(), DEC); sDate += "/"; sDate += String(now.month(), DEC); sDate += "/"; sDate += String(now.day(), DEC); // sTime sTime += String(now.hour(), DEC); sTime += ":"; sTime += String(now.minute(), DEC); sTime += ":"; sTime += String(now.second(), DEC); }
getSD.ino
// MicroSD Card // MicroSD Setup void setupSD() { // MicroSD Card pinMode( chipSelect , OUTPUT ); if(!SD.begin( chipSelect )){ ; return; } uint8_t cardType = SD.cardType(); // CARD NONE if(cardType == CARD_NONE){ ; return; } // SD Card Type if(cardType == CARD_MMC){ ; } else if(cardType == CARD_SD){ ; } else if(cardType == CARD_SDHC){ ; } else { ; } // Size uint64_t cardSize = SD.cardSize() / (1024 * 1024); } // MicroSD Card void isSD() { zzzzzz = ""; // DFR|EEPROM Unique ID|Version|Date|Time|Temperature Celsius|Humidity //|Altitude Meters|Barometric Pressure|eCO2 Concentration|tVOC Concentration|*\r zzzzzz = "DFR|" + uid + "|" + sver + "|" + sDate + "|" + sTime + "|" + String(BMEtempC) + "C|" + String(BMEhumid) + "%|" + String(BMEaltitudeM) + " M|" + String(BMEpressure) + "|" + String(CCS811CO2) + "|" + String(CCS811TVOC) + "|*\r"; // msg + 1 char msg[zzzzzz.length() + 1]; zzzzzz.toCharArray(msg, zzzzzz.length() + 1); // Append File appendFile(SD, "/dfrdata.txt", msg ); } // List Dir void listDir(fs::FS &fs, const char * dirname, uint8_t levels){ // List Dir dirname; File root = fs.open(dirname); if(!root){ return; } if(!root.isDirectory()){ return; } File file = root.openNextFile(); while(file){ if(file.isDirectory()){ file.name(); if(levels){ listDir(fs, file.name(), levels -1); } } else { file.name(); file.size(); } file = root.openNextFile(); } } // Write File void writeFile(fs::FS &fs, const char * path, const char * message){ // Write File path; File file = fs.open(path, FILE_WRITE); if(!file){ return; } if(file.print(message)){ ; } else { ; } file.close(); } // Append File void appendFile(fs::FS &fs, const char * path, const char * message){ // Append File path; File file = fs.open(path, FILE_APPEND); if(!file){ return; } if(file.print(message)){ ; } else { ; } file.close(); }
setup.ino
// Setup void setup() { // Give display time to power on delay(100); // EEPROM Size EEPROM.begin(EEPROM_SIZE); // EEPROM Unique ID isUID(); // Give display delay(100); // Set up I2C bus Wire.begin(); // Give display delay(100); // Setup DS3231 RTC isSetupRTC(); //MicroSD Card setupSD(); // SHARP Display Start & Clear the Display display.begin(); // Clear Display display.clearDisplay(); // Delay delay( 100 ); // SparkFun BME280 - Temperature, Humidity, Altitude and Barometric Pressure myBME280.begin(); // CCS811 - eCO2 & tVOC myCCS811.begin(); // Delay delay( 100 ); // Initialize digital pin iLED as an output pinMode(iLED, OUTPUT); // Outputting high, the LED turns on digitalWrite(iLED, HIGH); // Initialize the LED Green pinMode(iLEDGreen, OUTPUT); // iLEDGreen HIGH digitalWrite(iLEDGreen, HIGH ); // Initialize the Switch pinMode(iSwitch, INPUT); // Don Luc Electronics // Version // EEPROM isDisplayUID(); // Delay 5 Second delay( 5000 ); }
——
People can contact us: https://www.donluc.com/?page_id=1927
Teacher, Instructor, E-Mentor, R&D and Consulting
- Programming Language
- Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi, Arm, Silicon Labs, Espressif, Etc…)
- IoT
- Wireless (Radio Frequency, Bluetooth, WiFi, Etc…)
- Robotics
- Automation
- Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
- Unmanned Vehicles Terrestrial and Marine
- Machine Learning
- Artificial Intelligence (AI)
- RTOS
- Sensors, eHealth Sensors, Biosensor, and Biometric
- Research & Development (R & D)
- Consulting
Follow Us
Luc Paquin – Curriculum Vitae – 2024
https://www.donluc.com/luc/
Web: https://www.donluc.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/@thesass2063
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/
LinkedIn: https://www.linkedin.com/in/jlucpaquin/
Don Luc
Project #29 – DFRobot – RHT And MQ – Mk13
——
#DonLucElectronics #DonLuc #DFRobot #BLESensorBeacon #AmbientLight #SoilMoisture #SHT40 #FireBeetle2ESP32E #EEPROM #RTC #SD #Display #Adafruit #ESP32 #IoT #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant
——
——
——
——
Humidity and Temperature Sensor – RHT03
The RHT03 (also known by DHT-22) is a low cost humidity and temperature sensor with a single wire digital interface. The sensor is calibrated and doesn’t require extra components so you can get right to measuring relative humidity and temperature.
MQ Series Gas Sensor
The description of each MQ series gas sensor and its uses that follows will be helpful to anybody who wants to understand the foundations of gas sensing technology. The MQ Series Gas Sensor is a revolutionary technology designed for the detection of combustible gases, such as those used in industry and manufacturing. MQ sensor working principle involves detecting changes in electrical conductivity when specific gases come into contact with the sensor’s sensing element. This variety of semiconductor gas sensors makes it possible to measure concentrations of gasses such as alcohol, methane, propane, butane, and carbon monoxide.
Pololu Carrier for MQ Gas Sensors
This carrier board is designed to work with any of the MQ-series gas sensors, simplifying the interface from 6 to 3 pins—ground, power and analog voltage output +3-5 Volt. This board has two mounting holes and provides convenient pads for mounting the gas sensor’s required sensitivity-setting resistor.
DL2405Mk03
1 x DFRobot FireBeetle 2 ESP32-E
1 x Adafruit SHARP Memory Display
1 x Adafruit MicroSD card breakout board+
1 x MicroSD 16 GB
1 x Adafruit DS3231 Precision RTC FeatherWing – RTC
1 x Battery CR1220
4 x Pololu Carrier for MQ Gas Sensors
1 x SparkFun Hydrogen Gas Sensor – MQ-8
1 x 4.7K Ohm
1 x Pololu Carbon Monoxide & Flammable Gas Sensor – MQ-9
1 x 22k Ohm
1 x SparkFun Carbon Monoxide Gas Sensor – MQ-7
1 x 10K Ohm
1 x SparkFun Alcohol Gas Sensor – MQ-3
1 x 220k Ohm
1 x Temperature and Humidity Sensor – RHT03
1 x PIR Motion Sensor (JST)
1 x Switch
1 x 1K Ohm
1 x Gravity: Analog Soil Moisture Sensor
1 x Gravity: Analog Ambient Light Sensor
1 x Fermion: SHT40 Temperature & Humidity Sensor
3 x Fermion: BLE Sensor Beacon
3 x CR2032 Coin Cell Battery
1 x 1 x Lithium Ion Battery – 1000mAh
1 x Green LED
1 x Slide Switch
1 x SparkFun Serial Basic Breakout – CH340G
1 x SparkFun Cerberus USB Cable
1 x USB 3.1 Cable A to C
DFRobot FireBeetle 2 ESP32-E
LED – 2
DSCK – 4
DMOSI – 16
DSS – 17
SCK – 22
MOSI – 23
MISO – 19
CS – 13
SCL – 21
SDA – 22
LED – 14
RHT – 25
PIR – 26
SWI – 3
MQ8 = A0
MQ9 = A1
MQ7 = A2
MQ3 = A3
VIN – +3.3V
GND – GND
——
DL2405Mk03p.ino
/****** Don Luc Electronics © ****** Software Version Information Project #29 - DFRobot - RHT And MQ - Mk13 29-13 DL2404Mk03p.ino 1 x DFRobot FireBeetle 2 ESP32-E 1 x Adafruit SHARP Memory Display 1 x Adafruit MicroSD card breakout board+ 1 x MicroSD 16 GB 1 x Adafruit DS3231 Precision RTC FeatherWing - RTC 1 x Battery CR1220 4 x Pololu Carrier for MQ Gas Sensors 1 x SparkFun Hydrogen Gas Sensor - MQ-8 1 x 4.7K Ohm 1 x Pololu Carbon Monoxide & Flammable Gas Sensor - MQ-9 1 x 22k Ohm 1 x SparkFun Carbon Monoxide Gas Sensor - MQ-7 1 x 10K Ohm 1 x SparkFun Alcohol Gas Sensor - MQ-3 1 x 220k Ohm 1 x Temperature and Humidity Sensor - RHT03 1 x PIR Motion Sensor (JST) 1 x Switch 1 x 1K Ohm 1 x Gravity: Analog Soil Moisture Sensor 1 x Gravity: Analog Ambient Light Sensor 1 x Fermion: SHT40 Temperature & Humidity Sensor 3 x Fermion: BLE Sensor Beacon 3 x CR2032 Coin Cell Battery 1 x 1 x Lithium Ion Battery - 1000mAh 1 x Green LED 1 x SparkFun Serial Basic Breakout - CH340G 1 x SparkFun Cerberus USB Cable 1 x USB 3.1 Cable A to C */ // Include the Library Code // EEPROM Library to Read and Write EEPROM // with Unique ID for Unit #include "EEPROM.h" // Wire #include <Wire.h> // Arduino #include <Arduino.h> // BLE Device #include <BLEDevice.h> // BLE Utils #include <BLEUtils.h> // BLEScan #include <BLEScan.h> // BLE Advertised Device #include <BLEAdvertisedDevice.h> // BLE Eddystone URL #include <BLEEddystoneURL.h> // BLE Eddystone TLM #include <BLEEddystoneTLM.h> // BLE Beacon #include <BLEBeacon.h> // DS3231 RTC Date and Time #include <RTClib.h> // SD Card #include "FS.h" #include "SD.h" #include "SPI.h" // SHARP Memory Display #include <Adafruit_SharpMem.h> #include <Adafruit_GFX.h> // RHT Temperature and Humidity Sensor #include <SparkFun_RHT03.h> // ENDIAN_CHANGE #define ENDIAN_CHANGE_U16(x) ((((x)&0xFF00) >> 8) + (((x)&0xFF) << 8)) // DS3231 RTC Date and Time RTC_DS3231 rtc; String sDate; String sTime; // MicroSD Card const int chipSelect = 13; String zzzzzz = ""; // SHARP Memory Display #define SHARP_SCK 4 #define SHARP_MOSI 16 #define SHARP_SS 17 // Set the size of the display here, e.g. 144x168! Adafruit_SharpMem display(SHARP_SCK, SHARP_MOSI, SHARP_SS, 144, 168); // The currently-available SHARP Memory Display (144x168 pixels) // requires > 4K of microcontroller RAM; it WILL NOT WORK on Arduino Uno // or other <4K "classic" devices. #define BLACK 0 #define WHITE 1 // LED Green int iLEDGreen = 2; // Define LED int iLED = 14; // Fermion: SHT40 Temperature & Humidity Sensor // Temperature float TemperatureData; float Temperature; // Humidity float HumidityData; float Humidity; // Gravity: Analog Ambient Light Sensor float Sensor_Data; // SData => 1~6000 Lux float SData; // Gravity: Analog Soil Moisture Sensor float SensorSM; float SDataSM; // In seconds int scanTime = 5; // BLE Scan BLEScan *pBLEScan; // RHT Temperature and Humidity Sensor // RHT03 data pin Digital 25 const int RHT03_DATA_PIN = 25; // This creates a RTH03 object, which we'll use to interact with the sensor RHT03 rht; float latestHumidity; float latestTempC; // Gas Sensors MQ // Hydrogen Gas Sensor - MQ-8 int iMQ8 = A0; int iMQ8Raw = 0; int iMQ8ppm = 0; // Two points are taken from the curve in datasheet. // With these two points, a line is formed which is // "approximately equivalent" to the original curve. float H2Curve[3] = {2.3, 0.93,-1.44}; // Carbon Monoxide & Flammable Gas Sensor - MQ-9 int iMQ9 = A1; int iMQ9Raw = 0; int iMQ9ppm = 0; // Carbon Monoxide Gas Sensor - MQ-7 int iMQ7 = A2; int iMQ7Raw = 0; int iMQ7ppm = 0; // Alcohol Gas Sensor - MQ-3 int iMQ3 = A3; int iMQ3Raw = 0; int iMQ3ppm = 0; // PIR Motion // Motion detector const int iMotion = 26; // Proximity int proximity = LOW; String Det = ""; // Switch int iSwitch = 3; // Variable for reading the Switch status int iSwitchState = 0; // My Advertised Device Callbacks class MyAdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks { // onResult void onResult(BLEAdvertisedDevice advertisedDevice) { // Advertised Device if (advertisedDevice.haveName()) { // Name: Fermion: Sensor Beacon if(String(advertisedDevice.getName().c_str()) == "SHT40"){ // strManufacturerData std::string strManufacturerData = advertisedDevice.getManufacturerData(); uint8_t cManufacturerData[100]; strManufacturerData.copy((char *)cManufacturerData, strManufacturerData.length(), 0); // strManufacturerData.length for (int i = 0; i < strManufacturerData.length(); i++) { // cManufacturerData[i] cManufacturerData[i]; } // TemperatureData TemperatureData = int(cManufacturerData[2]<<8 | cManufacturerData[3]); // HumidityData HumidityData = int(cManufacturerData[5]<<8 | cManufacturerData[6]); } // Name: Fermion: Sensor Beacon if(String(advertisedDevice.getName().c_str()) == "Fermion: Sensor Beacon"){ // strManufacturerData std::string strManufacturerData = advertisedDevice.getManufacturerData(); uint8_t cManufacturerData[100]; strManufacturerData.copy((char *)cManufacturerData, strManufacturerData.length(), 0); // strManufacturerData.length for (int i = 0; i < strManufacturerData.length(); i++) { // cManufacturerData[i] cManufacturerData[i]; } // Sensor_Data Sensor_Data = int(cManufacturerData[2]<<8 | cManufacturerData[3]); } // Name: Fermion: Sensor Beacon if(String(advertisedDevice.getName().c_str()) == "Soil Moisture"){ // strManufacturerData std::string strManufacturerData = advertisedDevice.getManufacturerData(); uint8_t cManufacturerData[100]; strManufacturerData.copy((char *)cManufacturerData, strManufacturerData.length(), 0); // strManufacturerData.length for (int i = 0; i < strManufacturerData.length(); i++) { // cManufacturerData[i] cManufacturerData[i]; } // SensorSM SensorSM = int(cManufacturerData[2]<<8 | cManufacturerData[3]); } } } }; // EEPROM Unique ID Information #define EEPROM_SIZE 64 String uid = ""; // Software Version Information String sver = "29-13"; void loop() { // DS3231 RTC Date and Time isRTC(); // RHT Temperature and Humidity Sensor isRHT03(); // Gas Sensors MQ isGasSensor(); // isPIR Motion isPIR(); // ScanResults isBLEScanResults(); // Fermion: SHT40 Temperature & Humidity Sensor isSHT40(); // Gravity: Analog Ambient Light Sensor isAmbientLight(); // Soil Moisture isSoilMoisture(); // Delay 4 Second delay(4000); // Read the state of the Switch value iSwitchState = digitalRead(iSwitch); // The Switch is HIGH: if (iSwitchState == HIGH) { // Display Date, Time, Temperature, Humidity isDisplayDTTH(); } else { // Display Temperature, Humidity, MQ, PIR isDisplayDTMQPIR(); } // MicroSD Card isSD(); // iLED HIGH digitalWrite(iLED, HIGH ); // Delay 1 Second delay(1000); }
getAmbientLight.ino
// Gravity: Analog Ambient Light Sensor // Ambient Light void isAmbientLight(){ // Analog Ambient Light Sensor // SData => 1~6000 Lux SData = map(Sensor_Data, 1, 3000, 1, 6000); }
getBLEScan.ino
// getBLEScan // Setup BLE Scan void isSetupBLEScan(){ // BLE Device BLEDevice::init(""); // Create new scan pBLEScan = BLEDevice::getScan(); // Set Advertised Device Callbacks pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks()); // Active scan uses more power, but get results faster pBLEScan->setActiveScan(true); // Set Interval pBLEScan->setInterval(100); // Less or equal setInterval value pBLEScan->setWindow(99); } // BLE Scan Results void isBLEScanResults(){ // Put your main code here, to run repeatedly: BLEScanResults foundDevices = pBLEScan->start(scanTime, false); // Delete results fromBLEScan buffer to release memory pBLEScan->clearResults(); }
getDisplay.ino
// SHARP Memory Display // SHARP Memory Display - UID void isDisplayUID() { // Text Display // Clear Display display.clearDisplay(); display.setRotation(4); display.setTextSize(3); display.setTextColor(BLACK); // Don Luc Electronics display.setCursor(0,10); display.println( "Don Luc" ); display.setTextSize(2); display.setCursor(0,40); display.println( "Electronics" ); // Version //display.setTextSize(3); display.setCursor(0,70); display.println( "Version" ); //display.setTextSize(2); display.setCursor(0,95); display.println( sver ); // EEPROM display.setCursor(0,120); display.println( "EEPROM" ); display.setCursor(0,140); display.println( uid ); // Refresh display.refresh(); delay( 100 ); } // Display Date, Time, Temperature, Humidity, Ambient Light, Soil Moisture void isDisplayDTTH() { // Text Display Date // Clear Display display.clearDisplay(); display.setRotation(4); display.setTextSize(2); display.setTextColor(BLACK); // Date display.setCursor(0,5); display.println( sDate ); // Time display.setCursor(0,30); display.println( sTime ); // Temperature display.setCursor(0,55); display.print( Temperature ); display.println( "C" ); // Humidity display.setCursor(0,80); display.print( Humidity ); display.println( "%" ); // Lux display.setCursor(0,105); display.println( SData ); // Soil Moisture display.setCursor(0,130); display.println( SDataSM ); // Refresh display.refresh(); delay( 100 ); } // Display Temperature, Humidity, MQ, PIR void isDisplayDTMQPIR() { // Text Display Date // Clear Display display.clearDisplay(); display.setRotation(4); display.setTextSize(2); display.setTextColor(BLACK); // Temperature display.setCursor(0,5); display.print( latestTempC ); display.println( "C" ); // Humidity display.setCursor(0,30); display.print( latestHumidity ); display.println( "%" ); // MQ-8 display.setCursor(0,55); display.print( "MQ-8: " ); display.print( iMQ8ppm ); display.println( " PPM" ); // MQ-9 display.setCursor(0,80); display.print( "MQ-9: " ); display.print( iMQ9ppm ); display.println( " PPM" ); // MQ-7 display.setCursor(0,105); display.print( "MQ-7: " ); display.print( iMQ7ppm ); display.println( " PPM" ); // MQ-3 display.setCursor(0,130); display.print( "MQ-3: " ); display.print( iMQ3ppm ); display.println( "%" ); // PIR display.setCursor(0,145); display.println( Det ); // Refresh display.refresh(); delay( 100 ); }
getEEPROM.ino
// EEPROM // isUID EEPROM Unique ID void isUID() { // Is Unit ID uid = ""; for (int x = 0; x < 7; x++) { uid = uid + char(EEPROM.read(x)); } }
getGasSensorMQ.ino
// Gas Sensors MQ // Gas Sensor void isGasSensor() { // Read in analog value from each gas sensors // Hydrogen Gas Sensor - MQ-8 iMQ8Raw = analogRead( iMQ8 ); // Carbon Monoxide & Flammable Gas Sensor - MQ-9 iMQ9Raw = analogRead( iMQ9 ); // Carbon Monoxide Gas Sensor - MQ-7 iMQ7Raw = analogRead( iMQ7 ); // Alcohol Gas Sensor - MQ-3 iMQ3Raw = analogRead( iMQ3 ); // Caclulate the PPM of each gas sensors // Hydrogen Gas Sensor - MQ-8 iMQ8ppm = isMQ8( iMQ8Raw ); // Carbon Monoxide & Flammable Gas Sensor - MQ-9 iMQ9ppm = isMQ9( iMQ9Raw ); // Carbon Monoxide Gas Sensor - MQ-7 iMQ7ppm = isMQ7( iMQ7Raw ); // Alcohol Gas Sensor - MQ-3 iMQ3ppm = isMQ3( iMQ3Raw ); } // Hydrogen Gas Sensor - MQ-8 - PPM int isMQ8(double rawValue) { // RvRo double RvRo = rawValue * (3.3 / 4095); double ppm = 3.027*exp(1.0698*( RvRo )); return ppm; //return (pow(4.7,( ((log(RvRo)-H2Curve[1])/H2Curve[2]) + H2Curve[0]))); } // Carbon Monoxide & Flammable Gas Sensor - MQ-9 int isMQ9(double rawValue) { double RvRo = rawValue * 3.3 / 4095; double ppm = 3.027*exp(1.0698*( RvRo )); return ppm; } // Carbon Monoxide Gas Sensor - MQ-7 int isMQ7(double rawValue) { double RvRo = rawValue * 3.3 / 4095; double ppm = 3.027*exp(1.0698*( RvRo )); return ppm; } // Alcohol Gas Sensor - MQ-3 int isMQ3(double rawValue) { double RvRo = rawValue * 3.3 / 4095; double bac = RvRo * 0.21; return bac; }
getPIR.ino
// PIR Motion // Setup PIR void isSetupPIR() { // Setup PIR Montion pinMode(iMotion, INPUT_PULLUP); } // isPIR Motion void isPIR() { // Proximity proximity = digitalRead(iMotion); if (proximity == LOW) { // PIR Motion Sensor's LOW, Motion is detected Det = "Motion Yes"; } else { // PIR Motion Sensor's HIGH Det = "No"; } }
getRHT.ino
// RHT Temperature and Humidity Sensor // Setup RHT Temperature and Humidity Sensor void isSetupRTH03() { // RHT Temperature and Humidity Sensor // Call rht.begin() to initialize the sensor and our data pin rht.begin(RHT03_DATA_PIN); } // RHT Temperature and Humidity Sensor void isRHT03(){ // Call rht.update() to get new humidity and temperature values from the sensor. int updateRet = rht.update(); // The humidity(), tempC(), and tempF() functions can be called -- after // a successful update() -- to get the last humidity and temperature value latestHumidity = rht.humidity(); latestTempC = rht.tempC(); }
getRTC.ino
// DS3231 RTC Date and Time // Setup DS3231 RTC void isSetupRTC() { if (! rtc.begin()) { while (1); } if (rtc.lostPower()) { // Following line sets the RTC to the date & time this sketch was compiled rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); // This line sets the RTC with an explicit date & time, for example to set // January 21, 2014 at 3am you would call: // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0)); } } // DS3231 RTC Date and Time void isRTC(){ // Date and Time sDate = ""; sTime = ""; // Date Time DateTime now = rtc.now(); // sData sDate += String(now.year(), DEC); sDate += "/"; sDate += String(now.month(), DEC); sDate += "/"; sDate += String(now.day(), DEC); // sTime sTime += String(now.hour(), DEC); sTime += ":"; sTime += String(now.minute(), DEC); sTime += ":"; sTime += String(now.second(), DEC); }
getSD.ino
// MicroSD Card // MicroSD Setup void setupSD() { // MicroSD Card pinMode( chipSelect , OUTPUT ); if(!SD.begin( chipSelect )){ ; return; } uint8_t cardType = SD.cardType(); // CARD NONE if(cardType == CARD_NONE){ ; return; } // SD Card Type if(cardType == CARD_MMC){ ; } else if(cardType == CARD_SD){ ; } else if(cardType == CARD_SDHC){ ; } else { ; } // Size uint64_t cardSize = SD.cardSize() / (1024 * 1024); } // MicroSD Card void isSD() { zzzzzz = ""; // DFR|EEPROM Unique ID|Version|Date|Time|Temperature|Humidity|Lux| // Soil Moisture|Temperature|Humidity|MQ8|MQ9|MQ7|MQ3|PIR|*\r zzzzzz = "DFR|" + uid + "|" + sver + "|" + sDate + "|" + sTime + "|" + String(Temperature) + "C|" + String(Humidity) + "%|" + String(SData) + "|" + String(SDataSM) + "|" + String(latestTempC) + "C|" + String(latestHumidity) + "%|" + String(iMQ8ppm) + " PPM|" + String(iMQ9ppm) + " PPM|" + String(iMQ7ppm) + " PPM|" + String(iMQ3ppm) + "%|" + String(Det) + "|*\r"; // msg + 1 char msg[zzzzzz.length() + 1]; zzzzzz.toCharArray(msg, zzzzzz.length() + 1); // Append File appendFile(SD, "/dfrdata.txt", msg ); } // List Dir void listDir(fs::FS &fs, const char * dirname, uint8_t levels){ // List Dir dirname; File root = fs.open(dirname); if(!root){ return; } if(!root.isDirectory()){ return; } File file = root.openNextFile(); while(file){ if(file.isDirectory()){ file.name(); if(levels){ listDir(fs, file.name(), levels -1); } } else { file.name(); file.size(); } file = root.openNextFile(); } } // Write File void writeFile(fs::FS &fs, const char * path, const char * message){ // Write File path; File file = fs.open(path, FILE_WRITE); if(!file){ return; } if(file.print(message)){ ; } else { ; } file.close(); } // Append File void appendFile(fs::FS &fs, const char * path, const char * message){ // Append File path; File file = fs.open(path, FILE_APPEND); if(!file){ return; } if(file.print(message)){ ; } else { ; } file.close(); }
getSHT40.ino
// Fermion: SHT40 Temperature & Humidity Sensor // SHT40 Temperature & Humidity void isSHT40(){ // Fermion: SHT40 Temperature & Humidity Sensor // Temperature Temperature = (175 * TemperatureData/65535) - 45; // Humidity Humidity = (125 * HumidityData/65535) - 6; }
getSoilMoisture.ino
// Gravity: Analog Soil Moisture Sensor // Soil Moisture void isSoilMoisture(){ // SDataSM => 0~900 Soil Moisture SDataSM = map( SensorSM, 1, 3000, 0, 900); }
setup.ino
// Setup void setup() { // Give display time to power on delay(100); // EEPROM Size EEPROM.begin(EEPROM_SIZE); // EEPROM Unique ID isUID(); // Give display delay(100); // Set up I2C bus Wire.begin(); // Give display delay(100); // Setup BLE Scan isSetupBLEScan(); // Setup DS3231 RTC isSetupRTC(); //MicroSD Card setupSD(); // RHT Temperature and Humidity Sensor // Setup RTH03 Temperature and Humidity Sensor isSetupRTH03(); // PIR Motion // Setup PIR isSetupPIR(); // SHARP Display Start & Clear the Display display.begin(); // Clear Display display.clearDisplay(); // Initialize digital pin iLED as an output pinMode(iLED, OUTPUT); // Outputting high, the LED turns on digitalWrite(iLED, HIGH); // Initialize the LED Green pinMode(iLEDGreen, OUTPUT); // iLEDGreen HIGH digitalWrite(iLEDGreen, HIGH ); // Initialize the Switch pinMode(iSwitch, INPUT); // Don Luc Electronics // Version // EEPROM isDisplayUID(); // Delay 5 Second delay( 5000 ); }
——
People can contact us: https://www.donluc.com/?page_id=1927
Teacher, Instructor, E-Mentor, R&D and Consulting
- Programming Language
- Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi, Arm, Silicon Labs, Espressif, Etc…)
- IoT
- Wireless (Radio Frequency, Bluetooth, WiFi, Etc…)
- Robotics
- Automation
- Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
- Unmanned Vehicles Terrestrial and Marine
- Machine Learning
- Artificial Intelligence (AI)
- RTOS
- Sensors, eHealth Sensors, Biosensor, and Biometric
- Research & Development (R & D)
- Consulting
Follow Us
Luc Paquin – Curriculum Vitae – 2024
https://www.donluc.com/luc/
Web: https://www.donluc.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/@thesass2063
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/
LinkedIn: https://www.linkedin.com/in/jlucpaquin/
Don Luc
Project #29 – DFRobot – BLE Sensor Beacon – Mk12
——
#DonLucElectronics #DonLuc #DFRobot #BLESensorBeacon #AmbientLight #SoilMoisture #SHT40 #FireBeetle2ESP32E #EEPROM #RTC #SD #Display #Adafruit #ESP32 #IoT #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant
——
——
——
——
Fermion: BLE Sensor Beacon
Fermion: BLE Sensor Beacon, a wireless beacon that broadcasts sensor data via Bluetooth, with built-in 11-bit ADC acquisition and I2C write/read functionality, can be connected to digital or analogue sensors for data acquisition and broadcasting. Sensor data broadcasted by the beacon can be accessed within the beacon’s broadcast range using mobile phones, ESP32 and other devices that support BLE reception.
Fermion: BLE sensor beacons integrate low-power Bluetooth 5.3 technology with self-configurable data formats, such as iBeacon, Eddystone, user-defined, and more. The data format of the beacon broadcast, the content of the broadcast, the broadcast interval and so on can be configured through the graphical interface, without the need for any code programming to complete a Bluetooth beacon. After the configuration is completed, the device power supply is running as a Bluetooth beacon, which will automatically collect sensor data and broadcast to the outside world according to the configuration information. It is suitable for IoT sensor nodes, such as smart farms, offices, factories, warehouses and other scenarios in the data collection node.
DL2405Mk02
1 x DFRobot FireBeetle 2 ESP32-E
1 x Adafruit SHARP Memory Display
1 x Adafruit MicroSD card breakout board+
1 x MicroSD 16 GB
1 x Adafruit DS3231 Precision RTC FeatherWing – RTC
1 x Battery CR1220
1 x Gravity: Analog Soil Moisture Sensor
1 x Gravity: Analog Ambient Light Sensor
1 x Fermion: SHT40 Temperature & Humidity Sensor
3 x Fermion: BLE Sensor Beacon
3 x CR2032 Coin Cell Battery
1 x 1 x Lithium Ion Battery – 1000mAh
1 x Green LED
1 x Slide Switch
1 x SparkFun Serial Basic Breakout – CH340G
1 x SparkFun Cerberus USB Cable
1 x USB 3.1 Cable A to C
DFRobot FireBeetle 2 ESP32-E
LED – 2
DSCK – 12
DMOSI – 4
DSS – 16
SCK – 22
MOSI – 23
MISO – 19
CS – 13
SCL – 21
SDA – 22
LED – 14
VIN – +3.3V
GND – GND
——
DL2405Mk02p.ino
/****** Don Luc Electronics © ****** Software Version Information Project #29 - DFRobot - BLE Sensor Beacon - Mk12 29-12 DL2404Mk02p.ino 1 x DFRobot FireBeetle 2 ESP32-E 1 x Adafruit SHARP Memory Display 1 x Adafruit MicroSD card breakout board+ 1 x MicroSD 16 GB 1 x Adafruit DS3231 Precision RTC FeatherWing - RTC 1 x Battery CR1220 1 x Gravity: Analog Soil Moisture Sensor 1 x Gravity: Analog Ambient Light Sensor 1 x Fermion: SHT40 Temperature & Humidity Sensor 3 x Fermion: BLE Sensor Beacon 3 x CR2032 Coin Cell Battery 1 x 1 x Lithium Ion Battery - 1000mAh 1 x Green LED 1 x SparkFun Serial Basic Breakout - CH340G 1 x SparkFun Cerberus USB Cable 1 x USB 3.1 Cable A to C */ // Include the Library Code // EEPROM Library to Read and Write EEPROM // with Unique ID for Unit #include "EEPROM.h" // Wire #include <Wire.h> // Arduino #include <Arduino.h> // BLE Device #include <BLEDevice.h> // BLE Utils #include <BLEUtils.h> // BLEScan #include <BLEScan.h> // BLE Advertised Device #include <BLEAdvertisedDevice.h> // BLE Eddystone URL #include <BLEEddystoneURL.h> // BLE Eddystone TLM #include <BLEEddystoneTLM.h> // BLE Beacon #include <BLEBeacon.h> // DS3231 RTC Date and Time #include <RTClib.h> // SD Card #include "FS.h" #include "SD.h" #include "SPI.h" // SHARP Memory Display #include <Adafruit_SharpMem.h> #include <Adafruit_GFX.h> // ENDIAN_CHANGE #define ENDIAN_CHANGE_U16(x) ((((x)&0xFF00) >> 8) + (((x)&0xFF) << 8)) // DS3231 RTC Date and Time RTC_DS3231 rtc; String sDate; String sTime; // MicroSD Card const int chipSelect = 13; String zzzzzz = ""; // SHARP Memory Display #define SHARP_SCK 12 #define SHARP_MOSI 4 #define SHARP_SS 16 // Set the size of the display here, e.g. 144x168! Adafruit_SharpMem display(SHARP_SCK, SHARP_MOSI, SHARP_SS, 144, 168); // The currently-available SHARP Memory Display (144x168 pixels) // requires > 4K of microcontroller RAM; it WILL NOT WORK on Arduino Uno // or other <4K "classic" devices. #define BLACK 0 #define WHITE 1 // LED Green int iLEDGreen = 2; // Define LED int iLED = 14; // Fermion: SHT40 Temperature & Humidity Sensor // Temperature float TemperatureData; float Temperature; // Humidity float HumidityData; float Humidity; // Gravity: Analog Ambient Light Sensor float Sensor_Data; // SData => 1~6000 Lux float SData; // Gravity: Analog Soil Moisture Sensor float SensorSM; float SDataSM; // In seconds int scanTime = 5; // BLE Scan BLEScan *pBLEScan; // My Advertised Device Callbacks class MyAdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks { // onResult void onResult(BLEAdvertisedDevice advertisedDevice) { // Advertised Device if (advertisedDevice.haveName()) { // Name: Fermion: Sensor Beacon if(String(advertisedDevice.getName().c_str()) == "SHT40"){ // strManufacturerData std::string strManufacturerData = advertisedDevice.getManufacturerData(); uint8_t cManufacturerData[100]; strManufacturerData.copy((char *)cManufacturerData, strManufacturerData.length(), 0); // strManufacturerData.length for (int i = 0; i < strManufacturerData.length(); i++) { // cManufacturerData[i] cManufacturerData[i]; } // TemperatureData TemperatureData = int(cManufacturerData[2]<<8 | cManufacturerData[3]); // HumidityData HumidityData = int(cManufacturerData[5]<<8 | cManufacturerData[6]); } // Name: Fermion: Sensor Beacon if(String(advertisedDevice.getName().c_str()) == "Fermion: Sensor Beacon"){ // strManufacturerData std::string strManufacturerData = advertisedDevice.getManufacturerData(); uint8_t cManufacturerData[100]; strManufacturerData.copy((char *)cManufacturerData, strManufacturerData.length(), 0); // strManufacturerData.length for (int i = 0; i < strManufacturerData.length(); i++) { // cManufacturerData[i] cManufacturerData[i]; } // Sensor_Data Sensor_Data = int(cManufacturerData[2]<<8 | cManufacturerData[3]); } // Name: Fermion: Sensor Beacon if(String(advertisedDevice.getName().c_str()) == "Soil Moisture"){ // strManufacturerData std::string strManufacturerData = advertisedDevice.getManufacturerData(); uint8_t cManufacturerData[100]; strManufacturerData.copy((char *)cManufacturerData, strManufacturerData.length(), 0); // strManufacturerData.length for (int i = 0; i < strManufacturerData.length(); i++) { // cManufacturerData[i] cManufacturerData[i]; } // SensorSM SensorSM = int(cManufacturerData[2]<<8 | cManufacturerData[3]); } } } }; // EEPROM Unique ID Information #define EEPROM_SIZE 64 String uid = ""; // Software Version Information String sver = "29-12"; void loop() { // DS3231 RTC Date and Time isRTC(); // ScanResults isBLEScanResults(); // Fermion: SHT40 Temperature & Humidity Sensor isSHT40(); // Gravity: Analog Ambient Light Sensor isAmbientLight(); // Soil Moisture isSoilMoisture(); // Delay 4 Second delay(4000); // Display Date, Time, Temperature, Humidity isDisplayDTTH(); // MicroSD Card isSD(); // iLED HIGH digitalWrite(iLED, HIGH ); // Delay 1 Second delay(1000); }
getAmbientLight.ino
// Gravity: Analog Ambient Light Sensor // Ambient Light void isAmbientLight(){ // Analog Ambient Light Sensor // SData => 1~6000 Lux SData = map(Sensor_Data, 1, 3000, 1, 6000); }
getBLEScan.ino
// getBLEScan // Setup BLE Scan void isSetupBLEScan(){ // BLE Device BLEDevice::init(""); // Create new scan pBLEScan = BLEDevice::getScan(); // Set Advertised Device Callbacks pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks()); // Active scan uses more power, but get results faster pBLEScan->setActiveScan(true); // Set Interval pBLEScan->setInterval(100); // Less or equal setInterval value pBLEScan->setWindow(99); } // BLE Scan Results void isBLEScanResults(){ // Put your main code here, to run repeatedly: BLEScanResults foundDevices = pBLEScan->start(scanTime, false); // Delete results fromBLEScan buffer to release memory pBLEScan->clearResults(); }
getDisplay.ino
// SHARP Memory Display // SHARP Memory Display - UID void isDisplayUID() { // Text Display // Clear Display display.clearDisplay(); display.setRotation(4); display.setTextSize(3); display.setTextColor(BLACK); // Don Luc Electronics display.setCursor(0,10); display.println( "Don Luc" ); display.setTextSize(2); display.setCursor(0,40); display.println( "Electronics" ); // Version //display.setTextSize(3); display.setCursor(0,70); display.println( "Version" ); //display.setTextSize(2); display.setCursor(0,95); display.println( sver ); // EEPROM display.setCursor(0,120); display.println( "EEPROM" ); display.setCursor(0,140); display.println( uid ); // Refresh display.refresh(); delay( 100 ); } // Display Date, Time, Temperature, Humidity, Ambient Light, Soil Moisture void isDisplayDTTH() { // Text Display Date // Clear Display display.clearDisplay(); display.setRotation(4); display.setTextSize(2); display.setTextColor(BLACK); // Date display.setCursor(0,5); display.println( sDate ); // Time display.setCursor(0,30); display.println( sTime ); // Temperature display.setCursor(0,55); display.print( Temperature ); display.println( "C" ); // Humidity display.setCursor(0,80); display.print( Humidity ); display.println( "%" ); // Lux display.setCursor(0,105); display.println( SData ); // Soil Moisture display.setCursor(0,130); display.println( SDataSM ); // Refresh display.refresh(); delay( 100 ); }
getEEPROM.ino
// EEPROM // isUID EEPROM Unique ID void isUID() { // Is Unit ID uid = ""; for (int x = 0; x < 7; x++) { uid = uid + char(EEPROM.read(x)); } }
getRTC.ino
// DS3231 RTC Date and Time // Setup DS3231 RTC void isSetupRTC() { if (! rtc.begin()) { while (1); } if (rtc.lostPower()) { // Following line sets the RTC to the date & time this sketch was compiled rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); // This line sets the RTC with an explicit date & time, for example to set // January 21, 2014 at 3am you would call: // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0)); } } // DS3231 RTC Date and Time void isRTC(){ // Date and Time sDate = ""; sTime = ""; // Date Time DateTime now = rtc.now(); // sData sDate += String(now.year(), DEC); sDate += "/"; sDate += String(now.month(), DEC); sDate += "/"; sDate += String(now.day(), DEC); // sTime sTime += String(now.hour(), DEC); sTime += ":"; sTime += String(now.minute(), DEC); sTime += ":"; sTime += String(now.second(), DEC); }
getSD.ino
// MicroSD Card // MicroSD Setup void setupSD() { // MicroSD Card pinMode( chipSelect , OUTPUT ); if(!SD.begin( chipSelect )){ ; return; } uint8_t cardType = SD.cardType(); // CARD NONE if(cardType == CARD_NONE){ ; return; } // SD Card Type if(cardType == CARD_MMC){ ; } else if(cardType == CARD_SD){ ; } else if(cardType == CARD_SDHC){ ; } else { ; } // Size uint64_t cardSize = SD.cardSize() / (1024 * 1024); } // MicroSD Card void isSD() { zzzzzz = ""; // DFR|EEPROM Unique ID|Version|Date|Time|Temperature|Humidity|Lux| // Soil Moisture|*\r zzzzzz = "DFR|" + uid + "|" + sver + "|" + sDate + "|" + sTime + "|" + String(Temperature) + "C|" + String(Humidity) + "%|" + String(SData) + "|" + String(SDataSM) + "|*\r"; // msg + 1 char msg[zzzzzz.length() + 1]; zzzzzz.toCharArray(msg, zzzzzz.length() + 1); // Append File appendFile(SD, "/dfrdata.txt", msg ); } // List Dir void listDir(fs::FS &fs, const char * dirname, uint8_t levels){ // List Dir dirname; File root = fs.open(dirname); if(!root){ return; } if(!root.isDirectory()){ return; } File file = root.openNextFile(); while(file){ if(file.isDirectory()){ file.name(); if(levels){ listDir(fs, file.name(), levels -1); } } else { file.name(); file.size(); } file = root.openNextFile(); } } // Write File void writeFile(fs::FS &fs, const char * path, const char * message){ // Write File path; File file = fs.open(path, FILE_WRITE); if(!file){ return; } if(file.print(message)){ ; } else { ; } file.close(); } // Append File void appendFile(fs::FS &fs, const char * path, const char * message){ // Append File path; File file = fs.open(path, FILE_APPEND); if(!file){ return; } if(file.print(message)){ ; } else { ; } file.close(); }
getSHT40.ino
// Fermion: SHT40 Temperature & Humidity Sensor // SHT40 Temperature & Humidity void isSHT40(){ // Fermion: SHT40 Temperature & Humidity Sensor // Temperature Temperature = (175 * TemperatureData/65535) - 45; // Humidity Humidity = (125 * HumidityData/65535) - 6; }
getSoilMoisture.ino
// Gravity: Analog Soil Moisture Sensor // Soil Moisture void isSoilMoisture(){ // SDataSM => 0~900 Soil Moisture SDataSM = map( SensorSM, 1, 3000, 0, 900); }
setup.ino
// Setup void setup() { // Give display time to power on delay(100); // EEPROM Size EEPROM.begin(EEPROM_SIZE); // EEPROM Unique ID isUID(); // Give display delay(100); // Set up I2C bus Wire.begin(); // Give display delay(100); // Setup BLE Scan isSetupBLEScan(); // Setup DS3231 RTC isSetupRTC(); //MicroSD Card setupSD(); // SHARP Display Start & Clear the Display display.begin(); // Clear Display display.clearDisplay(); // Initialize digital pin iLED as an output pinMode(iLED, OUTPUT); // Outputting high, the LED turns on digitalWrite(iLED, HIGH); // Initialize the LED Green pinMode(iLEDGreen, OUTPUT); // iLEDGreen HIGH digitalWrite(iLEDGreen, HIGH ); // Don Luc Electronics // Version // EEPROM isDisplayUID(); // Delay 5 Second delay( 5000 ); }
——
People can contact us: https://www.donluc.com/?page_id=1927
Teacher, Instructor, E-Mentor, R&D and Consulting
- Programming Language
- Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi, Arm, Silicon Labs, Espressif, Etc…)
- IoT
- Wireless (Radio Frequency, Bluetooth, WiFi, Etc…)
- Robotics
- Automation
- Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
- Unmanned Vehicles Terrestrial and Marine
- Machine Learning
- Artificial Intelligence (AI)
- RTOS
- Sensors, eHealth Sensors, Biosensor, and Biometric
- Research & Development (R & D)
- Consulting
Follow Us
Luc Paquin – Curriculum Vitae – 2024
https://www.donluc.com/luc/
Web: https://www.donluc.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/@thesass2063
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/
LinkedIn: https://www.linkedin.com/in/jlucpaquin/
Don Luc
Project #29 – DFRobot – Display – Mk11
——
#DonLucElectronics #DonLuc #DFRobot #SHT40 #FireBeetle2ESP32E #EEPROM #RTC #SD #Display #Adafruit #ESP32 #IoT #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant
——
——
——
——
Adafruit SHARP Memory Display Breakout – 1.3″ 168×144 Monochrome
The 1.3″ 168×144 SHARP Memory LCD display is a cross between an eInk (e-Paper) display and an LCD. It has the ultra-low power usage of eInk and the fast-refresh rates of an LCD. This model has a gray background, and pixels show up as black-on-gray for a nice e-Reader type display. It does not have a backlight, but it is daylight readable. For dark/night reading you may need to illuminate the LCD area with external LEDs.
The bare display is 3 Volt powered and 3 Volt logic, so we placed it on a fully assembled & tested breakout board with a 3 Volt regulator and level shifting circuitry. Now you can use it safely with 3 Volt or 5 Volt power and logic. There are four mounting holes so you can easily attach it to a box.
The display is “Write Only” which means that it only needs 3 pins to send data. However, the downside of a write-only display is that the entire 168×144 bits must be buffered by the microcontroller driver. That means you cannot use this with an ATmega328 or ATmega32u4. You must use a high-RAM chip such as ATSAMD21, Teensy 3, ESP8266, ESP32, etc. On those chips, this display works great and looks wonderful.
DL2405Mk01
1 x DFRobot FireBeetle 2 ESP32-E
1 x Adafruit SHARP Memory Display
1 x Adafruit MicroSD card breakout board+
1 x MicroSD 16 GB
1 x Adafruit DS3231 Precision RTC FeatherWing – RTC
1 x Battery CR1220
1 x Fermion: SHT40 Temperature & Humidity Sensor
1 x Fermion: BLE Sensor Beacon
1 x CR2032 Coin Cell Battery
1 x 1 x Lithium Ion Battery – 1000mAh
1 x Green LED
1 x SparkFun Serial Basic Breakout – CH340G
1 x SparkFun Cerberus USB Cable
1 x USB 3.1 Cable A to C
DFRobot FireBeetle 2 ESP32-E
LED – 2
DSCK – 12
DMOSI – 4
DSS – 16
SCK – 22
MOSI – 23
MISO – 19
CS – 13
SCL – 21
SDA – 22
LED – 14
VIN – +3.3V
GND – GND
——
DL2405Mk01p.ino
/****** Don Luc Electronics © ****** Software Version Information Project #29 - DFRobot - Display - Mk11 29-11 DL2404Mk01p.ino 1 x DFRobot FireBeetle 2 ESP32-E 1 x Adafruit SHARP Memory Display 1 x Adafruit MicroSD card breakout board+ 1 x MicroSD 16 GB 1 x Adafruit DS3231 Precision RTC FeatherWing - RTC 1 x Battery CR1220 1 x Fermion: SHT40 Temperature & Humidity Sensor 1 x Fermion: BLE Sensor Beacon 1 x CR2032 Coin Cell Battery 1 x 1 x Lithium Ion Battery - 1000mAh 1 x Green LED 1 x SparkFun Serial Basic Breakout - CH340G 1 x SparkFun Cerberus USB Cable 1 x USB 3.1 Cable A to C */ // Include the Library Code // EEPROM Library to Read and Write EEPROM // with Unique ID for Unit #include "EEPROM.h" // Wire #include <Wire.h> // Arduino #include <Arduino.h> // BLE Device #include <BLEDevice.h> // BLE Utils #include <BLEUtils.h> // BLEScan #include <BLEScan.h> // BLE Advertised Device #include <BLEAdvertisedDevice.h> // BLE Eddystone URL #include <BLEEddystoneURL.h> // BLE Eddystone TLM #include <BLEEddystoneTLM.h> // BLE Beacon #include <BLEBeacon.h> // DS3231 RTC Date and Time #include <RTClib.h> // SD Card #include "FS.h" #include "SD.h" #include "SPI.h" // SHARP Memory Display #include <Adafruit_SharpMem.h> #include <Adafruit_GFX.h> // ENDIAN_CHANGE #define ENDIAN_CHANGE_U16(x) ((((x)&0xFF00) >> 8) + (((x)&0xFF) << 8)) // DS3231 RTC Date and Time RTC_DS3231 rtc; String sDate; String sTime; // MicroSD Card const int chipSelect = 13; String zzzzzz = ""; // SHARP Memory Display #define SHARP_SCK 12 #define SHARP_MOSI 4 #define SHARP_SS 16 // Set the size of the display here, e.g. 144x168! Adafruit_SharpMem display(SHARP_SCK, SHARP_MOSI, SHARP_SS, 144, 168); // The currently-available SHARP Memory Display (144x168 pixels) // requires > 4K of microcontroller RAM; it WILL NOT WORK on Arduino Uno // or other <4K "classic" devices. #define BLACK 0 #define WHITE 1 // LED Green int iLEDGreen = 2; // Define LED int iLED = 14; // Fermion: SHT40 Temperature & Humidity Sensor // Temperature float TemperatureData; float Temperature; // Humidity float HumidityData; float Humidity; // In seconds int scanTime = 5; // BLE Scan BLEScan *pBLEScan; // My Advertised Device Callbacks class MyAdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks { // onResult void onResult(BLEAdvertisedDevice advertisedDevice) { // Advertised Device if (advertisedDevice.haveName()) { // Name: Fermion: Sensor Beacon if(String(advertisedDevice.getName().c_str()) == "SHT40"){ // strManufacturerData std::string strManufacturerData = advertisedDevice.getManufacturerData(); uint8_t cManufacturerData[100]; strManufacturerData.copy((char *)cManufacturerData, strManufacturerData.length(), 0); // strManufacturerData.length for (int i = 0; i < strManufacturerData.length(); i++) { // cManufacturerData[i] cManufacturerData[i]; } // TemperatureData TemperatureData = int(cManufacturerData[2]<<8 | cManufacturerData[3]); // HumidityData HumidityData = int(cManufacturerData[5]<<8 | cManufacturerData[6]); } } } }; // EEPROM Unique ID Information #define EEPROM_SIZE 64 String uid = ""; // Software Version Information String sver = "29-11"; void loop() { // DS3231 RTC Date and Time isRTC(); // ScanResults isBLEScanResults(); // Fermion: SHT40 Temperature & Humidity Sensor isSHT40(); // Delay 3 Second delay(3000); // Display Date, Time, Temperature, Humidity isDisplayDTTH(); // MicroSD Card isSD(); // iLED HIGH digitalWrite(iLED, HIGH ); // Delay 1 Second delay(1000); }
getBLEScan.ino
// getBLEScan // Setup BLE Scan void isSetupBLEScan(){ // BLE Device BLEDevice::init(""); // Create new scan pBLEScan = BLEDevice::getScan(); // Set Advertised Device Callbacks pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks()); // Active scan uses more power, but get results faster pBLEScan->setActiveScan(true); // Set Interval pBLEScan->setInterval(100); // Less or equal setInterval value pBLEScan->setWindow(99); } // BLE Scan Results void isBLEScanResults(){ // Put your main code here, to run repeatedly: BLEScanResults foundDevices = pBLEScan->start(scanTime, false); // Delete results fromBLEScan buffer to release memory pBLEScan->clearResults(); }
getDisplay.ino
// SHARP Memory Display // SHARP Memory Display - UID void isDisplayUID() { // Text Display // Clear Display display.clearDisplay(); display.setRotation(4); display.setTextSize(3); display.setTextColor(BLACK); // Don Luc Electronics display.setCursor(0,10); display.println( "Don Luc" ); display.setTextSize(2); display.setCursor(0,40); display.println( "Electronics" ); // Version //display.setTextSize(3); display.setCursor(0,70); display.println( "Version" ); //display.setTextSize(2); display.setCursor(0,95); display.println( sver ); // EEPROM display.setCursor(0,120); display.println( "EEPROM" ); display.setCursor(0,140); display.println( uid ); // Refresh display.refresh(); delay( 100 ); } // Display Date, Time, Temperature, Humidity void isDisplayDTTH() { // Text Display Date // Clear Display display.clearDisplay(); display.setRotation(4); display.setTextSize(2); display.setTextColor(BLACK); // Date display.setCursor(0,5); display.println( sDate ); // Time display.setCursor(0,30); display.println( sTime ); // Temperature display.setCursor(0,55); display.print( Temperature ); display.println( "C" ); // Humidity display.setCursor(0,80); display.print( Humidity ); display.println( "%" ); // Refresh display.refresh(); delay( 100 ); }
getEEPROM.ino
// EEPROM // isUID EEPROM Unique ID void isUID() { // Is Unit ID uid = ""; for (int x = 0; x < 7; x++) { uid = uid + char(EEPROM.read(x)); } }
getRTC.ino
// DS3231 RTC Date and Time // Setup DS3231 RTC void isSetupRTC() { if (! rtc.begin()) { while (1); } if (rtc.lostPower()) { // Following line sets the RTC to the date & time this sketch was compiled rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); // This line sets the RTC with an explicit date & time, for example to set // January 21, 2014 at 3am you would call: // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0)); } } // DS3231 RTC Date and Time void isRTC(){ // Date and Time sDate = ""; sTime = ""; // Date Time DateTime now = rtc.now(); // sData sDate += String(now.year(), DEC); sDate += "/"; sDate += String(now.month(), DEC); sDate += "/"; sDate += String(now.day(), DEC); // sTime sTime += String(now.hour(), DEC); sTime += ":"; sTime += String(now.minute(), DEC); sTime += ":"; sTime += String(now.second(), DEC); }
getSD.ino
// MicroSD Card // MicroSD Setup void setupSD() { // MicroSD Card pinMode( chipSelect , OUTPUT ); if(!SD.begin( chipSelect )){ ; return; } uint8_t cardType = SD.cardType(); // CARD NONE if(cardType == CARD_NONE){ ; return; } // SD Card Type if(cardType == CARD_MMC){ ; } else if(cardType == CARD_SD){ ; } else if(cardType == CARD_SDHC){ ; } else { ; } // Size uint64_t cardSize = SD.cardSize() / (1024 * 1024); } // MicroSD Card void isSD() { zzzzzz = ""; // DFR|EEPROM Unique ID|Version|Date|Time|Temperature|Humidity|*\r zzzzzz = "DFR|" + uid + "|" + sver + "|" + sDate + "|" + sTime + "|" + String(Temperature) + "C|" + String(Humidity) + "%|*\r"; // msg + 1 char msg[zzzzzz.length() + 1]; zzzzzz.toCharArray(msg, zzzzzz.length() + 1); // Append File appendFile(SD, "/dfrdata.txt", msg ); } // List Dir void listDir(fs::FS &fs, const char * dirname, uint8_t levels){ // List Dir dirname; File root = fs.open(dirname); if(!root){ return; } if(!root.isDirectory()){ return; } File file = root.openNextFile(); while(file){ if(file.isDirectory()){ file.name(); if(levels){ listDir(fs, file.name(), levels -1); } } else { file.name(); file.size(); } file = root.openNextFile(); } } // Write File void writeFile(fs::FS &fs, const char * path, const char * message){ // Write File path; File file = fs.open(path, FILE_WRITE); if(!file){ return; } if(file.print(message)){ ; } else { ; } file.close(); } // Append File void appendFile(fs::FS &fs, const char * path, const char * message){ // Append File path; File file = fs.open(path, FILE_APPEND); if(!file){ return; } if(file.print(message)){ ; } else { ; } file.close(); }
getSHT40.ino
// Fermion: SHT40 Temperature & Humidity Sensor // SHT40 Temperature & Humidity void isSHT40(){ // Fermion: SHT40 Temperature & Humidity Sensor // Temperature Temperature = (175 * TemperatureData/65535) - 45; // Humidity Humidity = (125 * HumidityData/65535) - 6; }
setup.ino
// Setup void setup() { // Give display time to power on delay(100); // EEPROM Size EEPROM.begin(EEPROM_SIZE); // EEPROM Unique ID isUID(); // Give display delay(100); // Set up I2C bus Wire.begin(); // Give display delay(100); // Setup BLE Scan isSetupBLEScan(); // Setup DS3231 RTC isSetupRTC(); //MicroSD Card setupSD(); // SHARP Display Start & Clear the Display display.begin(); // Clear Display display.clearDisplay(); // Initialize digital pin iLED as an output pinMode(iLED, OUTPUT); // Outputting high, the LED turns on digitalWrite(iLED, HIGH); // Initialize the LED Green pinMode(iLEDGreen, OUTPUT); // iLEDGreen HIGH digitalWrite(iLEDGreen, HIGH ); // Don Luc Electronics // Version // EEPROM isDisplayUID(); // Delay 5 Second delay( 5000 ); }
——
People can contact us: https://www.donluc.com/?page_id=1927
Teacher, Instructor, E-Mentor, R&D and Consulting
- Programming Language
- Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi, Arm, Silicon Labs, Espressif, Etc…)
- IoT
- Wireless (Radio Frequency, Bluetooth, WiFi, Etc…)
- Robotics
- Automation
- Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
- Unmanned Vehicles Terrestrial and Marine
- Machine Learning
- Artificial Intelligence (AI)
- RTOS
- Sensors, eHealth Sensors, Biosensor, and Biometric
- Research & Development (R & D)
- Consulting
Follow Us
Luc Paquin – Curriculum Vitae – 2024
https://www.donluc.com/luc/
Web: https://www.donluc.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/@thesass2063
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/
LinkedIn: https://www.linkedin.com/in/jlucpaquin/
Don Luc
Project #26 – Radio Frequency – Universally Unique IDentifier – Mk27
——
#DonLucElectronics #DonLuc #RadioFrequency #Bluetooth #UUID #Display #SparkFun #Adafruit #BME280 #CCS811 #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant
——
——
——
——
Universally Unique IDentifier
A Universally Unique IDentifier (UUID) is a 128-bit label used for information in computer systems. When generated according to the standard methods, UUIDs are, for practical purposes, unique. Their uniqueness does not depend on a central registration authority or coordination between the parties generating them, unlike most other numbering schemes. While the probability that a UUID will be duplicated is not zero, it is generally considered close enough to zero to be negligible.
Thus, anyone can create a UUID and use it to identify something with near certainty that the identifier does not duplicate one that has already been, or will be, created to identify something else. Information labeled with UUIDs by independent parties can therefore be later combined into a single database or transmitted on the same channel, with a negligible probability of duplication. Adoption of UUIDs is widespread, with many computing platforms providing support for generating them and for parsing their textual representation.
DL2307Mk08
2 x SparkFun Thing Plus – ESP32 WROOM
1 x SparkFun BME280 – Temperature, Humidity, Barometric Pressure, and Altitude
1 x SparkFun Air Quality Breakout – CCS811
1 x Adafruit SHARP Memory Display Breakout
1 x Adalogger FeatherWing – RTC + SD
1 x 8 GB MicroSD Memory Card
1 x CR1220 3V Lithium Coin Cell Battery
2 x Lithium Ion Battery – 850mAh
2 x SparkFun Cerberus USB Cable
SparkFun Thing Plus – ESP32 WROOM (Server)
LED – LED_BUILTIN
SDA – Digital 23
SCL – Digital 22
RX2 – Bluetooth
TX2 – Bluetooth
VIN – +3.3V
GND – GND
——
DL2307Mk08ps.ino
/* ***** Don Luc Electronics © ***** Software Version Information Project #26 - Radio Frequency - Universally Unique IDentifier - Mk27 26-27 DL2307Mk08ps.ino 2 x SparkFun Thing Plus - ESP32 WROOM 1 x SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude 1 x SparkFun Air Quality Breakout - CCS811 1 x Adafruit SHARP Memory Display Breakout 1 x Adalogger FeatherWing - RTC + SD 1 x 8 GB MicroSD Memory Card 1 x CR1220 3V Lithium Coin Cell Battery 2 x Lithium Ion Battery - 850mAh 2 x SparkFun Cerberus USB Cable */ // Include the Library Code // BLE Device #include <BLEDevice.h> // BLE Utils #include <BLEUtils.h> // BLE Serve #include <BLEServer.h> // Two Wire Interface (TWI/I2C) #include <Wire.h> // SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude #include <SparkFunBME280.h> // SparkFun CCS811 - eCO2 & tVOC #include <SparkFunCCS811.h> // See the following for generating UUIDs: // https://www.uuidgenerator.net/ #define SERVICE_UUID "7c394dc4-49a8-4c22-8a5b-b1612d8c13c1" #define CHARACTERISTIC_UUID "a4c4cec2-f394-4f7a-b9de-89047feca74b" #define CHARACTERISTIC_TEM_UUID "74bd92c6-89d0-4387-823e-97e7e0fb7a2b" #define CHARACTERISTIC_HUM_UUID "1b63f246-b97f-4d2e-b8eb-f69e20a23a34" #define CHARACTERISTIC_BAR_UUID "43788175-37a7-4280-93c6-c690324d088e" #define CHARACTERISTIC_ALT_UUID "609deed9-a72d-45c3-aaba-14a73b0d8fda" #define CHARACTERISTIC_ECO_UUID "ab17aace-c0b9-4bd3-bb93-7715d9afaeea" #define CHARACTERISTIC_VOC_UUID "6a8bf86a-9d40-457c-9f7f-f13a3d6803f1" // Makes the chracteristic globlal static BLECharacteristic *pCharacteristicTEM; static BLECharacteristic *pCharacteristicHUM; static BLECharacteristic *pCharacteristicBAR; static BLECharacteristic *pCharacteristicALT; static BLECharacteristic *pCharacteristicECO; static BLECharacteristic *pCharacteristicVOC; // SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude BME280 myBME280; float BMEtempC = 0; float BMEhumid = 0; float BMEpressure = 0; float BMEaltitudeM = 0; String FullString = ""; // SparkFun CCS811 - eCO2 & tVOC // Default I2C Address #define CCS811_ADDR 0x5B CCS811 myCCS811(CCS811_ADDR); float CCS811CO2 = 0; float CCS811TVOC = 0; String FullStringA = ""; // Software Version Information String sver = "26-27"; void loop() { // SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude isBME280(); // SparkFun CCS811 - eCO2 & tVOC isCCS811(); // Delay 1 sec delay(1000); }
getBME280.ino
// SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude // isBME280 - Temperature, Humidity, Barometric Pressure, and Altitude void isBME280(){ // Temperature Celsius BMEtempC = myBME280.readTempC(); // Humidity BMEhumid = myBME280.readFloatHumidity(); // Barometric Pressure BMEpressure = myBME280.readFloatPressure(); // Altitude Meters BMEaltitudeM = (myBME280.readFloatAltitudeMeters(), 2); // setValue takes uint8_t, uint16_t, uint32_t, int, float, double and string pCharacteristicTEM->setValue(BMEtempC); pCharacteristicHUM->setValue(BMEhumid); pCharacteristicBAR->setValue(BMEpressure); pCharacteristicALT->setValue(BMEaltitudeM); // FullString FullString = "Temperature = " + String(BMEtempC,2) + " Humidity = " + String(BMEhumid,2) + " Barometric = " + String(BMEpressure,2) + " Altitude Meters = " + String(BMEaltitudeM,2) + "\r\n"; // FullString Bluetooth Serial + Serial for(int i = 0; i < FullString.length(); i++) { // Serial Serial.write(FullString.c_str()[i]); } }
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(); // setValue takes uint8_t, uint16_t, uint32_t, int, float, double and string pCharacteristicECO->setValue(CCS811CO2); pCharacteristicVOC->setValue(CCS811TVOC); // FullStringA FullStringA = "TVOCs = " + String(CCS811TVOC,2) + " eCO2 = " + String(CCS811CO2,2) + "\r\n"; // FullStringA Bluetooth Serial + Serial for(int i = 0; i < FullStringA.length(); i++) { // Serial Serial.write(FullStringA.c_str()[i]); } }
setup.ino
// Setup void setup() { // Serial Begin Serial.begin(115200); Serial.println("Starting BLE work!"); // Give display time to power on delay(100); // Wire - Inialize I2C Hardware Wire.begin(); // Give display time to power on delay(100); // SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude myBME280.begin(); // CCS811 - eCO2 & tVOC myCCS811.begin(); // Initialize digital pin LED_BUILTIN as an output pinMode(LED_BUILTIN, OUTPUT); // Turn the LED on HIGH digitalWrite(LED_BUILTIN, HIGH); // BLE Device Init BLEDevice::init("Don Luc Electronics Server"); BLEServer *pServer = BLEDevice::createServer(); BLEService *pService = pServer->createService(SERVICE_UUID); BLECharacteristic *pCharacteristic = pService->createCharacteristic( CHARACTERISTIC_UUID, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE ); pCharacteristicTEM = pService->createCharacteristic( CHARACTERISTIC_TEM_UUID, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE ); pCharacteristicHUM = pService->createCharacteristic( CHARACTERISTIC_HUM_UUID, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE ); pCharacteristicBAR = pService->createCharacteristic( CHARACTERISTIC_BAR_UUID, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE ); pCharacteristicALT = pService->createCharacteristic( CHARACTERISTIC_ALT_UUID, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE ); pCharacteristicVOC = pService->createCharacteristic( CHARACTERISTIC_VOC_UUID, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE ); pCharacteristicECO = pService->createCharacteristic( CHARACTERISTIC_ECO_UUID, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE ); pCharacteristic->setValue("Luc Paquin"); pService->start(); // This still is working for backward compatibility // BLEAdvertising *pAdvertising = pServer->getAdvertising(); // BLE Advertising BLEAdvertising *pAdvertising = BLEDevice::getAdvertising(); pAdvertising->addServiceUUID(SERVICE_UUID); pAdvertising->setScanResponse(true); // Functions that help with iPhone connections issue pAdvertising->setMinPreferred(0x06); pAdvertising->setMinPreferred(0x12); BLEDevice::startAdvertising(); }
——
SparkFun Thing Plus – ESP32 WROOM (Client)
LED – Digital 21
SCK – Digital 13
MOSI – Digital 12
SS – Digital 27
MISO – Digital 19
MOSI – Digital 18
SCK – Digital 5
CS – Digital 33
SDA – Digital 23
SCL – Digital 22
RX2 – Bluetooth
TX2 – Bluetooth
VIN – +3.3V
GND – GND
——
DL2307Mk08pr.ino
/* ***** Don Luc Electronics © ***** Software Version Information Project #26 - Radio Frequency - Universally Unique IDentifier - Mk27 26-27 DL2307Mk08pr.ino 2 x SparkFun Thing Plus - ESP32 WROOM 1 x SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude 1 x SparkFun Air Quality Breakout - CCS811 1 x Adafruit SHARP Memory Display Breakout 1 x Adalogger FeatherWing - RTC + SD 1 x 8 GB MicroSD Memory Card 1 x CR1220 3V Lithium Coin Cell Battery 2 x Lithium Ion Battery - 850mAh 2 x SparkFun Cerberus USB Cable */ // Include the Library Code // Bluetooth BLE Device #include "BLEDevice.h" // SHARP Memory Display #include <Adafruit_SharpMem.h> // Adafruit GFX Library #include <Adafruit_GFX.h> // Date and Time #include "RTClib.h" // SD Card #include "FS.h" #include "SD.h" #include "SPI.h" // 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, e.g. 144x168! Adafruit_SharpMem display(SHARP_SCK, SHARP_MOSI, SHARP_SS, 144, 168); // The currently-available SHARP Memory Display (144x168 pixels) // requires > 4K of microcontroller RAM; it WILL NOT WORK on Arduino Uno // or other <4K "classic" devices. #define BLACK 0 #define WHITE 1 // 1/2 of lesser of display width or height int minorHalfSize; // The remote service we wish to connect to. static BLEUUID serviceUUID("7c394dc4-49a8-4c22-8a5b-b1612d8c13c1"); // The characteristic of the remote service we are interested in. static BLEUUID charUUID("a4c4cec2-f394-4f7a-b9de-89047feca74b"); // Use the same UUID as on the server static BLEUUID charTEMUUID("74bd92c6-89d0-4387-823e-97e7e0fb7a2b"); static BLEUUID charHUMUUID("1b63f246-b97f-4d2e-b8eb-f69e20a23a34"); static BLEUUID charBARUUID("43788175-37a7-4280-93c6-c690324d088e"); static BLEUUID charALTUUID("609deed9-a72d-45c3-aaba-14a73b0d8fda"); static BLEUUID charECOUUID("ab17aace-c0b9-4bd3-bb93-7715d9afaeea"); static BLEUUID charVOCUUID("6a8bf86a-9d40-457c-9f7f-f13a3d6803f1"); static boolean doConnect = false; static boolean connected = false; static boolean doScan = false; static BLERemoteCharacteristic* pRemoteCharacteristic; static BLERemoteCharacteristic* pRemoteCharacteristicTEM; static BLERemoteCharacteristic* pRemoteCharacteristicHUM; static BLERemoteCharacteristic* pRemoteCharacteristicBAR; static BLERemoteCharacteristic* pRemoteCharacteristicALT; static BLERemoteCharacteristic* pRemoteCharacteristicECO; static BLERemoteCharacteristic* pRemoteCharacteristicVOC; static BLEAdvertisedDevice* myDevice; float TEMValue; float HUMValue; float BARValue; float ALTValue; float ECOValue; float VOCValue; int iLED = 21; // Date and Time // PCF8523 Precision RTC RTC_PCF8523 rtc; String dateRTC = ""; String timeRTC = ""; // microSD Card const int chipSelect = 33; String zzzzzz = ""; // Software Version Information String sver = "26-27"; void loop() { // Bluetooth BLE isBluetoothBLE(); // Date and Time isRTC(); // Display Environmental isDisplayEnvironmental(); // microSD Card isSD(); }
getBluetoothBLE.ino
// Bluetooth BLE // isBluetoothBLE void isBluetoothBLE(){ // If the flag "doConnect" is true then we have scanned for // and found the desired // BLE Server with which we wish to connect. Now we connect to it. // Once we are connected we set the connected flag to be true. if (doConnect == true) { if (connectToServer()) { Serial.println("We are now connected to the BLE Server."); } else { Serial.println("We have failed to connect to the server; there is nothin more we will do."); } doConnect = false; } // If we are connected to a peer BLE Server, update the characteristic each time we are reached // with the current time since boot. if (connected) { String newValue = "Time since boot: " + String(millis()/1000); //Serial.println("Setting new characteristic value to \"" + newValue + "\""); // Set the characteristic's value to be the array of bytes that is actually a string. // pRemoteCharacteristic->writeValue(newValue.c_str(), newValue.length());//***********JKO }else if(doScan){ BLEDevice::getScan()->start(0); // this is just example to start scan after disconnect, most likely there is better way to do it in arduino } // read the Characteristics and store them in a variable // This also makes the print command do float handling TEMValue = pRemoteCharacteristicTEM->readFloat(); HUMValue = pRemoteCharacteristicHUM->readFloat(); BARValue = pRemoteCharacteristicBAR->readFloat(); ALTValue = pRemoteCharacteristicALT->readFloat(); ECOValue = pRemoteCharacteristicECO->readFloat(); VOCValue = pRemoteCharacteristicVOC->readFloat(); } // Notify Callback static void notifyCallback( BLERemoteCharacteristic* pBLERemoteCharacteristic, uint8_t* pData, size_t length, bool isNotify) { Serial.print("Notify callback for characteristic "); Serial.print(pBLERemoteCharacteristic->getUUID().toString().c_str()); Serial.print(" of data length "); Serial.println(length); Serial.print("data: "); Serial.println((char*)pData); } // My Client Callback class MyClientCallback : public BLEClientCallbacks { void onConnect(BLEClient* pclient) { } void onDisconnect(BLEClient* pclient) { connected = false; Serial.println("onDisconnect"); } }; // Connect To Server bool connectToServer() { Serial.print("Forming a connection to "); Serial.println(myDevice->getAddress().toString().c_str()); BLEClient* pClient = BLEDevice::createClient(); Serial.println(" - Created client"); pClient->setClientCallbacks(new MyClientCallback()); // Connect to the remove BLE Server. // if you pass BLEAdvertisedDevice instead of address, //it will be recognized type of peer device address (public or private) pClient->connect(myDevice); Serial.println(" - Connected to server"); //set client to request maximum MTU from server (default is 23 otherwise) pClient->setMTU(517); // Obtain a reference to the service we are after in the remote BLE server. BLERemoteService* pRemoteService = pClient->getService(serviceUUID); if (pRemoteService == nullptr) { Serial.print("Failed to find our service UUID: "); Serial.println(serviceUUID.toString().c_str()); pClient->disconnect(); return false; } Serial.println(" - Found our service"); // Obtain a reference to the characteristic in the service of the remote BLE server. pRemoteCharacteristic = pRemoteService->getCharacteristic(charUUID); if (pRemoteCharacteristic == nullptr) { Serial.print("Failed to find our characteristic UUID: "); Serial.println(charUUID.toString().c_str()); pClient->disconnect(); return false; } Serial.println(" - Found our characteristic"); // Temperature Obtain a reference to the characteristic in the service // of the remote BLE server. pRemoteCharacteristicTEM = pRemoteService->getCharacteristic(charTEMUUID); if (pRemoteCharacteristicTEM == nullptr) { Serial.print("Failed to find our characteristic UUID Temperature: "); Serial.println(charTEMUUID.toString().c_str()); pClient->disconnect(); return false; } // Humidity Obtain a reference to the characteristic in the service // of the remote BLE server. pRemoteCharacteristicHUM = pRemoteService->getCharacteristic(charHUMUUID); if (pRemoteCharacteristicHUM == nullptr) { Serial.print("Failed to find our characteristic UUID Temperature: "); Serial.println(charHUMUUID.toString().c_str()); pClient->disconnect(); return false; } Serial.println(" - Found our characteristic"); // Barometric Obtain a reference to the characteristic in the service // of the remote BLE server. pRemoteCharacteristicBAR = pRemoteService->getCharacteristic(charBARUUID); if (pRemoteCharacteristicBAR == nullptr) { Serial.print("Failed to find our characteristic UUID Barometric: "); Serial.println(charBARUUID.toString().c_str()); pClient->disconnect(); return false; } Serial.println(" - Found our characteristic"); // Altitude Obtain a reference to the characteristic in the service // of the remote BLE server. pRemoteCharacteristicALT = pRemoteService->getCharacteristic(charALTUUID); if (pRemoteCharacteristicALT == nullptr) { Serial.print("Failed to find our characteristic UUID Altitude: "); Serial.println(charALTUUID.toString().c_str()); pClient->disconnect(); return false; } // eCO2 Concentration Obtain a reference to the characteristic in the service // of the remote BLE server. pRemoteCharacteristicECO = pRemoteService->getCharacteristic(charECOUUID); if (pRemoteCharacteristicECO == nullptr) { Serial.print("Failed to find our characteristic UUID eCO2 Concentration: "); Serial.println(charECOUUID.toString().c_str()); pClient->disconnect(); return false; } Serial.println(" - Found our characteristic"); // tVOC Concentration Obtain a reference to the characteristic in the service // of the remote BLE server. pRemoteCharacteristicVOC = pRemoteService->getCharacteristic(charVOCUUID); if (pRemoteCharacteristicVOC == nullptr) { Serial.print("Failed to find our characteristic UUID tVOC Concentration: "); Serial.println(charVOCUUID.toString().c_str()); pClient->disconnect(); return false; } Serial.println(" - Found our characteristic"); // Read the value of the characteristic. if(pRemoteCharacteristic->canRead()) { std::string value = pRemoteCharacteristic->readValue(); Serial.print("The characteristic value was: "); Serial.println(value.c_str()); } if(pRemoteCharacteristic->canNotify()) pRemoteCharacteristic->registerForNotify(notifyCallback); connected = true; return true; } /** * Scan for BLE servers and find the first one that advertises the service we are looking for. */ class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks { /** * Called for each advertising BLE server. */ void onResult(BLEAdvertisedDevice advertisedDevice) { Serial.print("BLE Advertised Device found: "); Serial.println(advertisedDevice.toString().c_str()); // We have found a device, let us now see if it contains the service we are looking for. if (advertisedDevice.haveServiceUUID() && advertisedDevice.isAdvertisingService(serviceUUID)) { BLEDevice::getScan()->stop(); myDevice = new BLEAdvertisedDevice(advertisedDevice); doConnect = true; doScan = true; } // Found our server } // onResult }; // MyAdvertisedDeviceCallbacks
getDisplay.ino
// Display // SHARP Memory Display - UID void isDisplayUID() { // Text Display // Clear Display display.clearDisplay(); display.setRotation(2); 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 ); display.setCursor(0,125); display.println( dateRTC ); display.setCursor(0,150); display.println( timeRTC ); // Refresh display.refresh(); delay( 5000 ); } // Display Environmental void isDisplayEnvironmental(){ // Text Display Environmental // Clear Display display.clearDisplay(); display.setRotation(2); display.setTextSize(2); display.setTextColor(BLACK); // Temperature Celsius display.setCursor(0,5); display.print( "T: " ); display.print( TEMValue ); display.println( "C" ); // Humidity display.setCursor(0,25); display.print( "H: " ); display.print( HUMValue ); display.println( "%" ); // Pressure display.setCursor(0,45); display.print( "B: " ); display.print( BARValue ); display.println( "" ); // Altitude Meters display.setCursor(0,65); display.print( "A: " ); display.print( ALTValue ); display.println( "M" ); // eCO2 Concentration display.setCursor(0,85); display.print( "C: " ); display.print( ECOValue ); display.println( "ppm" ); // tVOC Concentration display.setCursor(0,105); display.print( "V: " ); display.print( VOCValue ); display.println( "ppb" ); // Date display.setCursor(0,125); display.println( dateRTC ); // Time display.setCursor(0,145); display.println( timeRTC ); // Refresh display.refresh(); delay( 100 ); }
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(2023, 7, 24, 11, 0, 0)); } } // Date and Time RTC void isRTC () { // Date and Time dateRTC = ""; timeRTC = ""; DateTime now = rtc.now(); // Date dateRTC = now.year(), DEC; dateRTC = dateRTC + "/"; dateRTC = dateRTC + now.month(), DEC; dateRTC = dateRTC + "/"; dateRTC = dateRTC + now.day(), DEC; // Time timeRTC = now.hour(), DEC; timeRTC = timeRTC + ":"; timeRTC = timeRTC + now.minute(), DEC; timeRTC = timeRTC + ":"; timeRTC = timeRTC + now.second(), DEC; }
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 = ""; // BLE|Version|Date|Time|Temperature Celsius|Humidity|Barometric Pressure //|Altitude Meters|eCO2 Concentration|tVOC Concentration|* zzzzzz = "BLE|" + sver + "|" + dateRTC + "|" + timeRTC + "|" + TEMValue + "|" + HUMValue + "|" + BARValue + "|" + ALTValue + "|" + ECOValue + "|" + VOCValue + "|*\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() { // Serial Serial.begin(115200); Serial.println("Starting Arduino BLE Client application..."); // Initialize digital pin iLED as an output pinMode(iLED, OUTPUT); // Turn the LED on HIGH digitalWrite(iLED, HIGH); // SHARP Display start & clear the display display.begin(); display.clearDisplay(); // Date & Time RTC // PCF8523 Precision RTC setupRTC(); // Date & Time isRTC(); // Display UID isDisplayUID(); // microSD Card setupSD(); // Bluetooth BLE BLEDevice::init(""); // Give display time to power on delay(100); BLEScan* pBLEScan = BLEDevice::getScan(); pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks()); pBLEScan->setInterval(1349); pBLEScan->setWindow(449); pBLEScan->setActiveScan(true); pBLEScan->start(5, false); }
——
People can contact us: https://www.donluc.com/?page_id=1927
Technology Experience
- Programming Language
- Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
- IoT
- Wireless (Radio Frequency, Bluetooth, WiFi, Etc…)
- Robotics
- Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
- Unmanned Vehicles Terrestrial and Marine
- Machine Learning
- RTOS
- Research & Development (R & D)
Instructor, E-Mentor, STEAM, and Arts-Based Training
- Programming Language
- IoT
- PIC Microcontrollers
- Arduino
- Raspberry Pi
- Espressif
- Robotics
Follow Us
Luc Paquin – Curriculum Vitae – 2023
https://www.donluc.com/luc/
Web: https://www.donluc.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/@thesass2063
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/
Don Luc
Project #26 – Radio Frequency – Bluetooth Server and Client – Mk26
——
#DonLucElectronics #DonLuc #RadioFrequency #Bluetooth #Display #SparkFun #BME280 #CCS811 #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant
——
——
——
——-
Bluetooth Server and Client
Connect the SparkFun BME280 and CCS811 this is the “Server” board. Upload SparkFun Thing Plus the Server code to the board using the USB cable. When uploading is complete, disconnect this board from the computer. Now, connect the Lithium Ion battery to the “Server”. Next, connect the second SparkFun Thing Plus to your computer and upload the Client code to the board. We have two Arduino sketches to upload to the SparkFun Thing Plus boards. Upload the first sketch to the Server SparkFun Thing Plus and the second sketch to the Client SparkFun Thing Plus.
DL2307Mk07
2 x SparkFun Thing Plus – ESP32 WROOM
1 x SparkFun BME280 – Temperature, Humidity, Barometric Pressure, and Altitude
1 x SparkFun Air Quality Breakout – CCS811
1 x Adafruit SHARP Memory Display Breakout
2 x Lithium Ion Battery – 850mAh
2 x SparkFun Cerberus USB Cable
SparkFun Thing Plus – ESP32 WROOM (Server)
LED – LED_BUILTIN
SDA – Digital 23
SCL – Digital 22
RX2 – Bluetooth
TX2 – Bluetooth
VIN – +3.3V
GND – GND
——
DL2307Mk07ps.ino
/* ***** Don Luc Electronics © ***** Software Version Information Project #26 - Radio Frequency - Bluetooth Server and Client - Mk26 26-26 DL2307Mk07ps.ino 2 x SparkFun Thing Plus - ESP32 WROOM 1 x SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude 1 x SparkFun Air Quality Breakout - CCS811 1 x Adafruit SHARP Memory Display Breakout 2 x Lithium Ion Battery - 850mAh 2 x SparkFun Cerberus USB Cable */ // Include the Library Code // BLE Device #include <BLEDevice.h> // BLE Utils #include <BLEUtils.h> // BLE Serve #include <BLEServer.h> // Two Wire Interface (TWI/I2C) #include <Wire.h> // SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude #include <SparkFunBME280.h> // SparkFun CCS811 - eCO2 & tVOC #include <SparkFunCCS811.h> // See the following for generating UUIDs: // https://www.uuidgenerator.net/ #define SERVICE_UUID "7c394dc4-49a8-4c22-8a5b-b1612d8c13c1" #define CHARACTERISTIC_UUID "a4c4cec2-f394-4f7a-b9de-89047feca74b" #define CHARACTERISTIC_TEM_UUID "74bd92c6-89d0-4387-823e-97e7e0fb7a2b" #define CHARACTERISTIC_HUM_UUID "1b63f246-b97f-4d2e-b8eb-f69e20a23a34" #define CHARACTERISTIC_BAR_UUID "43788175-37a7-4280-93c6-c690324d088e" #define CHARACTERISTIC_ALT_UUID "609deed9-a72d-45c3-aaba-14a73b0d8fda" #define CHARACTERISTIC_ECO_UUID "ab17aace-c0b9-4bd3-bb93-7715d9afaeea" #define CHARACTERISTIC_VOC_UUID "6a8bf86a-9d40-457c-9f7f-f13a3d6803f1" // Makes the chracteristic globlal static BLECharacteristic *pCharacteristicTEM; static BLECharacteristic *pCharacteristicHUM; static BLECharacteristic *pCharacteristicBAR; static BLECharacteristic *pCharacteristicALT; static BLECharacteristic *pCharacteristicECO; static BLECharacteristic *pCharacteristicVOC; // SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude BME280 myBME280; float BMEtempC = 0; float BMEhumid = 0; float BMEpressure = 0; float BMEaltitudeM = 0; String FullString = ""; // SparkFun CCS811 - eCO2 & tVOC // Default I2C Address #define CCS811_ADDR 0x5B CCS811 myCCS811(CCS811_ADDR); float CCS811CO2 = 0; float CCS811TVOC = 0; String FullStringA = ""; // Software Version Information String sver = "26-26"; void loop() { // SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude isBME280(); // SparkFun CCS811 - eCO2 & tVOC isCCS811(); // Delay 1 sec delay(1000); }
getBME280.ino
// SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude // isBME280 - Temperature, Humidity, Barometric Pressure, and Altitude void isBME280(){ // Temperature Celsius BMEtempC = myBME280.readTempC(); // Humidity BMEhumid = myBME280.readFloatHumidity(); // Barometric Pressure BMEpressure = myBME280.readFloatPressure(); // Altitude Meters BMEaltitudeM = (myBME280.readFloatAltitudeMeters(), 2); // setValue takes uint8_t, uint16_t, uint32_t, int, float, double and string pCharacteristicTEM->setValue(BMEtempC); pCharacteristicHUM->setValue(BMEhumid); pCharacteristicBAR->setValue(BMEpressure); pCharacteristicALT->setValue(BMEaltitudeM); // FullString FullString = "Temperature = " + String(BMEtempC,2) + " Humidity = " + String(BMEhumid,2) + " Barometric = " + String(BMEpressure,2) + " Altitude Meters = " + String(BMEaltitudeM,2) + "\r\n"; // FullString Bluetooth Serial + Serial for(int i = 0; i < FullString.length(); i++) { // Serial Serial.write(FullString.c_str()[i]); } }
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(); // setValue takes uint8_t, uint16_t, uint32_t, int, float, double and string pCharacteristicECO->setValue(CCS811CO2); pCharacteristicVOC->setValue(CCS811TVOC); // FullStringA FullStringA = "TVOCs = " + String(CCS811TVOC,2) + " eCO2 = " + String(CCS811CO2,2) + "\r\n"; // FullStringA Bluetooth Serial + Serial for(int i = 0; i < FullStringA.length(); i++) { // Serial Serial.write(FullStringA.c_str()[i]); } }
setup.ino
// Setup void setup() { // Serial Begin Serial.begin(115200); Serial.println("Starting BLE work!"); // Give display time to power on delay(100); // Wire - Inialize I2C Hardware Wire.begin(); // Give display time to power on delay(100); // SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude myBME280.begin(); // CCS811 - eCO2 & tVOC myCCS811.begin(); // Initialize digital pin LED_BUILTIN as an output pinMode(LED_BUILTIN, OUTPUT); // Turn the LED on HIGH digitalWrite(LED_BUILTIN, HIGH); // BLE Device Init BLEDevice::init("Don Luc Electronics Server"); BLEServer *pServer = BLEDevice::createServer(); BLEService *pService = pServer->createService(SERVICE_UUID); BLECharacteristic *pCharacteristic = pService->createCharacteristic( CHARACTERISTIC_UUID, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE ); pCharacteristicTEM = pService->createCharacteristic( CHARACTERISTIC_TEM_UUID, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE ); pCharacteristicHUM = pService->createCharacteristic( CHARACTERISTIC_HUM_UUID, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE ); pCharacteristicBAR = pService->createCharacteristic( CHARACTERISTIC_BAR_UUID, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE ); pCharacteristicALT = pService->createCharacteristic( CHARACTERISTIC_ALT_UUID, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE ); pCharacteristicVOC = pService->createCharacteristic( CHARACTERISTIC_VOC_UUID, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE ); pCharacteristicECO = pService->createCharacteristic( CHARACTERISTIC_ECO_UUID, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE ); pCharacteristic->setValue("Luc Paquin"); pService->start(); // This still is working for backward compatibility // BLEAdvertising *pAdvertising = pServer->getAdvertising(); // BLE Advertising BLEAdvertising *pAdvertising = BLEDevice::getAdvertising(); pAdvertising->addServiceUUID(SERVICE_UUID); pAdvertising->setScanResponse(true); // Functions that help with iPhone connections issue pAdvertising->setMinPreferred(0x06); pAdvertising->setMinPreferred(0x12); BLEDevice::startAdvertising(); }
——
SparkFun Thing Plus – ESP32 WROOM (Client)
LED – Digital 21
SCK – Digital 13
MOSI – Digital 12
SS – Digital 27
RX2 – Bluetooth
TX2 – Bluetooth
VIN – +3.3V
GND – GND
——
DL2307Mk07pr.ino
/* ***** Don Luc Electronics © ***** Software Version Information Project #26 - Radio Frequency - Bluetooth Server and Client - Mk26 26-26 DL2307Mk07pr.ino 2 x SparkFun Thing Plus - ESP32 WROOM 1 x SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude 1 x SparkFun Air Quality Breakout - CCS811 1 x Adafruit SHARP Memory Display Breakout 2 x Lithium Ion Battery - 850mAh 2 x SparkFun Cerberus USB Cable */ // Include the Library Code // Bluetooth BLE Device #include "BLEDevice.h" // SHARP Memory Display #include <Adafruit_SharpMem.h> // Adafruit GFX Library #include <Adafruit_GFX.h> // 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, e.g. 144x168! Adafruit_SharpMem display(SHARP_SCK, SHARP_MOSI, SHARP_SS, 144, 168); // The currently-available SHARP Memory Display (144x168 pixels) // requires > 4K of microcontroller RAM; it WILL NOT WORK on Arduino Uno // or other <4K "classic" devices. #define BLACK 0 #define WHITE 1 // 1/2 of lesser of display width or height int minorHalfSize; // The remote service we wish to connect to. static BLEUUID serviceUUID("7c394dc4-49a8-4c22-8a5b-b1612d8c13c1"); // The characteristic of the remote service we are interested in. static BLEUUID charUUID("a4c4cec2-f394-4f7a-b9de-89047feca74b"); // Use the same UUID as on the server static BLEUUID charTEMUUID("74bd92c6-89d0-4387-823e-97e7e0fb7a2b"); static BLEUUID charHUMUUID("1b63f246-b97f-4d2e-b8eb-f69e20a23a34"); static BLEUUID charBARUUID("43788175-37a7-4280-93c6-c690324d088e"); static BLEUUID charALTUUID("609deed9-a72d-45c3-aaba-14a73b0d8fda"); static BLEUUID charECOUUID("ab17aace-c0b9-4bd3-bb93-7715d9afaeea"); static BLEUUID charVOCUUID("6a8bf86a-9d40-457c-9f7f-f13a3d6803f1"); static boolean doConnect = false; static boolean connected = false; static boolean doScan = false; static BLERemoteCharacteristic* pRemoteCharacteristic; static BLERemoteCharacteristic* pRemoteCharacteristicTEM; static BLERemoteCharacteristic* pRemoteCharacteristicHUM; static BLERemoteCharacteristic* pRemoteCharacteristicBAR; static BLERemoteCharacteristic* pRemoteCharacteristicALT; static BLERemoteCharacteristic* pRemoteCharacteristicECO; static BLERemoteCharacteristic* pRemoteCharacteristicVOC; static BLEAdvertisedDevice* myDevice; float TEMValue; float HUMValue; float BARValue; float ALTValue; float ECOValue; float VOCValue; int iLED = 21; // Software Version Information String sver = "26-26"; void loop() { isBluetoothBLE(); isDisplayEnvironmental(); }
getBluetoothBLE.ino
// Bluetooth BLE void isBluetoothBLE(){ // If the flag "doConnect" is true then we have scanned for // and found the desired // BLE Server with which we wish to connect. Now we connect to it. // Once we are connected we set the connected flag to be true. if (doConnect == true) { if (connectToServer()) { Serial.println("We are now connected to the BLE Server."); } else { Serial.println("We have failed to connect to the server; there is nothin more we will do."); } doConnect = false; } // If we are connected to a peer BLE Server, update the characteristic each time we are reached // with the current time since boot. if (connected) { String newValue = "Time since boot: " + String(millis()/1000); //Serial.println("Setting new characteristic value to \"" + newValue + "\""); // Set the characteristic's value to be the array of bytes that is actually a string. // pRemoteCharacteristic->writeValue(newValue.c_str(), newValue.length());//***********JKO }else if(doScan){ BLEDevice::getScan()->start(0); // this is just example to start scan after disconnect, most likely there is better way to do it in arduino } // read the Characteristics and store them in a variable // This also makes the print command do float handling TEMValue = pRemoteCharacteristicTEM->readFloat(); HUMValue = pRemoteCharacteristicHUM->readFloat(); BARValue = pRemoteCharacteristicBAR->readFloat(); ALTValue = pRemoteCharacteristicALT->readFloat(); ECOValue = pRemoteCharacteristicECO->readFloat(); VOCValue = pRemoteCharacteristicVOC->readFloat(); } // Notify Callback static void notifyCallback( BLERemoteCharacteristic* pBLERemoteCharacteristic, uint8_t* pData, size_t length, bool isNotify) { Serial.print("Notify callback for characteristic "); Serial.print(pBLERemoteCharacteristic->getUUID().toString().c_str()); Serial.print(" of data length "); Serial.println(length); Serial.print("data: "); Serial.println((char*)pData); } // My Client Callback class MyClientCallback : public BLEClientCallbacks { void onConnect(BLEClient* pclient) { } void onDisconnect(BLEClient* pclient) { connected = false; Serial.println("onDisconnect"); } }; // Connect To Server bool connectToServer() { Serial.print("Forming a connection to "); Serial.println(myDevice->getAddress().toString().c_str()); BLEClient* pClient = BLEDevice::createClient(); Serial.println(" - Created client"); pClient->setClientCallbacks(new MyClientCallback()); // Connect to the remove BLE Server. // if you pass BLEAdvertisedDevice instead of address, //it will be recognized type of peer device address (public or private) pClient->connect(myDevice); Serial.println(" - Connected to server"); //set client to request maximum MTU from server (default is 23 otherwise) pClient->setMTU(517); // Obtain a reference to the service we are after in the remote BLE server. BLERemoteService* pRemoteService = pClient->getService(serviceUUID); if (pRemoteService == nullptr) { Serial.print("Failed to find our service UUID: "); Serial.println(serviceUUID.toString().c_str()); pClient->disconnect(); return false; } Serial.println(" - Found our service"); // Obtain a reference to the characteristic in the service of the remote BLE server. pRemoteCharacteristic = pRemoteService->getCharacteristic(charUUID); if (pRemoteCharacteristic == nullptr) { Serial.print("Failed to find our characteristic UUID: "); Serial.println(charUUID.toString().c_str()); pClient->disconnect(); return false; } Serial.println(" - Found our characteristic"); // Temperature Obtain a reference to the characteristic in the service // of the remote BLE server. pRemoteCharacteristicTEM = pRemoteService->getCharacteristic(charTEMUUID); if (pRemoteCharacteristicTEM == nullptr) { Serial.print("Failed to find our characteristic UUID Temperature: "); Serial.println(charTEMUUID.toString().c_str()); pClient->disconnect(); return false; } // Humidity Obtain a reference to the characteristic in the service // of the remote BLE server. pRemoteCharacteristicHUM = pRemoteService->getCharacteristic(charHUMUUID); if (pRemoteCharacteristicHUM == nullptr) { Serial.print("Failed to find our characteristic UUID Temperature: "); Serial.println(charHUMUUID.toString().c_str()); pClient->disconnect(); return false; } Serial.println(" - Found our characteristic"); // Barometric Obtain a reference to the characteristic in the service // of the remote BLE server. pRemoteCharacteristicBAR = pRemoteService->getCharacteristic(charBARUUID); if (pRemoteCharacteristicBAR == nullptr) { Serial.print("Failed to find our characteristic UUID Barometric: "); Serial.println(charBARUUID.toString().c_str()); pClient->disconnect(); return false; } Serial.println(" - Found our characteristic"); // Altitude Obtain a reference to the characteristic in the service // of the remote BLE server. pRemoteCharacteristicALT = pRemoteService->getCharacteristic(charALTUUID); if (pRemoteCharacteristicALT == nullptr) { Serial.print("Failed to find our characteristic UUID Altitude: "); Serial.println(charALTUUID.toString().c_str()); pClient->disconnect(); return false; } // eCO2 Concentration Obtain a reference to the characteristic in the service // of the remote BLE server. pRemoteCharacteristicECO = pRemoteService->getCharacteristic(charECOUUID); if (pRemoteCharacteristicECO == nullptr) { Serial.print("Failed to find our characteristic UUID eCO2 Concentration: "); Serial.println(charECOUUID.toString().c_str()); pClient->disconnect(); return false; } Serial.println(" - Found our characteristic"); // tVOC Concentration Obtain a reference to the characteristic in the service // of the remote BLE server. pRemoteCharacteristicVOC = pRemoteService->getCharacteristic(charVOCUUID); if (pRemoteCharacteristicVOC == nullptr) { Serial.print("Failed to find our characteristic UUID tVOC Concentration: "); Serial.println(charVOCUUID.toString().c_str()); pClient->disconnect(); return false; } Serial.println(" - Found our characteristic"); // Read the value of the characteristic. if(pRemoteCharacteristic->canRead()) { std::string value = pRemoteCharacteristic->readValue(); Serial.print("The characteristic value was: "); Serial.println(value.c_str()); } if(pRemoteCharacteristic->canNotify()) pRemoteCharacteristic->registerForNotify(notifyCallback); connected = true; return true; } /** * Scan for BLE servers and find the first one that advertises the service we are looking for. */ class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks { /** * Called for each advertising BLE server. */ void onResult(BLEAdvertisedDevice advertisedDevice) { Serial.print("BLE Advertised Device found: "); Serial.println(advertisedDevice.toString().c_str()); // We have found a device, let us now see if it contains the service we are looking for. if (advertisedDevice.haveServiceUUID() && advertisedDevice.isAdvertisingService(serviceUUID)) { BLEDevice::getScan()->stop(); myDevice = new BLEAdvertisedDevice(advertisedDevice); doConnect = true; doScan = true; } // Found our server } // onResult }; // MyAdvertisedDeviceCallbacks
getDisplay.ino
// Display // SHARP Memory Display - UID void isDisplayUID() { // Text Display // Clear Display display.clearDisplay(); display.setRotation(2); 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 ); // Refresh display.refresh(); delay( 5000 ); } // Display Environmental void isDisplayEnvironmental(){ // Text Display Environmental // Clear Display display.clearDisplay(); display.setRotation(2); display.setTextSize(2); display.setTextColor(BLACK); // Temperature Celsius display.setCursor(0,5); display.print( "T: " ); display.print( TEMValue ); display.println( "C" ); // Humidity display.setCursor(0,25); display.print( "H: " ); display.print( HUMValue ); display.println( "%" ); // Pressure display.setCursor(0,45); display.print( "B: " ); display.print( BARValue ); display.println( "" ); // Altitude Meters display.setCursor(0,65); display.print( "A: " ); display.print( ALTValue ); display.println( "M" ); // eCO2 Concentration display.setCursor(0,85); display.print( "C: " ); display.print( ECOValue ); display.println( "ppm" ); // tVOC Concentration display.setCursor(0,105); display.print( "V: " ); display.print( VOCValue ); display.println( "ppb" ); // Refresh display.refresh(); delay( 100 ); }
setup.ino
// Setup void setup() { // Serial Serial.begin(115200); Serial.println("Starting Arduino BLE Client application..."); // Initialize digital pin iLED as an output pinMode(iLED, OUTPUT); // Turn the LED on HIGH digitalWrite(iLED, HIGH); // SHARP Display start & clear the display display.begin(); display.clearDisplay(); // Display UID isDisplayUID(); // Bluetooth BLE BLEDevice::init(""); // Give display time to power on delay(100); BLEScan* pBLEScan = BLEDevice::getScan(); pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks()); pBLEScan->setInterval(1349); pBLEScan->setWindow(449); pBLEScan->setActiveScan(true); pBLEScan->start(5, false); }
——
People can contact us: https://www.donluc.com/?page_id=1927
Technology Experience
- Programming Language
- Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
- IoT
- Wireless (Radio Frequency, Bluetooth, WiFi, Etc…)
- Robotics
- Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
- Unmanned Vehicles Terrestrial and Marine
- Machine Learning
- RTOS
- Research & Development (R & D)
Instructor, E-Mentor, STEAM, and Arts-Based Training
- Programming Language
- IoT
- PIC Microcontrollers
- Arduino
- Raspberry Pi
- Espressif
- Robotics
Follow Us
Luc Paquin – Curriculum Vitae – 2023
https://www.donluc.com/luc/
Web: https://www.donluc.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/@thesass2063
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/
Don Luc