Skip to content

11. Input Devices

Hero Shots

Assignement requirements

individual assignment:

  • measure something: add a sensor to a microcontroller board that you have designed and read it

group assignment:

  • probe an input device’s analog levels and digital signals

Group assignement

Here is the link for the group assignement.

Individual assignement

measure something: add a sensor to a microcontroller board that you have designed and read it

For this week assignement use case I will take my final project. For the final project the robot is supposed to be autonomous by following lines for Navigation and detecting obstacles by using some sensor.

The sensors

Line follower : 3-CH Tracking Module (Adeept)

The image you provided is of the Adeept 3-CH Line Tracking Module. Here are the technical details for this module:

Overview:

The Adeept 3-CH Line Tracking Module is designed for use in robotics and automation projects to enable line-following capabilities. It utilizes three infrared (IR) sensors to detect lines or tracks marked with contrasting colors, typically used in educational robotics to create line-following robots.

Key Features:

  1. Three Infrared Sensors: —> L1, L2, and L3: These sensors are arranged in a row, each capable of detecting infrared light reflected from surfaces. They work together to detect the position of a line relative to the robot.

  2. Detection Range: —> Typically effective for detecting lines at a close range, around 1 to 3 cm above the surface, but this can vary depending on the surface and lighting conditions.

  3. Output: —> Digital output for each sensor, indicating whether it detects the line (usually a high or low signal).

  4. Adjustable Sensitivity: —> Potentiometers or other mechanisms to adjust the sensitivity of each sensor, allowing for tuning based on the environment and the type of line being followed.

  5. Power Supply: —> Operates typically at 3.3V to 5V, making it compatible with most microcontrollers and development boards.

  6. Mounting Holes: —> Provides mounting holes for easy attachment to a robot chassis or other structures.

Pin Configuration:

  1. VCC: Power supply (typically 3.3V to 5V).
  2. GND: Ground.
  3. OUT1: Output from the first sensor (L1).
  4. OUT2: Output from the second sensor (L2).
  5. OUT3: Output from the third sensor (L3).

Applications:

  1. Line-Following Robots: The primary use case is in robotics, where the module enables a robot to follow a path marked on the floor with a contrasting line (usually black on white or vice versa).
  2. Maze Solving Robots: Used in more complex projects where the robot needs to navigate through a maze by following lines and making decisions at intersections.
  3. Automated Guided Vehicles (AGVs): In industrial settings, can be used to guide vehicles along predetermined paths.

Typical Use Case:

A small robot equipped with the Adeept 3-CH Line Tracking Module can navigate a track marked on the floor. The module’s IR sensors detect the contrast between the line and the surrounding surface, providing real-time feedback to the robot’s microcontroller. The microcontroller then adjusts the robot’s steering to ensure it stays on the line.

Summary:

The Adeept 3-CH Line Tracking Module is an essential component for building line-following robots. It offers reliable detection with three IR sensors, adjustable sensitivity, and easy integration with various microcontrollers, making it an excellent choice for both educational and practical robotics projects.

Deteting Obstacles : ToF Sensor (Time of Flight) VL53L1X

The sensor in the image is the VL53L1X Time-of-Flight (ToF) Distance Sensor, which is produced by STMicroelectronics and often sold by various electronics suppliers, including Adafruit. Here are the technical details about the VL53L1X sensor:

Overview:

The VL53L1X is a state-of-the-art Time-of-Flight (ToF) laser-ranging sensor, enhancing the VL53L0X by offering a longer ranging distance and greater accuracy. It is designed to measure the time it takes for emitted laser pulses to travel to the nearest object and reflect back to the sensor.

Key Features:

  1. Measurement Range: —> Up to 4 meters (4000 mm) —> Accurate ranging up to ±1% (in ideal conditions).

  2. Field of View (FoV): —> Programmable from 15° to 27°

  3. Distance Modes: —> Short, medium, and long-distance modes to optimize performance based on the specific application requirements.

  4. Operating Voltage: —> 2.6V to 3.5V.

  5. Communication Interface: —> I2C interface, allowing easy integration with microcontrollers and other digital systems —> Typical I2C address: 0x29.

  6. Low Power Consumption: —> Designed for low power operation, suitable for battery-operated devices.

  7. High-Speed Measurements: —> Capable of taking high-speed measurements with an output rate of up to 50 Hz.

  8. Embedded Microcontroller: —> The sensor integrates a microcontroller for data processing, which simplifies interfacing and offloads processing from the main application processor.

Pin Configuration:

  1. VIN: Power supply (2.6V to 5.5V).
  2. GND: Ground.
  3. SDA: I2C data line.
  4. SCL: I2C clock line.
  5. XSHUT: Shutdown pin (used to turn off the sensor).
  6. GPIO1: General-purpose input/output pin, can be used for interrupt signaling.

Applications:

  1. Obstacle Detection: Suitable for robotics and automation for detecting obstacles and enabling navigation.
  2. Gesture Recognition: Used in user interface devices to detect and interpret hand movements.
  3. Proximity Sensing: Ideal for presence detection in smart devices and security systems.
  4. Distance Measurement: Utilized in various industrial and consumer applications for accurate distance measurement.

Typical Use Case: The VL53L1X sensor can be mounted on a robotic vehicle to detect obstacles within its path. By measuring the time taken for the laser pulses to reflect from objects, the sensor can provide real-time distance data, allowing the robot to navigate safely around obstacles.

Summary:

The VL53L1X ToF Distance Sensor offers a robust solution for applications requiring precise distance measurements, with the added benefits of low power consumption, compact size, and easy integration via I2C. Its versatility makes it suitable for a wide range of applications in robotics, automation, and consumer electronics.

The Microcontroller

Here is the technical information for the Seeed Studio XIAO ESP32C3 presented in a table:

Feature Specification
Microcontroller ESP32-C3
Processor 32-bit RISC-V single-core processor
Clock Speed Up to 160 MHz
Flash Memory 4 MB
SRAM 400 KB
Wi-Fi 802.11 b/g/n
Bluetooth Bluetooth 5 (LE)
GPIO Pins 11 digital I/O pins
ADC 6 analog inputs (12-bit resolution)
UART 1
I2C 1
SPI 1
PWM Multiple PWM outputs
USB Type-C for power and programming
Input Voltage 3.3V to 5V via USB Type-C
Dimensions 21 x 17.5 mm
Logic Level 3.3V
IDE Support Arduino IDE, PlatformIO, ESP-IDF
Programming Languages C/C++, MicroPython, CircuitPython
3V3 3.3V power output
GND Ground
EN Chip enable
0-10 (GPIO) General-purpose input/output pins
A0-A5 Analog input pins
TX/RX UART serial communication pins
SDA/SCL I2C communication pins
SCK/MISO/MOSI/CS SPI communication pins
Applications IoT devices, wireless communication, embedded systems, prototyping
Typical Use Case Smart home devices, remote sensors, data logging, environmental monitoring

This table should provide a clear and concise overview of the technical aspects of the Seeed Studio XIAO ESP32C3.

Electronics design & Production

PCB Design

For the deign of my project I will use KiCAD software.

Schematics

PCB layout

Production

Soldering

Board Features
  • One (01) I2C port : is responsible for serial data transfer and clock synchronization.
  • One (01) I2C port : for the ToF Sensor;
  • Yellow Pins : The power Pins of the board : 12V;
  • A 5V regulation system to reduce the voltage from 12V to 5V : This area with a voltage regulator chip converts incoming voltage to a stable 5V output, necessary for powering the components on the board that require 5V.
  • A 04 pins connector : For a Ring LED to display the status of the program (When is connected to wifi or not, whille executing a command)
  • A 05 pins connector : for the line following sensor 3-CH Line tracking module which the structure explain at the top;
  • A XIAO ESP32C3 to control all the boards components

Testing & Programming

Here is the program code :

#include <Adafruit_VL53L0X.h>

// Broches des capteurs de ligne
#define LEFT_SENSOR_PIN 2
#define CENTER_SENSOR_PIN 3
#define RIGHT_SENSOR_PIN 4

// Adresse I2C du capteur de distance
#define VL53L0X_ADDRESS 0x29

// Initialiser le capteur VL53L0X
Adafruit_VL53L0X lox = Adafruit_VL53L0X();

unsigned long previousMillis = 0; // Pour stocker le temps précédent
const long interval = 1000; // Intervalle de 1 seconde (1000 millisecondes)

void setup() {
  Serial.begin(115200);
  Serial.println("Setup started");

  // Configurer les broches des capteurs de ligne comme entrées
  pinMode(LEFT_SENSOR_PIN, INPUT);
  pinMode(CENTER_SENSOR_PIN, INPUT);
  pinMode(RIGHT_SENSOR_PIN, INPUT);

  // Initialiser le capteur de distance
  setupDistanceSensor();

  Serial.println("Setup completed");
}

void checkLineSensors() {
  int leftSensor = digitalRead(LEFT_SENSOR_PIN);
  int centerSensor = digitalRead(CENTER_SENSOR_PIN);
  int rightSensor = digitalRead(RIGHT_SENSOR_PIN);

  Serial.print("L: ");
  Serial.print(leftSensor);
  Serial.print("   ");
  Serial.print("C: ");
  Serial.print(centerSensor);
  Serial.print("   ");
  Serial.print("R: ");
  Serial.println(rightSensor);
}

void setupDistanceSensor() {
  if (!lox.begin(VL53L0X_ADDRESS, &Wire)) {
    Serial.println(F("Failed to initialize VL53L0X sensor"));
    while (1);
  }
  Serial.println(F("VL53L0X sensor initialized"));
}

void readObstacleSensor() {
  VL53L0X_RangingMeasurementData_t measure;

  lox.rangingTest(&measure, true);
  if (measure.RangeStatus != 4) {  
    Serial.print("Distance (mm) : ");
    Serial.println(measure.RangeMilliMeter);
    if (measure.RangeMilliMeter < 300) {
      Serial.println("Obstacle detected, stopping");
    }
  } else {
    Serial.println("Out of range");
  }
}

void loop() {
  unsigned long currentMillis = millis();

  // Vérifier si 1 seconde s'est écoulée
  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;

    // Afficher les valeurs des capteurs de ligne
    checkLineSensors();

    // Afficher la valeur du capteur de distance
    readObstacleSensor();
  }
}

Design Files


Last update: July 15, 2024