Magnetometer
Project #29 – DFRobot – AltIMU-10 – Mk19
——
#DonLucElectronics #DonLuc #DFRobot #AltIMU10 #9DOF #GPS #FireBeetle2ESP32E #EEPROM #RTC #SD #Display #Pololu #ESP32 #IoT #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant
——
——
——
——
Pololu AltIMU-10 v5 Gyro, Accelerometer, Compass, and Altimeter
The Pololu AltIMU-10 v5 is a compact board that combines ST’s LSM6DS33 3-axis gyroscope and 3-axis accelerometer, LIS3MDL 3-axis magnetometer, and LPS25H digital barometer to form an inertial measurement unit (IMU) and altimeter. These sensors are great ICs, but their small packages make them difficult for the typical student or hobbyist to use. They also operate at voltages below 3.6 Volt, which can make interfacing difficult for microcontrollers operating at 5 Volt. The AltIMU-10 v5 addresses these issues by incorporating additional electronics, including a voltage regulator and a level-shifting circuit, while keeping the overall size as compact as possible. The board ships fully populated with its SMD components, including the LSM6DS33, LIS3MDL, and LPS25H.
Attitude and Heading Reference System (AHRS)
An attitude and heading reference system (AHRS) uses an inertial measurement unit (IMU) consisting of microelectromechanical system (MEMS) inertial sensors to measure the angular rate, acceleration, and Earth’s magnetic field. These measurements can then be used to derive an estimate of the object’s attitude. An AHRS typically includes a 3-axis gyroscope, a 3-axis accelerometer, and a 3-axis magnetometer to determine an estimate of a system’s orientation. Each of these sensors contribute different measurements to the combined system and each exhibit unique limitations.
DL2406Mk06
1 x DFRobot FireBeetle 2 ESP32-E
1 x Adafruit SHARP Memory Display
1 x Adafruit MicroSD card breakout board+
1 x MicroSD 16 GB
1 x Pololu AltIMU-10 v5
1 x GPS Receiver – GP-20U7
2 x Switch
1 x 1K Ohm
1 x 1 x Lithium Ion Battery – 1000mAh
1 x Green LED
1 x USB 3.1 Cable A to C
DFRobot FireBeetle 2 ESP32-E
LED – 2
DSCK – 4
DMOSI – 16
DSS – 17
SCK – 22
MOSI – 23
MISO – 19
CS – 13
GPR – 26
GPT – 25
SCL – 21
SDA – 22
LED – 14
SWI – 3
XAC – A0
YAC – A1
ZAC – A2
VIN – +3.3V
GND – GND
——
DL2406Mk06p.ino
/****** Don Luc Electronics © ****** Software Version Information Project #29 - DFRobot - AltIMU-10 - Mk19 29-19 DL2406Mk06p.ino DL2406Mk06 1 x DFRobot FireBeetle 2 ESP32-E 1 x Adafruit SHARP Memory Display 1 x Adafruit MicroSD card breakout board+ 1 x MicroSD 16 GB 1 x Pololu AltIMU-10 v5 1 x GPS Receiver - GP-20U7 2 x Switch 1 x 1K Ohm 1 x 1 x Lithium Ion Battery - 1000mAh 1 x Green LED 1 x USB 3.1 Cable A to C */ // Include the Library Code // EEPROM Library to Read and Write EEPROM // with Unique ID for Unit #include "EEPROM.h" // Wire #include <Wire.h> // SD Card #include "FS.h" #include "SD.h" #include "SPI.h" // SHARP Memory Display #include <Adafruit_SharpMem.h> #include <Adafruit_GFX.h> // GPS Receiver #include <TinyGPS++.h> // ESP32 Hardware Serial #include <HardwareSerial.h> // Includes and variables for IMU integration // STMicroelectronics LSM6DS33 Gyroscope and Accelerometer #include <LSM6.h> // STMicroelectronics LIS3MDL Magnetometer #include <LIS3MDL.h> // STMicroelectronics LPS25H digital Barometer #include <LPS.h> // Earth's magnetic field varies by location. Add or subtract // a declination to get a more accurate heading. Calculate // your's here: http://www.ngdc.noaa.gov/geomag-web/#declination // Declination (degrees) in Mexicali #define DECLINATION 10.31 // 9DoF IMU // STMicroelectronics LSM6DS33 Gyroscope and Accelerometer LSM6 imu; // Accelerometer and Gyroscopes // Accelerometer int imuAX; int imuAY; int imuAZ; //String FullStringB = ""; // Gyroscopes int imuGX; int imuGY; int imuGZ; // STMicroelectronics LIS3MDL magnetometer LIS3MDL mag; // Magnetometer int magX; int magY; int magZ; // STMicroelectronics LPS25H digital barometer LPS ps; // Digital Barometer float pressure; float altitude; float temperature; // Attitude Calculate Pitch, Roll, and Headind float r; float p; float h; // ESP32 HardwareSerial HardwareSerial tGPS(2); // GPS Receiver #define gpsRXPIN 26 // This one is unused and doesnt have a conection #define gpsTXPIN 25 // The TinyGPS++ object TinyGPSPlus gps; // Latitude float TargetLat; // Longitude float TargetLon; // GPS Date, Time, Speed, Altitude // GPS Date String TargetDat; // GPS Time String TargetTim; // GPS Speeds M/S String TargetSMS; // GPS Speeds Km/h String TargetSKH; // GPS Altitude Meters String TargetALT; // GPS Status String GPSSt = ""; // MicroSD Card const int chipSelect = 13; String zzzzzz = ""; // SHARP Memory Display #define SHARP_SCK 4 #define SHARP_MOSI 16 #define SHARP_SS 17 // Set the size of the display here, e.g. 144x168! Adafruit_SharpMem display(SHARP_SCK, SHARP_MOSI, SHARP_SS, 144, 168); // The currently-available SHARP Memory Display (144x168 pixels) // requires > 4K of microcontroller RAM; it WILL NOT WORK on Arduino Uno // or other <4K "classic" devices. #define BLACK 0 #define WHITE 1 // LED Green int iLEDGreen = 2; // Define LED int iLED = 14; // Switch int iSwitch = 3; // Variable for reading the Switch status int iSwitchState = 0; // EEPROM Unique ID Information #define EEPROM_SIZE 64 String uid = ""; // Software Version Information String sver = "29-19"; void loop() { // Accelerometer and Gyroscopes isIMU(); // Magnetometer isMag(); // Barometer isBarometer(); // Attitude Calculate Pitch, Roll, and Heading isAttitude(imuAX, imuAY, imuAZ, -imuGY, -imuGX, imuGZ); // isGPS isGPS(); // Read the state of the Switch value iSwitchState = digitalRead(iSwitch); // The Switch is HIGH: if (iSwitchState == HIGH) { // Attitude Calculate Pitch, Roll, and Heading and Barometer isDisplayAttitude(); } else { // Display GPS isDisplayGPS(); } // MicroSD Card isSD(); // iLED HIGH digitalWrite(iLED, HIGH ); // Delay 5 Second delay(5000); }
getAccelGyro.ino
// Accelerometer and Gyroscopes // Setup IMU void isSetupIMU() { // Setup IMU imu.init(); // Default imu.enableDefault(); } // Accelerometer and Gyroscopes void isIMU() { // Accelerometer and Gyroscopes imu.read(); // Accelerometer x, y, z imuAX = imu.a.x; imuAY = imu.a.y; imuAZ = imu.a.z; // Gyroscopes x, y, z imuGX = imu.g.x; imuGY = imu.g.y; imuGZ = imu.g.z; }
getAttitude.ino
// Attitude Calculate Pitch, Roll, and Heading void isAttitude(float ax, float ay, float az, float mx, float my, float mz) { // Attitude Calculate Pitch, Roll, and Heading float roll = atan2(ay, az); float pitch = atan2(-ax, sqrt(ay * ay + az * az)); float heading; if (my == 0) heading = (mx < 0) ? PI : 0; else heading = atan2(mx, my); heading -= DECLINATION * PI / 180; if (heading > PI) heading -= (2 * PI); else if (heading < -PI) heading += (2 * PI); // Convert everything from radians to degrees: heading *= 180.0 / PI; pitch *= 180.0 / PI; roll *= 180.0 / PI; h = heading; p = pitch; r = roll; }
getBarometer.ino
// STMicroelectronics LPS25H digital barometer // Setup Barometer void isSetupBarometer(){ // Setup Barometer ps.init(); // Default ps.enableDefault(); } // Barometer void isBarometer(){ // Barometer pressure = ps.readPressureMillibars(); // Altitude Meters altitude = ps.pressureToAltitudeMeters(pressure); // Temperature Celsius temperature = ps.readTemperatureC(); }
getDisplay.ino
// SHARP Memory Display // SHARP Memory Display - UID void isDisplayUID() { // Text Display // Clear Display display.clearDisplay(); display.setRotation(4); display.setTextSize(3); display.setTextColor(BLACK); // Don Luc Electronics display.setCursor(0,10); display.println( "Don Luc" ); display.setTextSize(2); display.setCursor(0,40); display.println( "Electronics" ); // Version //display.setTextSize(3); display.setCursor(0,70); display.println( "Version" ); //display.setTextSize(2); display.setCursor(0,95); display.println( sver ); // EEPROM display.setCursor(0,120); display.println( "EEPROM" ); display.setCursor(0,140); display.println( uid ); // Refresh display.refresh(); delay( 100 ); } // Attitude Calculate Pitch, Roll, and Heading void isDisplayAttitude() { // Text Display // Clear Display display.clearDisplay(); display.setRotation(4); display.setTextSize(2); display.setTextColor(BLACK); // Pitch display.setCursor(0,5); display.print( "Pi: " ); display.println( p ); // Roll display.setCursor(0,25); display.print( "Ro: " ); display.println( r ); // Heading display.setCursor(0,45); display.print( "He: " ); display.println( h ); // Temperature Celsius display.setCursor(0,65); display.print( "Te: " ); display.println( temperature ); // Barometer display.setCursor(0,85); display.print( "Ba: " ); display.println( pressure ); // Altitude Meters display.setCursor(0,105); display.print( "Al: " ); display.println( altitude ); // Refresh display.refresh(); delay( 100 ); } // Display GPS void isDisplayGPS() { // Text Display Date // Clear Display display.clearDisplay(); display.setRotation(4); display.setTextSize(2); display.setTextColor(BLACK); // Latitude display.setCursor(0,5); display.print( "Lat: " ); display.println( TargetLat ); // Longitude display.setCursor(0,30); display.print( "Lon: " ); display.println( TargetLon ); // GPS Date display.setCursor(0,55); display.println( TargetDat ); // GPS Time display.setCursor(0,80); display.println( TargetTim ); // GPS Speed M/S display.setCursor(0,105); display.print( TargetSMS ); display.println( " M/S" ); // GPS Altitude Meters display.setCursor(0,130); display.print( TargetALT ); display.println( " M" ); // Refresh display.refresh(); delay( 100 ); }
getEEPROM.ino
// EEPROM // isUID EEPROM Unique ID void isUID() { // Is Unit ID uid = ""; for (int x = 0; x < 7; x++) { uid = uid + char(EEPROM.read(x)); } }
getGPS.ino
// GPS Receiver // Setup GPS void isSetupGPS() { // Setup GPS tGPS.begin( 9600 , SERIAL_8N1 , gpsRXPIN , gpsTXPIN ); } // isGPS void isGPS(){ // Receives NEMA data from GPS receiver // This sketch displays information every time a new sentence is correctly encoded while ( tGPS.available() > 0) if (gps.encode( tGPS.read() )) { // GPS Vector Pointer Target displayInfo(); // GPS Date, Time, Speed, Altitude displayDTS(); } if (millis() > 5000 && gps.charsProcessed() < 10) { while(true); } } // GPS Vector Pointer Target void displayInfo(){ // Location if (gps.location.isValid()) { // Latitude TargetLat = gps.location.lat(); // Longitude TargetLon = gps.location.lng(); // GPS Status 2 GPSSt = "Yes"; } else { // GPS Status 0 GPSSt = "No"; } } // GPS Date, Time, Speed, Altitude void displayDTS(){ // Date TargetDat = ""; if (gps.date.isValid()) { // Date // Year TargetDat += String(gps.date.year(), DEC); TargetDat += "/"; // Month TargetDat += String(gps.date.month(), DEC); TargetDat += "/"; // Day TargetDat += String(gps.date.day(), DEC); } // Time TargetTim = ""; if (gps.time.isValid()) { // Time // Hour TargetTim += String(gps.time.hour(), DEC); TargetTim += ":"; // Minute TargetTim += String(gps.time.minute(), DEC); TargetTim += ":"; // Secound TargetTim += String(gps.time.second(), DEC); } // Speed TargetSMS = ""; TargetSKH = ""; if (gps.speed.isValid()) { // Speed // M/S int x = gps.speed.mps(); TargetSMS = String( x, DEC); // Km/h int y = gps.speed.kmph(); TargetSKH = String( y, DEC); } // Altitude TargetALT = ""; if (gps.altitude.isValid()) { // Altitude // Meters int z = gps.altitude.meters(); TargetALT = String( z, DEC); } }
getMagnetometer.ino
// Magnetometer // Setup Magnetometer void isSetupMag() { // Setup Magnetometer mag.init(); // Default mag.enableDefault(); } // Magnetometer void isMag() { // Magnetometer mag.read(); // Magnetometer x, y, z magX = mag.m.x; magY = mag.m.y; magZ = mag.m.z; }
getSD.ino
// MicroSD Card // MicroSD Setup void isSetupSD() { // MicroSD Card pinMode( chipSelect , OUTPUT ); if(!SD.begin( chipSelect )){ ; return; } uint8_t cardType = SD.cardType(); // CARD NONE if(cardType == CARD_NONE){ ; return; } // SD Card Type if(cardType == CARD_MMC){ ; } else if(cardType == CARD_SD){ ; } else if(cardType == CARD_SDHC){ ; } else { ; } // Size uint64_t cardSize = SD.cardSize() / (1024 * 1024); } // MicroSD Card void isSD() { zzzzzz = ""; //DFR|EEPROM Unique ID|Version| //Accelerometer X|Accelerometer Y|Accelerometer Z| //Gyroscope X|Gyroscope Y|Gyroscope Z| //Magnetometer X|Magnetometer Y|Magnetometer Z| //Pitch|Roll|Heading| //Temperature C|Pressure Millibars|Altitude Meters| //GPS|Latitude|Longitude|GPS Date|GPS Time|GPS Speed M/S|GPS Altitude|*\r zzzzzz = "DFR|" + uid + "|" + sver + "|" + String(imuAX) + "|" + String(imuAY) + "|" + String(imuAZ) + "|" + String(imuGX) + "|" + String(imuGY) + "|" + String(imuGZ) + "|" + String(magX) + "|" + String(magY) + "|" + String(magZ) + "|" + String(p) + "|" + String(r) + "|" + String(h) + "|" + String(temperature) + "|" + String(pressure) + "|" + String(altitude) + "|" + String(GPSSt) + "|" + String(TargetLat) + "|" + String(TargetLon) + "|" + String(TargetDat) + "|" + String(TargetTim) + "|" + String(TargetSMS) + "|" + String(TargetALT)+ "|*\r"; // msg + 1 char msg[zzzzzz.length() + 1]; zzzzzz.toCharArray(msg, zzzzzz.length() + 1); // Append File appendFile(SD, "/dfrdata.txt", msg ); } // List Dir void listDir(fs::FS &fs, const char * dirname, uint8_t levels){ // List Dir dirname; File root = fs.open(dirname); if(!root){ return; } if(!root.isDirectory()){ return; } File file = root.openNextFile(); while(file){ if(file.isDirectory()){ file.name(); if(levels){ listDir(fs, file.name(), levels -1); } } else { file.name(); file.size(); } file = root.openNextFile(); } } // Write File void writeFile(fs::FS &fs, const char * path, const char * message){ // Write File path; File file = fs.open(path, FILE_WRITE); if(!file){ return; } if(file.print(message)){ ; } else { ; } file.close(); } // Append File void appendFile(fs::FS &fs, const char * path, const char * message){ // Append File path; File file = fs.open(path, FILE_APPEND); if(!file){ return; } if(file.print(message)){ ; } else { ; } file.close(); }
setup.ino
// Setup void setup() { // Give display time to power on delay(100); // EEPROM Size EEPROM.begin(EEPROM_SIZE); // EEPROM Unique ID isUID(); // Give display delay(100); // Set up I2C bus Wire.begin(); // Give display delay(100); //MicroSD Card isSetupSD(); // SHARP Display Start & Clear the Display display.begin(); // Clear Display display.clearDisplay(); // Delay delay( 100 ); // GPS Receiver // Setup GPS isSetupGPS(); // Delay delay( 100 ); // Setup IMU isSetupIMU(); // Setup Magnetometer isSetupMag(); // Setup Barometer isSetupBarometer(); // Delay delay( 100 ); // Initialize digital pin iLED as an output pinMode(iLED, OUTPUT); // Outputting high, the LED turns on digitalWrite(iLED, HIGH); // Initialize the LED Green pinMode(iLEDGreen, OUTPUT); // iLEDGreen HIGH digitalWrite(iLEDGreen, HIGH ); // Initialize the Switch pinMode(iSwitch, INPUT); // Don Luc Electronics // Version // EEPROM isDisplayUID(); // Delay 5 Second delay( 5000 ); }
——
People can contact us: https://www.donluc.com/?page_id=1927
Teacher, Instructor, E-Mentor, R&D and Consulting
- Programming Language
- Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi, Arm, Silicon Labs, Espressif, Etc…)
- IoT
- Wireless (Radio Frequency, Bluetooth, WiFi, Etc…)
- Robotics
- Automation
- Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
- Unmanned Vehicles Terrestrial and Marine
- Machine Learning
- Artificial Intelligence (AI)
- RTOS
- Sensors, eHealth Sensors, Biosensor, and Biometric
- Research & Development (R & D)
- Consulting
Follow Us
Luc Paquin – Curriculum Vitae – 2024
https://www.donluc.com/luc/
Web: https://www.donluc.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/@thesass2063
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/
LinkedIn: https://www.linkedin.com/in/jlucpaquin/
Don Luc
Project #29 – DFRobot – L3G4200D – Mk18
——
#DonLucElectronics #DonLuc #DFRobot #L3G4200D #HMC5883L #ADXL335 #GPS #FireBeetle2ESP32E #EEPROM #RTC #SD #Display #SparkFun #ESP32 #IoT #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant
——
——
——
——
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 #28 – Sensors – HC-SR04 – Mk12
——
#DonLucElectronics #DonLuc #Sensors #LSM9DS1 #IMU #GPSReceiver #Adafruit #SparkFun #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant
——
——
——
——
Pololu 5 Volt Step-Up Voltage Regulator U1V10F5
This tiny U1V10F5 switching step-up voltage regulator efficiently generates 5 Volt from input voltages as low as 0.5 Volt. Unlike most boost regulators, the U1V10F5 automatically switches to a linear down-regulation mode when the input voltage exceeds the output.
Ultrasonic Distance Sensor – HC-SR04 (5 Volt)
This is the HC-SR04 ultrasonic distance sensor. This economical sensor provides 2 Centimetres to 400 Centimetres of non-contact measurement functionality with a ranging accuracy that can reach up to 3 Millimetres. Each HC-SR04 module includes an ultrasonic transmitter, a receiver and a control circuit. There are only four pins that you need to worry about on the HC-SR04: VCC (Power), Trig (Trigger), Echo (Receive), and GND (Ground). This sensor has additional control circuitry that can prevent inconsistent “Bouncy” data depending on the application.
DL2310Mk01
1 x SparkFun Thing Plus – ESP32 WROOM
1 x DS3231 Precision RTC FeatherWing
1 x GPS Receiver – GP-20U7 (56 Channel)
1 x SparkFun 9DoF IMU Breakout – LSM9DS1
1 x Ultrasonic Distance Sensor – HC-SR04 (5V)
1 x Pololu 5V Step-Up Voltage Regulator U1V10F5
1 x Rocker Switch – SPST
1 x Resistor 10K Ohm
1 x CR1220 3V Lithium Coin Cell Battery
1 x 1 x Lithium Ion Battery – 1000mAh
1 x Terminal Block Breakout FeatherWing
1 x SparkFun Cerberus USB Cable
SparkFun Thing Plus – ESP32 WROOM
LED – LED_BUILTIN
SDA – Digital 23
SCL – Digital 22
SW1 – Digital 21
GPT – Digital 17
GPR – Digital 16
TRI – Digital 15
ECH – Digital 14
VIN – +3.3V
VIN – +5V
GND – GND
——
DL2310Mk01p.ino
/****** Don Luc Electronics © ****** Software Version Information Project #28 - Sensors - HC-SR04 - Mk12 28-12 DL2310Mk01p.ino 1 x SparkFun Thing Plus - ESP32 WROOM 1 x DS3231 Precision RTC FeatherWing 1 x GPS Receiver - GP-20U7 (56 Channel) 1 x SparkFun 9DoF IMU Breakout - LSM9DS1 1 x Ultrasonic Distance Sensor - HC-SR04 (5V) 1 x Pololu 5V Step-Up Voltage Regulator U1V10F5 1 x Rocker Switch - SPST 1 x Resistor 10K Ohm 1 x Lithium Ion Battery - 1000mAh 1 x CR1220 3V Lithium Coin Cell Battery 1 x Terminal Block Breakout FeatherWing 1 x SparkFun Cerberus USB Cable */ // Include the Library Code // Bluetooth LE keyboard #include <BleKeyboard.h> // Two Wire Interface (TWI/I2C) #include <Wire.h> // Serial Peripheral Interface #include <SPI.h> // DS3231 Precision RTC #include <RTClib.h> // GPS Receiver #include <TinyGPS++.h> // ESP32 Hardware Serial #include <HardwareSerial.h> // LSM9DS1 9DOF Sensor #include <SparkFunLSM9DS1.h> // Bluetooth LE Keyboard BleKeyboard bleKeyboard; String sKeyboard = ""; // Send Size byte sendSize = 0; // DS3231 Precision RTC RTC_DS3231 rtc; String dateRTC = ""; String timeRTC = ""; // GPS Receiver #define gpsRXPIN 16 // This one is unused and doesnt have a conection #define gpsTXPIN 17 // The TinyGPS++ object TinyGPSPlus gps; // Latitude float TargetLat; // Longitude float TargetLon; // GPS Date, Time // GPS Date String TargetDat; // GPS Time String TargetTim; // GPS Status String GPSSt = ""; // ESP32 HardwareSerial HardwareSerial tGPS(2); // LSM9DS1 9DOF Sensor LSM9DS1 imu; #define PRINT_CALCULATED // Earth's magnetic field varies by location. Add or subtract // a declination to get a more accurate heading. Calculate // your's here: http://www.ngdc.noaa.gov/geomag-web/#declination // Declination (degrees) in El Centro, CA #define DECLINATION 10.4 // Gyro float fGyroX; float fGyroY; float fGyroZ; // Accel float fAccelX; float fAccelY; float fAccelZ; // Mag float fMagX; float fMagY; float fMagZ; // Attitude float fRoll; float fPitch; float fHeading; // HC-SR04 Ultrasonic Sensor int iTrig = 15; int iEcho = 14; // Stores the distance measured by the distance sensor float distance = 0; // The number of the Rocker Switch pin int iSwitch = 21; // Variable for reading the button status int SwitchState = 0; // Software Version Information String sver = "28-12"; void loop() { // Date and Time RTC isRTC (); // isGPS isGPS(); // GPS Keyboard isGPSKeyboard(); // Gyro isGyro(); // Accel isAccel(); // Mag isMag(); // Attitude isAttitude(); // HC-SR04 Ultrasonic Sensor isHCSR04(); // Read the state of the Switch value: SwitchState = digitalRead(iSwitch); // Check if the button is pressed. If it is, the SwitchState is HIGH: if (SwitchState == HIGH) { // Bluetooth LE Keyboard isBluetooth(); } // Delay 1 Second delay(1000); }
getBleKeyboard.ino
// Ble Keyboard // Bluetooth // isBluetooth void isBluetooth() { // ESP32 BLE Keyboard if(bleKeyboard.isConnected()) { // Send Size Length sendSize = sKeyboard.length(); // Send Size, charAt for(byte i = 0; i < sendSize+1; i++){ // Write bleKeyboard.write(sKeyboard.charAt(i)); delay(50); } bleKeyboard.write(KEY_RETURN); } }
getGPS.ino
// GPS Receiver // Setup GPS void isSetupGPS() { // Setup GPS //tGPS.begin( 9600 ); // 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 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"; TargetLat = 0; TargetLon = 0; } } // GPS Date, Time 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); } } // GPS Keyboard void isGPSKeyboard(){ // GPS Keyboard // bleKeyboard // GPS Vector Pointer Target sKeyboard = sKeyboard + GPSSt + "|" + String(TargetLat) + "|" + String(TargetLon) + "|"; // bleKeyboard // GPS Date, Time sKeyboard = sKeyboard + TargetDat + "|" + TargetTim + "|"; }
getHC-SR04.ino
// HC-SR04 Ultrasonic Sensor // Setup HC-SR04 void isSetupHCSR04() { // The trigger iTrig will output pulses of electricity pinMode(iTrig, OUTPUT); // The echo iEcho will measure the duration of pulses coming back from the distance sensor pinMode(iEcho, INPUT); } // HC-SR04 void isHCSR04() { // Variable to store the distance measured by the sensor distance = isDistance(); sKeyboard = sKeyboard + String(distance) + " cm|*"; } // Distance float isDistance() { // Variable to store the time it takes for a ping to bounce off an object float echoTime; // Variable to store the distance calculated from the echo time float calculatedDistance; // Send out an ultrasonic pulse that's 10ms long digitalWrite(iTrig, HIGH); delayMicroseconds(10); digitalWrite(iTrig, LOW); // Use the pulseIn command to see how long it takes for the // pulse to bounce back to the sensor echoTime = pulseIn(iEcho, HIGH); // Calculate the distance of the object that reflected the pulse // (half the bounce time multiplied by the speed of sound) // cm = 58.0 calculatedDistance = echoTime / 58.0; // Send back the distance that was calculated return calculatedDistance; }
getLSM9DS1.ino
// LSM9DS1 9DOF Sensor // Gyro void isGyro(){ // Update the sensor values whenever new data is available if ( imu.gyroAvailable() ) { // To read from the gyroscope, first call the // readGyro() function. When it exits, it'll update the // gx, gy, and gz variables with the most current data. imu.readGyro(); // If you want to print calculated values, you can use the // calcGyro helper function to convert a raw ADC value to // DPS. Give the function the value that you want to convert. fGyroX = imu.calcGyro(imu.gx); fGyroY = imu.calcGyro(imu.gy); fGyroZ = imu.calcGyro(imu.gz); // bleKeyboard // Gyro sKeyboard = sKeyboard + String(fGyroX) + "|" + String(fGyroY) + "|" + String(fGyroZ) + "|"; } } // Accel void isAccel(){ // Update the sensor values whenever new data is available if ( imu.accelAvailable() ) { // To read from the accelerometer, first call the // readAccel() function. When it exits, it'll update the // ax, ay, and az variables with the most current data. imu.readAccel(); // If you want to print calculated values, you can use the // calcAccel helper function to convert a raw ADC value to // g's. Give the function the value that you want to convert. fAccelX = imu.calcAccel(imu.ax); fAccelY = imu.calcAccel(imu.ay); fAccelZ = imu.calcAccel(imu.az); // bleKeyboard // Accel sKeyboard = sKeyboard + String(fAccelX) + "|" + String(fAccelY) + "|" + String(fAccelZ) + "|"; } } // Mag void isMag(){ // Update the sensor values whenever new data is available if ( imu.magAvailable() ) { // To read from the magnetometer, first call the // readMag() function. When it exits, it'll update the // mx, my, and mz variables with the most current data. imu.readMag(); // If you want to print calculated values, you can use the // calcMag helper function to convert a raw ADC value to // Gauss. Give the function the value that you want to convert. fMagX = imu.calcMag(imu.mx); fMagY = imu.calcMag(imu.my); fMagZ = imu.calcMag(imu.mz); // bleKeyboard // Mag sKeyboard = sKeyboard + String(fMagX) + "|" + String(fMagY) + "|" + String(fMagZ) + "|"; } } // Attitude void isAttitude(){ // Attitude // Roll fRoll = atan2(fAccelY, fAccelZ); // Pitch fPitch = atan2(-fAccelX, sqrt(fAccelY * fAccelY + fAccelZ * fAccelZ)); // Heading if (fMagY == 0) { fHeading = (fMagX < 0) ? PI : 0; } else { fHeading = atan2(fMagX, fMagY); } fHeading -= DECLINATION * PI / 180; if (fHeading > PI) fHeading -= (2 * PI); else if (fHeading < -PI) fHeading += (2 * PI); // Convert everything from radians to degrees: fHeading *= 180.0 / PI; fPitch *= 180.0 / PI; fRoll *= 180.0 / PI; // bleKeyboard // Attitude sKeyboard = sKeyboard + String(fHeading) + "|" + String(fPitch) + "|" + String(fRoll) + "|"; }
getRTC.ino
// Date & Time // DS3231 Precision RTC void isSetupRTC() { // DS3231 Precision RTC if (! rtc.begin()) { //Serial.println("Couldn't find RTC"); //Serial.flush(); while (1) delay(10); } if (rtc.lostPower()) { //Serial.println("RTC lost power, let's set the time!"); // When time needs to be set on a new device, or after a power loss, the // following line sets the RTC to the date & time this sketch was compiled rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); // This line sets the RTC with an explicit date & time, for example to set // January 21, 2014 at 3am you would call: //rtc.adjust(DateTime(2023, 8, 10, 11, 0, 0)); } } // Date and Time RTC void isRTC () { // Date and Time dateRTC = ""; timeRTC = ""; DateTime now = rtc.now(); // Date dateRTC = now.year(), DEC; dateRTC = dateRTC + "/"; dateRTC = dateRTC + now.month(), DEC; dateRTC = dateRTC + "/"; dateRTC = dateRTC + now.day(), DEC; // Time timeRTC = now.hour(), DEC; timeRTC = timeRTC + ":"; timeRTC = timeRTC + now.minute(), DEC; timeRTC = timeRTC + ":"; timeRTC = timeRTC + now.second(), DEC; // bleKeyboard sKeyboard = "SEN|" + sver + "|" + String(dateRTC) + "|" + String(timeRTC) + "|"; }
setup.ino
// Setup void setup() { // Give display time to power on delay(100); // Bluetooth LE keyboard bleKeyboard.begin(); // Wire - Inialize I2C Hardware Wire.begin(); // Give display time to power on delay(100); // Date & Time RTC // DS3231 Precision RTC isSetupRTC(); // Give display time to power on delay(100); // GPS Receiver // Setup GPS isSetupGPS(); // LSM9DS1 9DOF Sensor imu.begin(); // Setup HC-SR04 isSetupHCSR04(); // Initialize the Switch pin as an input pinMode(iSwitch, INPUT); // Initialize digital pin LED_BUILTIN as an output pinMode(LED_BUILTIN, OUTPUT); // Turn the LED on HIGH digitalWrite(LED_BUILTIN, HIGH); // Delay 5 Second delay( 5000 ); }
——
People can contact us: https://www.donluc.com/?page_id=1927
Teacher, Instructor, E-Mentor, R&D and Consulting
- Programming Language
- Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi, Arm, Silicon Labs, Espressif, Etc…)
- IoT
- Wireless (Radio Frequency, Bluetooth, WiFi, Etc…)
- Robotics
- Automation
- Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
- Unmanned Vehicles Terrestrial and Marine
- Machine Learning
- Artificial Intelligence (AI)
- RTOS
- eHealth Sensors, Biosensor, and Biometric
- Research & Development (R & D)
- Consulting
Follow Us
Luc Paquin – Curriculum Vitae – 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 #28 – Sensors – LSM9DS1 – Mk11
——
#DonLucElectronics #DonLuc #Sensors #LSM9DS1 #IMU #GPSReceiver #Adafruit #SparkFun #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant
——
——
——
——
SparkFun 9DoF IMU Breakout – LSM9DS1
The SparkFun LSM9DS1 Breakout is a versatile, motion-sensing System-In-A-Chip. It houses a 3-axis accelerometer, 3-axis gyroscope, and 3-axis magnetometer, nine degrees of freedom (9DOF) on a single board. The LSM9DS1 from STMicroelectronics is equipped with a digital interface, but even that is flexible. This IMU-In-A-Chip is so cool we put it on the quarter-sized breakout board you are currently viewing.
The LSM9DS1 is one of only a handful of IC’s that can measure three key properties of movement, angular velocity, acceleration, and heading, in a single IC. By measuring these three properties, you can gain a great deal of knowledge about an object’s movement and orientation. The LSM9DS1 measures each of these movement properties in three dimensions. That means it produces nine pieces of data: acceleration in x/y/z, angular rotation in x/y/z, and magnetic force in x/y/z. The LSM9DS1 Breakout has labels indicating the accelerometer and gyroscope axis orientations, which share a right-hand rule relationship with each other.
DL2309Mk05
1 x SparkFun Thing Plus – ESP32 WROOM
1 x DS3231 Precision RTC FeatherWing
1 x GPS Receiver – GP-20U7 (56 Channel)
1 x SparkFun 9DoF IMU Breakout – LSM9DS1
1 x Rocker Switch – SPST
1 x Resistor 10K Ohm
1 x CR1220 3V Lithium Coin Cell Battery
1 x 1 x Lithium Ion Battery – 1000mAh
1 x Terminal Block Breakout FeatherWing
1 x SparkFun Cerberus USB Cable
SparkFun Thing Plus – ESP32 WROOM
LED – LED_BUILTIN
SDA – Digital 23
SCL – Digital 22
SW1 – Digital 21
GPT – Digital 17
GPR – Digital 16
VIN – +3.3V
GND – GND
——
DL2309Mk05p.ino
/****** Don Luc Electronics © ****** Software Version Information Project #28 - Sensors - LSM9DS1 - Mk11 28-11 DL2309Mk05p.ino 1 x SparkFun Thing Plus - ESP32 WROOM 1 x DS3231 Precision RTC FeatherWing 1 x GPS Receiver - GP-20U7 (56 Channel) 1 x SparkFun 9DoF IMU Breakout - LSM9DS1 1 x Rocker Switch - SPST 1 x Resistor 10K Ohm 1 x Lithium Ion Battery - 1000mAh 1 x CR1220 3V Lithium Coin Cell Battery 1 x Terminal Block Breakout FeatherWing 1 x SparkFun Cerberus USB Cable */ // Include the Library Code // Bluetooth LE keyboard #include <BleKeyboard.h> // Two Wire Interface (TWI/I2C) #include <Wire.h> // Serial Peripheral Interface #include <SPI.h> // DS3231 Precision RTC #include <RTClib.h> // GPS Receiver #include <TinyGPS++.h> // ESP32 Hardware Serial #include <HardwareSerial.h> // LSM9DS1 9DOF Sensor #include <SparkFunLSM9DS1.h> // Bluetooth LE Keyboard BleKeyboard bleKeyboard; String sKeyboard = ""; // Send Size byte sendSize = 0; // DS3231 Precision RTC RTC_DS3231 rtc; String dateRTC = ""; String timeRTC = ""; // GPS Receiver #define gpsRXPIN 16 // This one is unused and doesnt have a conection #define gpsTXPIN 17 // The TinyGPS++ object TinyGPSPlus gps; // Latitude float TargetLat; // Longitude float TargetLon; // GPS Date, Time // GPS Date String TargetDat; // GPS Time String TargetTim; // GPS Status String GPSSt = ""; // ESP32 HardwareSerial HardwareSerial tGPS(2); // LSM9DS1 9DOF Sensor LSM9DS1 imu; #define PRINT_CALCULATED // Earth's magnetic field varies by location. Add or subtract // a declination to get a more accurate heading. Calculate // your's here: http://www.ngdc.noaa.gov/geomag-web/#declination // Declination (degrees) in El Centro, CA #define DECLINATION 10.4 // Gyro float fGyroX; float fGyroY; float fGyroZ; // Accel float fAccelX; float fAccelY; float fAccelZ; // Mag float fMagX; float fMagY; float fMagZ; // Attitude float fRoll; float fPitch; float fHeading; // The number of the Rocker Switch pin int iSwitch = 21; // Variable for reading the button status int SwitchState = 0; // Software Version Information String sver = "28-11"; void loop() { // Date and Time RTC isRTC (); // isGPS isGPS(); // GPS Keyboard isGPSKeyboard(); // Gyro isGyro(); // Accel isAccel(); // Mag isMag(); // Attitude isAttitude(); // Read the state of the Switch value: SwitchState = digitalRead(iSwitch); // Check if the button is pressed. If it is, the SwitchState is HIGH: if (SwitchState == HIGH) { // Bluetooth LE Keyboard isBluetooth(); } // Delay 1 Second delay(1000); }
getBleKeyboard.ino
// Ble Keyboard // Bluetooth // isBluetooth void isBluetooth() { // ESP32 BLE Keyboard if(bleKeyboard.isConnected()) { // Send Size Length sendSize = sKeyboard.length(); // Send Size, charAt for(byte i = 0; i < sendSize+1; i++){ // Write bleKeyboard.write(sKeyboard.charAt(i)); delay(50); } bleKeyboard.write(KEY_RETURN); } }
getGPS.ino
// GPS Receiver // Setup GPS void setupGPS() { // Setup GPS //tGPS.begin( 9600 ); // 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 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"; TargetLat = 0; TargetLon = 0; } } // GPS Date, Time 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); } } // GPS Keyboard void isGPSKeyboard(){ // GPS Keyboard // bleKeyboard // GPS Vector Pointer Target sKeyboard = sKeyboard + GPSSt + "|" + String(TargetLat) + "|" + String(TargetLon) + "|"; // bleKeyboard // GPS Date, Time sKeyboard = sKeyboard + TargetDat + "|" + TargetTim + "|"; }
getLSM9DS1.ino
// LSM9DS1 9DOF Sensor // Gyro void isGyro(){ // Update the sensor values whenever new data is available if ( imu.gyroAvailable() ) { // To read from the gyroscope, first call the // readGyro() function. When it exits, it'll update the // gx, gy, and gz variables with the most current data. imu.readGyro(); // If you want to print calculated values, you can use the // calcGyro helper function to convert a raw ADC value to // DPS. Give the function the value that you want to convert. fGyroX = imu.calcGyro(imu.gx); fGyroY = imu.calcGyro(imu.gy); fGyroZ = imu.calcGyro(imu.gz); // bleKeyboard // Gyro sKeyboard = sKeyboard + String(fGyroX) + "|" + String(fGyroY) + "|" + String(fGyroZ) + "|"; } } // Accel void isAccel(){ // Update the sensor values whenever new data is available if ( imu.accelAvailable() ) { // To read from the accelerometer, first call the // readAccel() function. When it exits, it'll update the // ax, ay, and az variables with the most current data. imu.readAccel(); // If you want to print calculated values, you can use the // calcAccel helper function to convert a raw ADC value to // g's. Give the function the value that you want to convert. fAccelX = imu.calcAccel(imu.ax); fAccelY = imu.calcAccel(imu.ay); fAccelZ = imu.calcAccel(imu.az); // bleKeyboard // Accel sKeyboard = sKeyboard + String(fAccelX) + "|" + String(fAccelY) + "|" + String(fAccelZ) + "|"; } } // Mag void isMag(){ // Update the sensor values whenever new data is available if ( imu.magAvailable() ) { // To read from the magnetometer, first call the // readMag() function. When it exits, it'll update the // mx, my, and mz variables with the most current data. imu.readMag(); // If you want to print calculated values, you can use the // calcMag helper function to convert a raw ADC value to // Gauss. Give the function the value that you want to convert. fMagX = imu.calcMag(imu.mx); fMagY = imu.calcMag(imu.my); fMagZ = imu.calcMag(imu.mz); // bleKeyboard // Mag sKeyboard = sKeyboard + String(fMagX) + "|" + String(fMagY) + "|" + String(fMagZ) + "|"; } } // Attitude void isAttitude(){ // Attitude // Roll fRoll = atan2(fAccelY, fAccelZ); // Pitch fPitch = atan2(-fAccelX, sqrt(fAccelY * fAccelY + fAccelZ * fAccelZ)); // Heading if (fMagY == 0) { fHeading = (fMagX < 0) ? PI : 0; } else { fHeading = atan2(fMagX, fMagY); } fHeading -= DECLINATION * PI / 180; if (fHeading > PI) fHeading -= (2 * PI); else if (fHeading < -PI) fHeading += (2 * PI); // Convert everything from radians to degrees: fHeading *= 180.0 / PI; fPitch *= 180.0 / PI; fRoll *= 180.0 / PI; // bleKeyboard // Attitude sKeyboard = sKeyboard + String(fHeading) + "|" + String(fPitch) + "|" + String(fRoll) + "|*"; }
getRTC.ino
// Date & Time // DS3231 Precision RTC void setupRTC() { // DS3231 Precision RTC if (! rtc.begin()) { //Serial.println("Couldn't find RTC"); //Serial.flush(); while (1) delay(10); } if (rtc.lostPower()) { //Serial.println("RTC lost power, let's set the time!"); // When time needs to be set on a new device, or after a power loss, the // following line sets the RTC to the date & time this sketch was compiled rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); // This line sets the RTC with an explicit date & time, for example to set // January 21, 2014 at 3am you would call: //rtc.adjust(DateTime(2023, 8, 10, 11, 0, 0)); } } // Date and Time RTC void isRTC () { // Date and Time dateRTC = ""; timeRTC = ""; DateTime now = rtc.now(); // Date dateRTC = now.year(), DEC; dateRTC = dateRTC + "/"; dateRTC = dateRTC + now.month(), DEC; dateRTC = dateRTC + "/"; dateRTC = dateRTC + now.day(), DEC; // Time timeRTC = now.hour(), DEC; timeRTC = timeRTC + ":"; timeRTC = timeRTC + now.minute(), DEC; timeRTC = timeRTC + ":"; timeRTC = timeRTC + now.second(), DEC; // bleKeyboard sKeyboard = "SEN|" + sver + "|" + String(dateRTC) + "|" + String(timeRTC) + "|"; }
setup.ino
// Setup void setup() { // Give display time to power on delay(100); // Bluetooth LE keyboard bleKeyboard.begin(); // Wire - Inialize I2C Hardware Wire.begin(); // Give display time to power on delay(100); // Date & Time RTC // DS3231 Precision RTC setupRTC(); // Give display time to power on delay(100); // GPS Receiver // Setup GPS setupGPS(); // LSM9DS1 9DOF Sensor imu.begin(); // Initialize the Switch pin as an input pinMode(iSwitch, INPUT); // Initialize digital pin LED_BUILTIN as an output pinMode(LED_BUILTIN, OUTPUT); // Turn the LED on HIGH digitalWrite(LED_BUILTIN, HIGH); // Delay 5 Second delay( 5000 ); }
——
People can contact us: https://www.donluc.com/?page_id=1927
Teacher, Instructor, E-Mentor, R&D and Consulting
- Programming Language
- Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi, Arm, Silicon Labs, Espressif, Etc…)
- IoT
- Wireless (Radio Frequency, Bluetooth, WiFi, Etc…)
- Robotics
- Automation
- Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
- Unmanned Vehicles Terrestrial and Marine
- Machine Learning
- Artificial Intelligence (AI)
- RTOS
- eHealth Sensors, Biosensor, and Biometric
- Research & Development (R & D)
- Consulting
Follow Us
Luc Paquin – Curriculum Vitae – 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 #28 – Sensors – SparkFun Environmental Combo CCS811/BME280 – Mk09
——
#DonLucElectronics #DonLuc #Sensors #CCS811 #BME280 #TSOP85 #TMP102 #LineSensor #AlcoholGasSensor #MinIMU9 #Pololu #Adafruit #SparkFun #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant
——
——
——
——
SparkFun Environmental Combo – 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.
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.
DL2309Mk03
1 x Adafruit METRO M0 Express
1 x DS3231 Precision RTC FeatherWing
1 x Pololu MinIMU-9 v5 Gyro, Accelerometer, and Compass
1 x Pololu Carrier for MQ Gas Sensors
1 x Alcohol Gas Sensor – MQ-3
1 x SparkFun Line Sensor – QRE1113
1 x SparkFun Digital Temperature Sensor – TMP102
1 x SparkFun IR Receiver – TSOP85
1 x SparkFun Environmental Combo – CCS811/BME280
1 x LED Red
1 x ProtoScrewShield
1 x Rocker Switch – SPST
2 x Resistor 10K Ohm
1 x CR1220 3V Lithium Coin Cell Battery
1 x SparkFun Cerberus USB Cable
Adafruit METRO M0 Express
LED – LED_BUILTIN
SDA – Digital 20
SCL – Digital 21
IRR – Digital 11
LER – Digital 3
SW1 – Digital 2
MQ3 – Analog 0
LSB – Analog 1
ALE = Analog 3
VIN – +3.3V
VIN – +5V
GND – GND
——
DL2309Mk03p.ino
/****** Don Luc Electronics © ****** Software Version Information Project #28 - Sensors - SparkFun Environmental Combo CCS811/BME280 - Mk09 28-09 DL2309Mk03p.ino 1 x Adafruit METRO M0 Express 1 x DS3231 Precision RTC FeatherWing 1 x Pololu MinIMU-9 v5 Gyro, Accelerometer, and Compass 1 x Pololu Carrier for MQ Gas Sensors 1 x Alcohol Gas Sensor - MQ-3 1 x SparkFun Line Sensor - QRE1113 1 x SparkFun Digital Temperature Sensor - TMP102 1 x SparkFun IR Receiver - TSOP85 1 x SparkFun Environmental Combo - CCS811/BME280 1 x LED Red 1 x ProtoScrewShield 1 x Rocker Switch - SPST 2 x Resistor 10K Ohm 1 x CR1220 3V Lithium Coin Cell Battery 1 x SparkFun Cerberus USB Cable */ // Include the Library Code // DS3231 Precision RTC #include <RTClib.h> // Two Wire Interface (TWI/I2C) #include <Wire.h> // Keyboard #include <Keyboard.h> // Includes and variables for IMU integration // STMicroelectronics LSM6DS33 Gyroscope and Accelerometer #include <LSM6.h> // STMicroelectronics LIS3MDL Magnetometer #include <LIS3MDL.h> // SparkFun Digital Temperature Sensor TMP102 #include <SparkFunTMP102.h> // SparkFun IR Receiver - TSOP85 #include <IRremote.h> // SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude #include <SparkFunBME280.h> // SparkFun CCS811 - eCO2 & tVOC #include <SparkFunCCS811.h> // Keyboard String sKeyboard = ""; // DS3231 Precision RTC RTC_DS3231 rtc; String dateRTC = ""; String timeRTC = ""; // Pololu 9DoF IMU // STMicroelectronics LSM6DS33 Gyroscope and Accelerometer LSM6 imu; // Accelerometer and Gyroscopes // Accelerometer int imuAX; int imuAY; int imuAZ; // Gyroscopes int imuGX; int imuGY; int imuGZ; // STMicroelectronics LIS3MDL Magnetometer LIS3MDL mag; // Magnetometer int magX; int magY; int magZ; // Gas Sensors MQ // Alcohol Gas Sensor - MQ-3 int iMQ3 = A0; int iMQ3Raw = 0; int iMQ3ppm = 0; // SparkFun Line Sensor - QRE1113 (Analog) int iLine = A1; int iLineSensor = 0; // SparkFun Digital Temperature Sensor TMP102 const int ALERT_PIN = A3; TMP102 sensor0; float temperature; boolean alertPinState; boolean alertRegisterState; // SparkFun IR Receiver - TSOP85 int RECV_PIN = 11; IRrecv irrecv(RECV_PIN); decode_results results; String IRValue = ""; int iLEDRed = 3; // SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude BME280 myBME280; float BMEtempC = 0; float BMEhumid = 0; float BMEpressure = 0; float BMEaltitudeM = 0; // SparkFun CCS811 - eCO2 & tVOC // Default I2C Address #define CCS811_ADDR 0x5B CCS811 myCCS811(CCS811_ADDR); float CCS811CO2 = 0; float CCS811TVOC = 0; // The number of the Rocker Switch pin int iSwitch = 2; // Variable for reading the button status int SwitchState = 0; // Software Version Information String sver = "28-09"; void loop() { // Date and Time RTC isRTC (); // Pololu Accelerometer and Gyroscopes isIMU(); // Pololu Magnetometer isMag(); // Gas Sensors MQ isGasSensor(); // SparkFun Line Sensor isLineSensor(); // SparkFun Temperature TMP102 isTMP102(); // SparkFun IR Receiver - TSOP85 isIR(); // SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude isBME280(); // SparkFun CCS811 - eCO2 & tVOC isCCS811(); // Read the state of the Switch value: SwitchState = digitalRead(iSwitch); // Check if the button is pressed. If it is, the SwitchState is HIGH: if (SwitchState == HIGH) { Keyboard.println(sKeyboard); } // Delay 1 Second delay(1000); }
getAccelGyro.ino
// Accelerometer and Gyroscopes // Setup IMU void setupIMU() { // Setup IMU imu.init(); // Default imu.enableDefault(); } // Accelerometer and Gyroscopes void isIMU() { // Accelerometer and Gyroscopes imu.read(); // Accelerometer x, y, z imuAX = imu.a.x; imuAY = imu.a.y; imuAZ = imu.a.z; // Gyroscopes x, y, z imuGX = imu.g.x; imuGY = imu.g.y; imuGZ = imu.g.z; // Keyboard sKeyboard = sKeyboard + String(imuAX) + "|" + String(imuAY) + "|" + String(imuAZ) + "|"; sKeyboard = sKeyboard + String(imuGX) + "|" + String(imuGY) + "|" + String(imuGZ) + "|"; }
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); // Keyboard sKeyboard = sKeyboard + String(BMEtempC) + "|" + String(BMEhumid) + "|" + String(BMEpressure) + "|" + String(BMEaltitudeM) + "|"; }
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(); // Keyboard sKeyboard = sKeyboard + String(CCS811CO2) + "|" + String(CCS811TVOC) + "|*"; }
getGasSensorMQ.ino
// Gas Sensors MQ // Gas Sensor void isGasSensor() { // Read in analog value from each gas sensors // Alcohol Gas Sensor - MQ-3 iMQ3ppm = isMQ3( iMQ3Raw ); // Keyboard sKeyboard = sKeyboard + String(iMQ3ppm) + "|"; } // Alcohol Gas Sensor - MQ-3 int isMQ3(double rawValue) { double RvRo = rawValue; // % BAC = breath mg/L * 0.21 double bac = RvRo * 0.21; return bac; }
getIMUMagnetometer.ino
// IMU Magnetometer // Setup Magnetometer void setupMag() { // Setup Magnetometer mag.init(); // Default mag.enableDefault(); } // Magnetometer void isMag() { // Magnetometer mag.read(); // Magnetometer x, y, z magX = mag.m.x; magY = mag.m.y; magZ = mag.m.z; // Keyboard sKeyboard = sKeyboard + String(magX) + "|" + String(magY) + "|" + String(magZ) + "|"; }
getIRRemote.ino
// SparkFun IR Receiver - TSOP85 // Setup void isSetupIR(){ // Initialize digital pin LED Red as an output pinMode(iLEDRed, OUTPUT); // Start the receiver irrecv.enableIRIn(); } // void isIR(){ if (irrecv.decode(&results)) { // LED Red HIGH digitalWrite(iLEDRed, HIGH); //Serial.print("IR RECV Code = 0x "); //Serial.println(results.value, HEX); IRValue = "0x "; IRValue = IRValue + String(results.value, HEX); // LED Red LOW digitalWrite(iLEDRed, LOW); // IR Resume irrecv.resume(); } else { IRValue = "0"; } // Keyboard sKeyboard = sKeyboard + String(IRValue) + "|"; }
getLineSensor.ino
// Line Sensor // isLine Sensor void isLineSensor(){ // Line Sensor iLineSensor = analogRead(iLine); // Keyboard sKeyboard = sKeyboard + String(iLineSensor) + "|"; }
getRTC.ino
// Date & Time // DS3231 Precision RTC void setupRTC() { // DS3231 Precision RTC if (! rtc.begin()) { //Serial.println("Couldn't find RTC"); //Serial.flush(); while (1) delay(10); } if (rtc.lostPower()) { //Serial.println("RTC lost power, let's set the time!"); // When time needs to be set on a new device, or after a power loss, the // following line sets the RTC to the date & time this sketch was compiled rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); // This line sets the RTC with an explicit date & time, for example to set // January 21, 2014 at 3am you would call: //rtc.adjust(DateTime(2023, 8, 10, 11, 0, 0)); } } // Date and Time RTC void isRTC () { // Date and Time dateRTC = ""; timeRTC = ""; DateTime now = rtc.now(); // Date dateRTC = now.year(), DEC; dateRTC = dateRTC + "/"; dateRTC = dateRTC + now.month(), DEC; dateRTC = dateRTC + "/"; dateRTC = dateRTC + now.day(), DEC; // Time timeRTC = now.hour(), DEC; timeRTC = timeRTC + ":"; timeRTC = timeRTC + now.minute(), DEC; timeRTC = timeRTC + ":"; timeRTC = timeRTC + now.second(), DEC; // Keyboard sKeyboard = "SEN|" + sver + "|" + String(dateRTC) + "|" + String(timeRTC) + "|"; }
getTempTMP102.ino
// SparkFun Digital Temperature Sensor TMP102 // Setup TMP102 void isSetupTMP102(){ // Declare alertPin as an input pinMode(ALERT_PIN,INPUT); // Begin //It will return true on success or false on failure to communicate if(!sensor0.begin()) { while(1); } // set the Conversion Rate //0-3: 0:0.25Hz, 1:1Hz, 2:4Hz, 3:8Hz sensor0.setConversionRate(2); //set Extended Mode. //0:12-bit Temperature(-55C to +128C) 1:13-bit Temperature(-55C to +150C) sensor0.setExtendedMode(0); // Set T_HIGH, the upper limit to trigger the alert on // Set T_HIGH in C sensor0.setHighTempC(29.4); // Set T_LOW, the lower limit to shut turn off the alert // set T_LOW in C sensor0.setLowTempC(27.67); } // is TMP102 void isTMP102(){ // Turn sensor on to start temperature measurement. // Current consumtion typically ~10uA. sensor0.wakeup(); // read temperature data C temperature = sensor0.readTempC(); // Check for Alert // Read the Alert from pin alertPinState = digitalRead(ALERT_PIN); // Read the Alert from register alertRegisterState = sensor0.alert(); // Place sensor in sleep mode to save power. // Current consumtion typically <0.5uA. sensor0.sleep(); // Keyboard sKeyboard = sKeyboard + String(temperature) + "|" + String(alertPinState) + "|" + String(alertRegisterState) + "|"; }
setup.ino
// Setup void setup() { // Give display time to power on delay(100); // Wire - Inialize I2C Hardware Wire.begin(); // Give display time to power on delay(100); // Date & Time RTC // DS3231 Precision RTC setupRTC(); // Initialize control over the keyboard: Keyboard.begin(); // Pololu Setup IMU setupIMU(); // Pololu Setup Magnetometer setupMag(); // Setup TMP102 isSetupTMP102(); // SetupTSOP85 isSetupIR(); // SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude myBME280.begin(); // CCS811 - eCO2 & tVOC myCCS811.begin(); // Initialize the Switch pin as an input pinMode(iSwitch, INPUT); // Initialize digital pin LED_BUILTIN as an output pinMode(LED_BUILTIN, OUTPUT); // Turn the LED on HIGH digitalWrite(LED_BUILTIN, HIGH); // Delay 5 Second delay( 5000 ); }
——
People can contact us: https://www.donluc.com/?page_id=1927
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 #28 – Sensors – SparkFun IR Receiver TSOP85 – Mk08
——
#DonLucElectronics #DonLuc #Sensors #TMP102 #LineSensor #AlcoholGasSensor #MinIMU9 #Pololu #Adafruit #SparkFun #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant
——
——
——
——
SparkFun IR Receiver – TSOP85
This is a very small infrared receiver based on the TSOP85 receiver from Vishay. This receiver has all the filtering and 38kHz demodulation built into the unit. Simply point a IR remote at the receiver, hit a button, and you’ll see a stream of 1s and 0s out of the data pin.
DL2309Mk02
1 x Adafruit METRO M0 Express
1 x DS3231 Precision RTC FeatherWing
1 x Pololu MinIMU-9 v5 Gyro, Accelerometer, and Compass
1 x Pololu Carrier for MQ Gas Sensors
1 x Alcohol Gas Sensor – MQ-3
1 x SparkFun Line Sensor – QRE1113
1 x SparkFun Digital Temperature Sensor – TMP102
1 x SparkFun IR Receiver – TSOP85
1 x LED Red
1 x ProtoScrewShield
1 x Rocker Switch – SPST
2 x Resistor 10K Ohm
1 x CR1220 3V Lithium Coin Cell Battery
1 x SparkFun Cerberus USB Cable
Adafruit METRO M0 Express
LED – LED_BUILTIN
SDA – Digital 20
SCL – Digital 21
IRR – Digital 11
LER – Digital 3
SW1 – Digital 2
MQ3 – Analog 0
LSB – Analog 1
ALE = Analog 3
VIN – +3.3V
VIN – +5V
GND – GND
——
DL2309Mk02p.ino
/****** Don Luc Electronics © ****** Software Version Information Project #28 - Sensors - SparkFun IR Receiver TSOP85 - Mk08 28-08 DL2309Mk02p.ino 1 x Adafruit METRO M0 Express 1 x DS3231 Precision RTC FeatherWing 1 x Pololu MinIMU-9 v5 Gyro, Accelerometer, and Compass 1 x Pololu Carrier for MQ Gas Sensors 1 x Alcohol Gas Sensor - MQ-3 1 x SparkFun Line Sensor - QRE1113 1 x SparkFun Digital Temperature Sensor - TMP102 1 x SparkFun IR Receiver - TSOP85 1 x LED Red 1 x ProtoScrewShield 1 x Rocker Switch - SPST 2 x Resistor 10K Ohm 1 x CR1220 3V Lithium Coin Cell Battery 1 x SparkFun Cerberus USB Cable */ // Include the Library Code // DS3231 Precision RTC #include <RTClib.h> // Two Wire Interface (TWI/I2C) #include <Wire.h> // Keyboard #include <Keyboard.h> // Includes and variables for IMU integration // STMicroelectronics LSM6DS33 Gyroscope and Accelerometer #include <LSM6.h> // STMicroelectronics LIS3MDL Magnetometer #include <LIS3MDL.h> // SparkFun Digital Temperature Sensor TMP102 #include <SparkFunTMP102.h> // SparkFun IR Receiver - TSOP85 #include <IRremote.h> // Keyboard String sKeyboard = ""; // DS3231 Precision RTC RTC_DS3231 rtc; String dateRTC = ""; String timeRTC = ""; // Pololu 9DoF IMU // STMicroelectronics LSM6DS33 Gyroscope and Accelerometer LSM6 imu; // Accelerometer and Gyroscopes // Accelerometer int imuAX; int imuAY; int imuAZ; // Gyroscopes int imuGX; int imuGY; int imuGZ; // STMicroelectronics LIS3MDL Magnetometer LIS3MDL mag; // Magnetometer int magX; int magY; int magZ; // Gas Sensors MQ // Alcohol Gas Sensor - MQ-3 int iMQ3 = A0; int iMQ3Raw = 0; int iMQ3ppm = 0; // SparkFun Line Sensor - QRE1113 (Analog) int iLine = A1; int iLineSensor = 0; // SparkFun Digital Temperature Sensor TMP102 const int ALERT_PIN = A3; TMP102 sensor0; float temperature; boolean alertPinState; boolean alertRegisterState; // SparkFun IR Receiver - TSOP85 int RECV_PIN = 11; IRrecv irrecv(RECV_PIN); decode_results results; String IRValue = ""; int iLEDRed = 3; // The number of the Rocker Switch pin int iSwitch = 2; // Variable for reading the button status int SwitchState = 0; // Software Version Information String sver = "28-08"; void loop() { // Date and Time RTC isRTC (); // Pololu Accelerometer and Gyroscopes isIMU(); // Pololu Magnetometer isMag(); // Gas Sensors MQ isGasSensor(); // SparkFun Line Sensor isLineSensor(); // SparkFun Temperature TMP102 isTMP102(); // SparkFun IR Receiver - TSOP85 isIR(); // Read the state of the Switch value: SwitchState = digitalRead(iSwitch); // Check if the button is pressed. If it is, the SwitchState is HIGH: if (SwitchState == HIGH) { Keyboard.println(sKeyboard); } // Delay 1 Second delay(1000); }
getAccelGyro.ino
// Accelerometer and Gyroscopes // Setup IMU void setupIMU() { // Setup IMU imu.init(); // Default imu.enableDefault(); } // Accelerometer and Gyroscopes void isIMU() { // Accelerometer and Gyroscopes imu.read(); // Accelerometer x, y, z imuAX = imu.a.x; imuAY = imu.a.y; imuAZ = imu.a.z; // Gyroscopes x, y, z imuGX = imu.g.x; imuGY = imu.g.y; imuGZ = imu.g.z; // Keyboard sKeyboard = sKeyboard + String(imuAX) + "|" + String(imuAY) + "|" + String(imuAZ) + "|"; sKeyboard = sKeyboard + String(imuGX) + "|" + String(imuGY) + "|" + String(imuGZ) + "|"; }
getGasSensorMQ.ino
// Gas Sensors MQ // Gas Sensor void isGasSensor() { // Read in analog value from each gas sensors // Alcohol Gas Sensor - MQ-3 iMQ3ppm = isMQ3( iMQ3Raw ); // Keyboard sKeyboard = sKeyboard + String(iMQ3ppm) + "|"; } // Alcohol Gas Sensor - MQ-3 int isMQ3(double rawValue) { double RvRo = rawValue; // % BAC = breath mg/L * 0.21 double bac = RvRo * 0.21; return bac; }
getIMUMagnetometer.ino
// IMU Magnetometer // Setup Magnetometer void setupMag() { // Setup Magnetometer mag.init(); // Default mag.enableDefault(); } // Magnetometer void isMag() { // Magnetometer mag.read(); // Magnetometer x, y, z magX = mag.m.x; magY = mag.m.y; magZ = mag.m.z; // Keyboard sKeyboard = sKeyboard + String(magX) + "|" + String(magY) + "|" + String(magZ) + "|"; }
getIRRemote.ino
// SparkFun IR Receiver - TSOP85 // Setup void isSetupIR(){ // Initialize digital pin LED Red as an output pinMode(iLEDRed, OUTPUT); // Start the receiver irrecv.enableIRIn(); } // void isIR(){ if (irrecv.decode(&results)) { // LED Red HIGH digitalWrite(iLEDRed, HIGH); //Serial.print("IR RECV Code = 0x "); //Serial.println(results.value, HEX); IRValue = "0x "; IRValue = IRValue + String(results.value, HEX); // LED Red LOW digitalWrite(iLEDRed, LOW); // IR Resume irrecv.resume(); } else { IRValue = "0"; } // Keyboard sKeyboard = sKeyboard + String(IRValue) + "|*"; }
getLineSensor.ino
// Line Sensor // isLine Sensor void isLineSensor(){ // Line Sensor iLineSensor = analogRead(iLine); // Keyboard sKeyboard = sKeyboard + String(iLineSensor) + "|"; }
getRTC.ino
// Date & Time // DS3231 Precision RTC void setupRTC() { // DS3231 Precision RTC if (! rtc.begin()) { //Serial.println("Couldn't find RTC"); //Serial.flush(); while (1) delay(10); } if (rtc.lostPower()) { //Serial.println("RTC lost power, let's set the time!"); // When time needs to be set on a new device, or after a power loss, the // following line sets the RTC to the date & time this sketch was compiled rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); // This line sets the RTC with an explicit date & time, for example to set // January 21, 2014 at 3am you would call: //rtc.adjust(DateTime(2023, 8, 10, 11, 0, 0)); } } // Date and Time RTC void isRTC () { // Date and Time dateRTC = ""; timeRTC = ""; DateTime now = rtc.now(); // Date dateRTC = now.year(), DEC; dateRTC = dateRTC + "/"; dateRTC = dateRTC + now.month(), DEC; dateRTC = dateRTC + "/"; dateRTC = dateRTC + now.day(), DEC; // Time timeRTC = now.hour(), DEC; timeRTC = timeRTC + ":"; timeRTC = timeRTC + now.minute(), DEC; timeRTC = timeRTC + ":"; timeRTC = timeRTC + now.second(), DEC; // Keyboard sKeyboard = "SEN|" + sver + "|" + String(dateRTC) + "|" + String(timeRTC) + "|"; }
getTempTMP102.ino
// SparkFun Digital Temperature Sensor TMP102 // Setup TMP102 void isSetupTMP102(){ // Declare alertPin as an input pinMode(ALERT_PIN,INPUT); // Begin //It will return true on success or false on failure to communicate if(!sensor0.begin()) { while(1); } // set the Conversion Rate //0-3: 0:0.25Hz, 1:1Hz, 2:4Hz, 3:8Hz sensor0.setConversionRate(2); //set Extended Mode. //0:12-bit Temperature(-55C to +128C) 1:13-bit Temperature(-55C to +150C) sensor0.setExtendedMode(0); // Set T_HIGH, the upper limit to trigger the alert on // Set T_HIGH in C sensor0.setHighTempC(29.4); // Set T_LOW, the lower limit to shut turn off the alert // set T_LOW in C sensor0.setLowTempC(27.67); } // is TMP102 void isTMP102(){ // Turn sensor on to start temperature measurement. // Current consumtion typically ~10uA. sensor0.wakeup(); // read temperature data C temperature = sensor0.readTempC(); // Check for Alert // Read the Alert from pin alertPinState = digitalRead(ALERT_PIN); // Read the Alert from register alertRegisterState = sensor0.alert(); // Place sensor in sleep mode to save power. // Current consumtion typically <0.5uA. sensor0.sleep(); // Keyboard sKeyboard = sKeyboard + String(temperature) + "|" + String(alertPinState) + "|" + String(alertRegisterState) + "|"; }
setup.ino
// Setup void setup() { // Give display time to power on delay(100); // Wire - Inialize I2C Hardware Wire.begin(); // Give display time to power on delay(100); // Date & Time RTC // DS3231 Precision RTC setupRTC(); // Initialize control over the keyboard: Keyboard.begin(); // Pololu Setup IMU setupIMU(); // Pololu Setup Magnetometer setupMag(); // Setup TMP102 isSetupTMP102(); // SetupTSOP85 isSetupIR(); // Initialize the Switch pin as an input pinMode(iSwitch, INPUT); // Initialize digital pin LED_BUILTIN as an output pinMode(LED_BUILTIN, OUTPUT); // Turn the LED on HIGH digitalWrite(LED_BUILTIN, HIGH); // Delay 5 Second delay( 5000 ); }
——
People can contact us: https://www.donluc.com/?page_id=1927
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 #28 – Sensors – Digital Temperature Sensor TMP102 – Mk07
——
#DonLucElectronics #DonLuc #Sensors #TMP102 #LineSensor #AlcoholGasSensor #MinIMU9 #Pololu #Adafruit #SparkFun #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant
——
——
——
——
SparkFun Digital Temperature Sensor – TMP102
The TMP102 is an easy-to-use digital temperature sensor from Texas Instruments. The TMP102 breakout allows you to easily incorporate the digital temperature sensor into your project. While some temperature sensors use an analog voltage to represent the temperature, the TMP102 uses the I2C bus of the Arduino to communicate the temperature. Needless to say, this is a very handy sensor that doesn’t require much setup.
The TMP102 is capable of reading temperatures to a resolution of 0.0625°C, and is accurate up to 0.5°C. The breakout has built-in 4.7k Ohm pull-up resistors for I2C communications and runs from 1.4V to 3.6V. I2C communication uses an open drain signaling, so there is no need to use level shifting.
DL2309Mk01
1 x Adafruit METRO M0 Express
1 x DS3231 Precision RTC FeatherWing
1 x Pololu MinIMU-9 v5 Gyro, Accelerometer, and Compass
1 x Pololu Carrier for MQ Gas Sensors
1 x Alcohol Gas Sensor – MQ-3
1 x SparkFun Line Sensor – QRE1113
1 x SparkFun Digital Temperature Sensor – TMP102
1 x ProtoScrewShield
1 x Rocker Switch – SPST
2 x Resistor 10K Ohm
1 x CR1220 3V Lithium Coin Cell Battery
1 x SparkFun Cerberus USB Cable
Adafruit METRO M0 Express
LED – LED_BUILTIN
SDA – Digital 20
SCL – Digital 21
SW1 – Digital 2
MQ3 – Analog 0
LSB – Analog 1
ALE = Analog 3
VIN – +3.3V
VIN – +5V
GND – GND
——
DL2309Mk01p.ino
/****** Don Luc Electronics © ****** Software Version Information Project #28 - Sensors - Digital Temperature Sensor TMP102 - Mk07 28-07 DL2309Mk01p.ino 1 x Adafruit METRO M0 Express 1 x DS3231 Precision RTC FeatherWing 1 x Pololu MinIMU-9 v5 Gyro, Accelerometer, and Compass 1 x Pololu Carrier for MQ Gas Sensors 1 x Alcohol Gas Sensor - MQ-3 1 x SparkFun Line Sensor - QRE1113 1 x SparkFun Digital Temperature Sensor - TMP102 1 x ProtoScrewShield 1 x Rocker Switch - SPST 2 x Resistor 10K Ohm 1 x CR1220 3V Lithium Coin Cell Battery 1 x SparkFun Cerberus USB Cable */ // Include the Library Code // DS3231 Precision RTC #include <RTClib.h> // Two Wire Interface (TWI/I2C) #include <Wire.h> // Keyboard #include <Keyboard.h> // Includes and variables for IMU integration // STMicroelectronics LSM6DS33 Gyroscope and Accelerometer #include <LSM6.h> // STMicroelectronics LIS3MDL Magnetometer #include <LIS3MDL.h> // SparkFun Digital Temperature Sensor TMP102 #include <SparkFunTMP102.h> // Keyboard String sKeyboard = ""; // DS3231 Precision RTC RTC_DS3231 rtc; String dateRTC = ""; String timeRTC = ""; // Pololu 9DoF IMU // STMicroelectronics LSM6DS33 Gyroscope and Accelerometer LSM6 imu; // Accelerometer and Gyroscopes // Accelerometer int imuAX; int imuAY; int imuAZ; // Gyroscopes int imuGX; int imuGY; int imuGZ; // STMicroelectronics LIS3MDL Magnetometer LIS3MDL mag; // Magnetometer int magX; int magY; int magZ; // Gas Sensors MQ // Alcohol Gas Sensor - MQ-3 int iMQ3 = A0; int iMQ3Raw = 0; int iMQ3ppm = 0; // SparkFun Line Sensor - QRE1113 (Analog) int iLine = A1; int iLineSensor = 0; // SparkFun Digital Temperature Sensor TMP102 const int ALERT_PIN = A3; TMP102 sensor0; float temperature; boolean alertPinState; boolean alertRegisterState; // The number of the Rocker Switch pin int iSwitch = 2; // Variable for reading the button status int SwitchState = 0; // Software Version Information String sver = "28-07"; void loop() { // Date and Time RTC isRTC (); // Pololu Accelerometer and Gyroscopes isIMU(); // Pololu Magnetometer isMag(); // Gas Sensors MQ isGasSensor(); // SparkFun Line Sensor isLineSensor(); // SparkFun Temperature TMP102 isTMP102(); // Read the state of the Switch value: SwitchState = digitalRead(iSwitch); // Check if the button is pressed. If it is, the SwitchState is HIGH: if (SwitchState == HIGH) { Keyboard.println(sKeyboard); } // Delay 1 Second delay(1000); }
getAccelGyro.ino
// Accelerometer and Gyroscopes // Setup IMU void setupIMU() { // Setup IMU imu.init(); // Default imu.enableDefault(); } // Accelerometer and Gyroscopes void isIMU() { // Accelerometer and Gyroscopes imu.read(); // Accelerometer x, y, z imuAX = imu.a.x; imuAY = imu.a.y; imuAZ = imu.a.z; // Gyroscopes x, y, z imuGX = imu.g.x; imuGY = imu.g.y; imuGZ = imu.g.z; // Keyboard sKeyboard = sKeyboard + String(imuAX) + "|" + String(imuAY) + "|" + String(imuAZ) + "|"; sKeyboard = sKeyboard + String(imuGX) + "|" + String(imuGY) + "|" + String(imuGZ) + "|"; }
getGasSensorMQ.ino
// Gas Sensors MQ // Gas Sensor void isGasSensor() { // Read in analog value from each gas sensors // Alcohol Gas Sensor - MQ-3 iMQ3ppm = isMQ3( iMQ3Raw ); // Keyboard sKeyboard = sKeyboard + String(iMQ3ppm) + "|"; } // Alcohol Gas Sensor - MQ-3 int isMQ3(double rawValue) { double RvRo = rawValue; // % BAC = breath mg/L * 0.21 double bac = RvRo * 0.21; return bac; }
getIMUMagnetometer.ino
// IMU Magnetometer // Setup Magnetometer void setupMag() { // Setup Magnetometer mag.init(); // Default mag.enableDefault(); } // Magnetometer void isMag() { // Magnetometer mag.read(); // Magnetometer x, y, z magX = mag.m.x; magY = mag.m.y; magZ = mag.m.z; // Keyboard sKeyboard = sKeyboard + String(magX) + "|" + String(magY) + "|" + String(magZ) + "|"; }
getLineSensor.ino
// Line Sensor // isLine Sensor void isLineSensor(){ // Line Sensor iLineSensor = analogRead(iLine); // Keyboard sKeyboard = sKeyboard + String(iLineSensor) + "|"; }
getRTC.ino
// Date & Time // DS3231 Precision RTC void setupRTC() { // DS3231 Precision RTC if (! rtc.begin()) { //Serial.println("Couldn't find RTC"); //Serial.flush(); while (1) delay(10); } if (rtc.lostPower()) { //Serial.println("RTC lost power, let's set the time!"); // When time needs to be set on a new device, or after a power loss, the // following line sets the RTC to the date & time this sketch was compiled rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); // This line sets the RTC with an explicit date & time, for example to set // January 21, 2014 at 3am you would call: //rtc.adjust(DateTime(2023, 8, 10, 11, 0, 0)); } } // Date and Time RTC void isRTC () { // Date and Time dateRTC = ""; timeRTC = ""; DateTime now = rtc.now(); // Date dateRTC = now.year(), DEC; dateRTC = dateRTC + "/"; dateRTC = dateRTC + now.month(), DEC; dateRTC = dateRTC + "/"; dateRTC = dateRTC + now.day(), DEC; // Time timeRTC = now.hour(), DEC; timeRTC = timeRTC + ":"; timeRTC = timeRTC + now.minute(), DEC; timeRTC = timeRTC + ":"; timeRTC = timeRTC + now.second(), DEC; // Keyboard sKeyboard = "SEN|" + sver + "|" + String(dateRTC) + "|" + String(timeRTC) + "|"; }
getTempTMP102.ino
// SparkFun Digital Temperature Sensor TMP102 // Setup TMP102 void isSetupTMP102(){ // Declare alertPin as an input pinMode(ALERT_PIN,INPUT); // Begin //It will return true on success or false on failure to communicate if(!sensor0.begin()) { while(1); } // set the Conversion Rate //0-3: 0:0.25Hz, 1:1Hz, 2:4Hz, 3:8Hz sensor0.setConversionRate(2); //set Extended Mode. //0:12-bit Temperature(-55C to +128C) 1:13-bit Temperature(-55C to +150C) sensor0.setExtendedMode(0); // Set T_HIGH, the upper limit to trigger the alert on // Set T_HIGH in C sensor0.setHighTempC(29.4); // Set T_LOW, the lower limit to shut turn off the alert // set T_LOW in C sensor0.setLowTempC(27.67); } // is TMP102 void isTMP102(){ // Turn sensor on to start temperature measurement. // Current consumtion typically ~10uA. sensor0.wakeup(); // read temperature data C temperature = sensor0.readTempC(); // Check for Alert // Read the Alert from pin alertPinState = digitalRead(ALERT_PIN); // Read the Alert from register alertRegisterState = sensor0.alert(); // Place sensor in sleep mode to save power. // Current consumtion typically <0.5uA. sensor0.sleep(); // Keyboard sKeyboard = sKeyboard + String(temperature) + "|" + String(alertPinState) + "|" + String(alertRegisterState) + "|*"; }
setup.ino
// Setup void setup() { // Give display time to power on delay(100); // Wire - Inialize I2C Hardware Wire.begin(); // Give display time to power on delay(100); // Date & Time RTC // DS3231 Precision RTC setupRTC(); // Initialize control over the keyboard: Keyboard.begin(); // Pololu Setup IMU setupIMU(); // Pololu Setup Magnetometer setupMag(); // Setup TMP102 isSetupTMP102(); // Initialize the Switch pin as an input pinMode(iSwitch, INPUT); // Initialize digital pin LED_BUILTIN as an output pinMode(LED_BUILTIN, OUTPUT); // Turn the LED on HIGH digitalWrite(LED_BUILTIN, HIGH); // Delay 5 Second delay( 5000 ); }
——
People can contact us: https://www.donluc.com/?page_id=1927
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 #28 – Sensors – SparkFun Line Sensor QRE1113 – Mk06
——
#DonLucElectronics #DonLuc #Sensors #LineSensor #AlcoholGasSensor #MinIMU9 #Pololu #Adafruit #SparkFun #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant
——
——
——
——
SparkFun Line Sensor QRE1113 (Analog)
This version of the QRE1113 breakout board features an easy-to-use analog output, which will vary depending on the amount of IR light reflected back to the sensor. This tiny board is perfect for line sensing applications and can be used in both 3.3V and 5V systems.
The board’s QRE1113 IR reflectance sensor is comprised of two parts – an IR emitting LED and an IR sensitive phototransistor. When you apply power to the VCC and GND pins the IR LED inside the sensor will illuminate. A 100 Ohm resistor is on-board and placed in series with the LED to limit current. A 10k Ohm resistor pulls the output pin high, but when the light from the LED is reflected back onto the phototransistor the output will begin to go lower. The more IR light sensed by the phototransistor, the lower the output voltage of the breakout board.
These sensors are widely used in line following robots, white surfaces reflect much more light than black, so, when directed towards a white surface, the voltage output will be lower than that on a black surface.
DL2308Mk07
1 x Adafruit METRO M0 Express
1 x DS3231 Precision RTC FeatherWing
1 x Pololu MinIMU-9 v5 Gyro, Accelerometer, and Compass
1 x Pololu Carrier for MQ Gas Sensors
1 x Alcohol Gas Sensor – MQ-3
1 x SparkFun Line Sensor – QRE1113
1 x ProtoScrewShield
1 x Rocker Switch – SPST
2 x Resistor 10K Ohm
1 x CR1220 3V Lithium Coin Cell Battery
1 x SparkFun Cerberus USB Cable
Adafruit METRO M0 Express
LED – LED_BUILTIN
SDA – Digital 20
SCL – Digital 21
SW1 – Digital 2
MQ3 – Analog 0
LSB – Analog 1
VIN – +3.3V
VIN – +5V
GND – GND
——
DL2308Mk07p.ino
/****** Don Luc Electronics © ****** Software Version Information Project #28 - Sensors - SparkFun Line Sensor QRE1113 - Mk06 28-06 DL2308Mk07p.ino 1 x Adafruit METRO M0 Express 1 x DS3231 Precision RTC FeatherWing 1 x Pololu MinIMU-9 v5 Gyro, Accelerometer, and Compass 1 x Pololu Carrier for MQ Gas Sensors 1 x Alcohol Gas Sensor - MQ-3 1 x SparkFun Line Sensor - QRE1113 1 x ProtoScrewShield 1 x Rocker Switch - SPST 2 x Resistor 10K Ohm 1 x CR1220 3V Lithium Coin Cell Battery 1 x SparkFun Cerberus USB Cable */ // Include the Library Code // DS3231 Precision RTC #include <RTClib.h> // Two Wire Interface (TWI/I2C) #include <Wire.h> // Keyboard #include <Keyboard.h> // Includes and variables for IMU integration // STMicroelectronics LSM6DS33 Gyroscope and Accelerometer #include <LSM6.h> // STMicroelectronics LIS3MDL Magnetometer #include <LIS3MDL.h> // Keyboard String sKeyboard = ""; // DS3231 Precision RTC RTC_DS3231 rtc; String dateRTC = ""; String timeRTC = ""; // Pololu 9DoF IMU // STMicroelectronics LSM6DS33 Gyroscope and Accelerometer LSM6 imu; // Accelerometer and Gyroscopes // Accelerometer int imuAX; int imuAY; int imuAZ; // Gyroscopes int imuGX; int imuGY; int imuGZ; // STMicroelectronics LIS3MDL Magnetometer LIS3MDL mag; // Magnetometer int magX; int magY; int magZ; // Gas Sensors MQ // Alcohol Gas Sensor - MQ-3 int iMQ3 = A0; int iMQ3Raw = 0; int iMQ3ppm = 0; // SparkFun Line Sensor - QRE1113 (Analog) int iLine = A1; int iLineSensor = 0; // The number of the Rocker Switch pin int iSwitch = 2; // Variable for reading the button status int SwitchState = 0; // Software Version Information String sver = "28-06"; void loop() { // Date and Time RTC isRTC (); // Pololu Accelerometer and Gyroscopes isIMU(); // Pololu Magnetometer isMag(); // Gas Sensors MQ isGasSensor(); // SparkFun Line Sensor isLineSensor(); // Read the state of the Switch value: SwitchState = digitalRead(iSwitch); // Check if the button is pressed. If it is, the SwitchState is HIGH: if (SwitchState == HIGH) { Keyboard.println(sKeyboard); } // Delay 1 Second delay(1000); }
getAccelGyro.ino
// Accelerometer and Gyroscopes // Setup IMU void setupIMU() { // Setup IMU imu.init(); // Default imu.enableDefault(); } // Accelerometer and Gyroscopes void isIMU() { // Accelerometer and Gyroscopes imu.read(); // Accelerometer x, y, z imuAX = imu.a.x; imuAY = imu.a.y; imuAZ = imu.a.z; // Gyroscopes x, y, z imuGX = imu.g.x; imuGY = imu.g.y; imuGZ = imu.g.z; // Keyboard sKeyboard = sKeyboard + String(imuAX) + "|" + String(imuAY) + "|" + String(imuAZ) + "|"; sKeyboard = sKeyboard + String(imuGX) + "|" + String(imuGY) + "|" + String(imuGZ) + "|"; }
getGasSensorMQ.ino
// Gas Sensors MQ // Gas Sensor void isGasSensor() { // Read in analog value from each gas sensors // Alcohol Gas Sensor - MQ-3 iMQ3ppm = isMQ3( iMQ3Raw ); // Keyboard sKeyboard = sKeyboard + String(iMQ3ppm) + "|"; } // Alcohol Gas Sensor - MQ-3 int isMQ3(double rawValue) { double RvRo = rawValue; // % BAC = breath mg/L * 0.21 double bac = RvRo * 0.21; return bac; }
getIMUMagnetometer.ino
// IMU Magnetometer // Setup Magnetometer void setupMag() { // Setup Magnetometer mag.init(); // Default mag.enableDefault(); } // Magnetometer void isMag() { // Magnetometer mag.read(); // Magnetometer x, y, z magX = mag.m.x; magY = mag.m.y; magZ = mag.m.z; // Keyboard sKeyboard = sKeyboard + String(magX) + "|" + String(magY) + "|" + String(magZ) + "|"; }
getLineSensor.ino
// Line Sensor // isLine Sensor void isLineSensor(){ // Line Sensor iLineSensor = analogRead(iLine); // Keyboard sKeyboard = sKeyboard + String(iLineSensor) + "|*"; }
getRTC.ino
// Date & Time // DS3231 Precision RTC void setupRTC() { // DS3231 Precision RTC if (! rtc.begin()) { //Serial.println("Couldn't find RTC"); //Serial.flush(); while (1) delay(10); } if (rtc.lostPower()) { //Serial.println("RTC lost power, let's set the time!"); // When time needs to be set on a new device, or after a power loss, the // following line sets the RTC to the date & time this sketch was compiled rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); // This line sets the RTC with an explicit date & time, for example to set // January 21, 2014 at 3am you would call: //rtc.adjust(DateTime(2023, 8, 10, 11, 0, 0)); } } // Date and Time RTC void isRTC () { // Date and Time dateRTC = ""; timeRTC = ""; DateTime now = rtc.now(); // Date dateRTC = now.year(), DEC; dateRTC = dateRTC + "/"; dateRTC = dateRTC + now.month(), DEC; dateRTC = dateRTC + "/"; dateRTC = dateRTC + now.day(), DEC; // Time timeRTC = now.hour(), DEC; timeRTC = timeRTC + ":"; timeRTC = timeRTC + now.minute(), DEC; timeRTC = timeRTC + ":"; timeRTC = timeRTC + now.second(), DEC; // Keyboard sKeyboard = "SEN|" + sver + "|" + String(dateRTC) + "|" + String(timeRTC) + "|"; }
setup.ino
// Setup void setup() { // Give display time to power on delay(100); // Wire - Inialize I2C Hardware Wire.begin(); // Give display time to power on delay(100); // Date & Time RTC // DS3231 Precision RTC setupRTC(); // Initialize control over the keyboard: Keyboard.begin(); // Pololu Setup IMU setupIMU(); // Pololu Setup Magnetometer setupMag(); // Initialize the Switch pin as an input pinMode(iSwitch, INPUT); // Initialize digital pin LED_BUILTIN as an output pinMode(LED_BUILTIN, OUTPUT); // Turn the LED on HIGH digitalWrite(LED_BUILTIN, HIGH); // Delay 5 Second delay( 5000 ); }
——
People can contact us: https://www.donluc.com/?page_id=1927
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 #28 – Sensors – Alcohol Gas Sensor MQ-3 – Mk05
——
#DonLucElectronics #DonLuc #Sensors #AlcoholGasSensor #MinIMU9 #Pololu #Adafruit #SparkFun #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant
——
——
——
——
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—that are broken out with a 0.1″ spacing, making the board compatible with 0.1″ headers and standard breadboards and perfboards. This board has two mounting holes and provides convenient pads for mounting the gas sensor’s required sensitivity-setting resistor.
Alcohol Gas Sensor – MQ-3
This alcohol sensor is suitable for detecting alcohol concentration on your breath, just like your common breathalyzer. It has a high sensitivity and fast response time. Sensor provides an analog resistive output based on alcohol concentration.
How does this relate to the breath? It turns out that there is a standard conversion from breath alcohol content to BAC that is employed by commercial breathalyzers. Our formula for calculating BAC from the alcohol measured in the breath is:
% BAC = Breath mg/L * 0.21
DL2308Mk06
1 x Adafruit METRO M0 Express
1 x DS3231 Precision RTC FeatherWing
1 x Pololu MinIMU-9 v5 Gyro, Accelerometer, and Compass
1 x Pololu Carrier for MQ Gas Sensors
1 x Alcohol Gas Sensor – MQ-3
1 x ProtoScrewShield
1 x Rocker Switch – SPST
2 x Resistor 10K Ohm
1 x CR1220 3V Lithium Coin Cell Battery
1 x SparkFun Cerberus USB Cable
Adafruit METRO M0 Express
LED – LED_BUILTIN
SDA – Digital 20
SCL – Digital 21
SW1 – Digital 2
MQ3 – Analog 0
VIN – +3.3V
VIN – +5V
GND – GND
——
DL2308Mk06p.ino
/****** Don Luc Electronics © ****** Software Version Information Project #28 - Sensors - Alcohol Gas Sensor MQ-3 - Mk05 28-05 DL2308Mk06p.ino 1 x Adafruit METRO M0 Express 1 x DS3231 Precision RTC FeatherWing 1 x Pololu MinIMU-9 v5 Gyro, Accelerometer, and Compass 1 x Pololu Carrier for MQ Gas Sensors 1 x Alcohol Gas Sensor - MQ-3 1 x ProtoScrewShield 1 x Rocker Switch - SPST 2 x Resistor 10K Ohm 1 x CR1220 3V Lithium Coin Cell Battery 1 x SparkFun Cerberus USB Cable */ // Include the Library Code // DS3231 Precision RTC #include <RTClib.h> // Two Wire Interface (TWI/I2C) #include <Wire.h> // Keyboard #include <Keyboard.h> // Includes and variables for IMU integration // STMicroelectronics LSM6DS33 Gyroscope and Accelerometer #include <LSM6.h> // STMicroelectronics LIS3MDL Magnetometer #include <LIS3MDL.h> // Keyboard String sKeyboard = ""; // DS3231 Precision RTC RTC_DS3231 rtc; String dateRTC = ""; String timeRTC = ""; // Pololu 9DoF IMU // STMicroelectronics LSM6DS33 Gyroscope and Accelerometer LSM6 imu; // Accelerometer and Gyroscopes // Accelerometer int imuAX; int imuAY; int imuAZ; // Gyroscopes int imuGX; int imuGY; int imuGZ; // STMicroelectronics LIS3MDL Magnetometer LIS3MDL mag; // Magnetometer int magX; int magY; int magZ; // Gas Sensors MQ // Alcohol Gas Sensor - MQ-3 int iMQ3 = A0; int iMQ3Raw = 0; int iMQ3ppm = 0; // The number of the button pin int iButton = 2; // Variable for reading the button status int buttonState = 0; // Software Version Information String sver = "28-05"; void loop() { // Date and Time RTC isRTC (); // Pololu Accelerometer and Gyroscopes isIMU(); // Pololu Magnetometer isMag(); // Gas Sensors MQ isGasSensor(); // Read the state of the button value: buttonState = digitalRead(iButton); // Check if the button is pressed. If it is, the buttonState is HIGH: if (buttonState == HIGH) { Keyboard.println(sKeyboard); } // Delay 1 Second delay(1000); }
getAccelGyro.ino
// Accelerometer and Gyroscopes // Setup IMU void setupIMU() { // Setup IMU imu.init(); // Default imu.enableDefault(); } // Accelerometer and Gyroscopes void isIMU() { // Accelerometer and Gyroscopes imu.read(); // Accelerometer x, y, z imuAX = imu.a.x; imuAY = imu.a.y; imuAZ = imu.a.z; // Gyroscopes x, y, z imuGX = imu.g.x; imuGY = imu.g.y; imuGZ = imu.g.z; sKeyboard = sKeyboard + String(imuAX) + "|" + String(imuAY) + "|" + String(imuAZ) + "|"; sKeyboard = sKeyboard + String(imuGX) + "|" + String(imuGY) + "|" + String(imuGZ) + "|"; }
getGasSensorMQ.ino
// Gas Sensors MQ // Gas Sensor void isGasSensor() { // Read in analog value from each gas sensors // Alcohol Gas Sensor - MQ-3 iMQ3ppm = isMQ3( iMQ3Raw ); sKeyboard = sKeyboard + String(iMQ3ppm) + "|*"; } // Alcohol Gas Sensor - MQ-3 int isMQ3(double rawValue) { double RvRo = rawValue; // % BAC = breath mg/L * 0.21 double bac = RvRo * 0.21; return bac; }
getIMUMagnetometer.ino
// IMU Magnetometer // Setup Magnetometer void setupMag() { // Setup Magnetometer mag.init(); // Default mag.enableDefault(); } // Magnetometer void isMag() { // Magnetometer mag.read(); // Magnetometer x, y, z magX = mag.m.x; magY = mag.m.y; magZ = mag.m.z; sKeyboard = sKeyboard + String(magX) + "|" + String(magY) + "|" + String(magZ) + "|"; }
getRTC.ino
// Date & Time // DS3231 Precision RTC void setupRTC() { // DS3231 Precision RTC if (! rtc.begin()) { //Serial.println("Couldn't find RTC"); //Serial.flush(); while (1) delay(10); } if (rtc.lostPower()) { //Serial.println("RTC lost power, let's set the time!"); // When time needs to be set on a new device, or after a power loss, the // following line sets the RTC to the date & time this sketch was compiled rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); // This line sets the RTC with an explicit date & time, for example to set // January 21, 2014 at 3am you would call: //rtc.adjust(DateTime(2023, 8, 10, 11, 0, 0)); } } // Date and Time RTC void isRTC () { // Date and Time dateRTC = ""; timeRTC = ""; DateTime now = rtc.now(); // Date dateRTC = now.year(), DEC; dateRTC = dateRTC + "/"; dateRTC = dateRTC + now.month(), DEC; dateRTC = dateRTC + "/"; dateRTC = dateRTC + now.day(), DEC; // Time timeRTC = now.hour(), DEC; timeRTC = timeRTC + ":"; timeRTC = timeRTC + now.minute(), DEC; timeRTC = timeRTC + ":"; timeRTC = timeRTC + now.second(), DEC; sKeyboard = "SEN|" + sver + "|" + String(dateRTC) + "|" + String(timeRTC) + "|"; }
setup.ino
// Setup void setup() { // Give display time to power on delay(100); // Wire - Inialize I2C Hardware Wire.begin(); // Give display time to power on delay(100); // Date & Time RTC // DS3231 Precision RTC setupRTC(); // Initialize control over the keyboard: Keyboard.begin(); // Pololu Setup IMU setupIMU(); // Pololu Setup Magnetometer setupMag(); // Initialize the button pin as an input pinMode(iButton, INPUT); // Initialize digital pin LED_BUILTIN as an output pinMode(LED_BUILTIN, OUTPUT); // Turn the LED on HIGH digitalWrite(LED_BUILTIN, HIGH); // Delay 5 Second delay( 5000 ); }
——
People can contact us: https://www.donluc.com/?page_id=1927
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