The Alpha Geek – Geeking Out

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

——

SparkFun Line Sensor QRE1113

——

SparkFun Line Sensor QRE1113

——

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

Leave a Reply

Your email address will not be published. Required fields are marked *

Categories
Archives