Sunday, January 26, 2025

Different type of ESP32S pins

1. Power Pins

Pin NamePurpose
VINInput power (5V or 3.3V) from an external source.
3.3VOutput 3.3V to power external components (like sensors or modules).
GNDGround pins, connect to the ground of other components.

2. GPIO Pins

  • These are General Purpose Input/Output (GPIO) pins, meaning they can be used for reading inputs or controlling outputs.
  • ESP32S has up to 36 GPIO pins, but not all are available on every board.
Pin NamePurpose
GPIO0Boot mode pin. Used to flash programs when held low during boot. Can also be used as a general GPIO.
GPIO1UART TX pin (default). Can also be used as a general GPIO.
GPIO2General GPIO pin. Often connected to the onboard LED on some boards.
GPIO3UART RX pin (default). Can also be used as a general GPIO.
GPIO4-19General-purpose GPIO pins. Can be configured for input, output, PWM, I2C, SPI, ADC, etc.
GPIO20+Some higher GPIO numbers may have restricted use depending on the board design.

3. Analog Pins

  • ADC (Analog-to-Digital Converter):

    • Up to 18 ADC pins (like GPIO32 to GPIO39) that read analog signals and convert them to digital (12-bit resolution).
    • Example: Reading the output from a potentiometer or temperature sensor.
  • DAC (Digital-to-Analog Converter):

    • GPIO25 and GPIO26 can output analog signals (like generating an audio signal).

4. Communication Pins

UART (Serial Communication):

Pin NamePurpose
TX (GPIO1)Transmits data (UART TX).
RX (GPIO3)Receives data (UART RX).

I2C (Inter-Integrated Circuit):

Pin NamePurpose
SDA (GPIO21)Data line for I2C communication.
SCL (GPIO22)Clock line for I2C communication.

SPI (Serial Peripheral Interface):

Pin NamePurpose
MOSI (GPIO23)Master Out Slave In.
MISO (GPIO19)Master In Slave Out.
SCLK (GPIO18)Clock signal.
SS (GPIO5)Chip select (Slave Select).

I2S (Inter-IC Sound):

  • Used for audio communication (e.g., microphones and speakers).
  • Pins vary based on configuration.

5. PWM Pins

  • Any GPIO pin can generate Pulse Width Modulation (PWM) signals for controlling:
    • LED brightness.
    • Servo motors.
    • DC motor speed.

6. Touch Sensor Pins

  • ESP32S has 10 capacitive touch pins. These can sense touch or proximity (like touch buttons). | Touch Pin | GPIO Equivalent | |---------------|----------------------| | T0 | GPIO4 | | T1 | GPIO0 | | T2 | GPIO2 | | T3 | GPIO15 | | T4 | GPIO13 | | T5 | GPIO12 | | T6 | GPIO14 | | T7 | GPIO27 | | T8 | GPIO33 | | T9 | GPIO32 |

7. Special Purpose Pins

Pin NamePurpose
ENEnable pin. Pulling this pin low resets the ESP32.
BOOTUsed to put ESP32 into bootloader mode for uploading code.

Saturday, January 25, 2025

Winter vacation homework (2024-2025) Bhiwani Public School, DRP Bhiwani Public School

 

What is an IR Sensor?

An IR sensor (Infrared sensor) is a tiny electronic device that can detect objects and measure distances using infrared light.


How Does an IR Sensor Work?

  1. Emission:
    The sensor has an infrared LED that emits invisible light.

  2. Reflection:
    If there’s an object in front of the sensor, the light hits it and bounces back.


Example Analogy:
Imagine you clap your hands in a cave. The sound bounces off the walls and comes back as an echo. The time it takes for the echo to return tells you how far the wall is.


Real-Life Applications of IR Sensors

  1. Remote Controls:

    • The buttons on your TV remote send infrared signals to the TV to change channels or volume.
    • Every time you press a button, it’s like sending a secret invisible message to the TV!
  2. Automatic Doors:

    • Have you ever walked toward a mall or shop door, and it opened automatically?
    • That’s because an IR sensor detects when someone is near and signals the door to open.
  3. Obstacle Detection in Robots:

    • Robots use IR sensors to detect walls or objects, so they don’t bump into things.
  4. Home Security Systems:

    • IR sensors can detect if someone is moving in front of your house at night, triggering alarms or lights.
  5. Hand Sanitizer Dispensers:

    • The ones you wave your hand under, and sanitizer comes out?
    • That’s an IR sensor detecting your hand!

Fun Fact:

IR sensors are so cool because they use light you can’t see, but it helps devices see the world around them! It’s like giving “invisible vision” to gadgets.


What is an Ultrasonic Sensor?

An ultrasonic sensor is a special device that can measure distances or detect objects using sound waves.


  • It sends out high-frequency sound waves (so high that humans can’t hear them).
  • It listens for the echo of these sound waves bouncing back.
  • Based on how long the echo takes to return, it calculates how far the object is.

How Does an Ultrasonic Sensor Work?

  1. Emit Sound Waves:

    • The sensor has a part called a transmitter that sends out sound waves (ultrasonic waves).
    • These sound waves travel through the air like ripples in water.
  2. Reflection (Echo):

    • If there’s an object in the way, the sound waves hit it and bounce back.

Real-Life Applications of Ultrasonic Sensors

  1. Parking Sensors in Cars:

    • Ever seen a car beep when it gets too close to a wall or another car while parking?
    • That’s an ultrasonic sensor measuring how far the car is from an obstacle.
  2. Robots Avoiding Obstacles:

    • Ultrasonic sensors help robots move around without bumping into walls or furniture.
  3. Automatic Water Level Detection:

    • Used in water tanks to measure how full the tank is. If the water level gets too low, it can alert or start the pump.
  4. Medical Scanners (Ultrasound):

    • Doctors use ultrasonic sensors in ultrasound machines to see images of internal organs or babies in the womb.
  5. Smart Trash Bins:

    • Ultrasonic sensors detect when your hand is near the bin, and the lid opens automatically.
  6. Drones and Robots:

    • Ultrasonic sensors help drones stay at the right height or avoid crashing into trees.

Fun Fact:

While IR sensors use light, ultrasonic sensors use sound. That’s why ultrasonic sensors work even in the dark—they don’t need light to "see."

 

What are Ultrasonic wave ?

 

What Are Ultrasonic Waves?

  • Ultrasonic waves are sound waves that are so high-pitched that humans cannot hear them.
  • Humans can hear sounds between 20 Hz to 20,000 Hz (this is called the audible range).
  • Ultrasonic waves have frequencies higher than 20,000 Hz, which makes them inaudible to our ears.

How Are Ultrasonic Waves Used?

  • Bats: Use ultrasonic waves to "see" in the dark (echolocation).
  • Dolphins: Use them to communicate and navigate underwater.

How TV remote IR sensor works ?

 How TV remote IR sensor works ?

  • The TV remote acts as the transmitter:
    It sends out infrared light signals (like a message) when you press a button.

  • The TV has the receiver:
    It detects and reads the infrared signals sent by the remote and performs the action (like changing the channel or volume).



Type of IR Sensor in the TV

The IR sensor used in TVs is typically called an IR Receiver Module or Photo Diode-Based IR Sensor.

Components of the TV IR Sensor:

  1. Photodiode (or IR Detector):

    • A special component that detects infrared light.
    • It generates a small electrical signal when IR light falls on it.
  2. Demodulator Circuit:

    • Decodes the signal received by the photodiode.
    • Removes any unnecessary noise or extra signals in the environment (like sunlight or heat).
  3. Output Signal:

    • After decoding, the IR sensor sends a clean signal to the TV’s microcontroller, telling it what command was received.

Type of IR Transmission

The TV remote uses Modulated IR Light, meaning the infrared light is turned on and off in a specific pattern (called a frequency, often around 38 kHz).

  • This modulation helps the TV distinguish the remote’s signal from ambient IR light, like sunlight or other heat sources.

How to Categorize This TV IR Sensor:

The TV IR sensor is a Passive IR Sensor, specifically a TSOP (Thin Small Outline Package) IR Receiver Module.


Examples of Common TV IR Receiver Modules:

  1. TSOP1738
  2. TSOP1838
  3. VS1838B

What is IR sensor ? How IR sensor works ?

What is an IR Sensor ?

An IR sensor ( Infra-red Sensor) is a device that uses invisible light to detect objects or measure distances.


How Does an IR Sensor Work?

  1. Two Main Parts:

    • IR Emitter (like a flashlight): Sends out invisible infrared light.
    • IR Receiver (like an eye): Detects the infrared light that bounces back from an object.
  2. What Happens?

    • The IR emitter sends out infrared light.
    • If there’s an object in front of the sensor, the light hits the object and reflects back.
    • The IR receiver detects the reflected light and tells the system, “Hey, there’s something in front of me!”
  3. Application: Everyday Examples of IR Sensors

    • TV Remote: Sends infrared signals to your TV to change channels. 
    • Automatic Doors: Open when they detect someone nearby using IR sensors.
    • Obstacle Avoiding Robots: IR sensors help them avoid crashing into walls.
  4. Activity Idea for Students (How i can see the IR (Infrared light))

    Take a TV remote and point it at a phone camera. Press any button, and they’ll see the infrared light blinking on the camera screen! This makes the "invisible" infrared light visible to them.

  5. Key Points for Students

    • Pulse Patterns: The remote sends specific patterns of IR pulses for each button. For example, pressing "Volume Up" sends a different signal than "Channel Up."
    • Line of Sight: IR signals usually need a clear path to the TV sensor, which is why remotes don’t work well if something blocks the sensor.





Two_RFID_Interface_Ambulance_System_Sunil_Singh_Negi

 #include <SPI.h>

#include <MFRC522.h>


// Define pins for RFID readers

#define RST_PIN_1 9

#define SDA_PIN_1 10

#define RST_PIN_2 7

#define SDA_PIN_2 8


// Define LED pins

#define LED_1_PIN 5  // LED for RFID reader 1

#define LED_2_PIN 6  // LED for RFID reader 2


MFRC522 rfid1(SDA_PIN_1, RST_PIN_1); // RFID reader 1

MFRC522 rfid2(SDA_PIN_2, RST_PIN_2); // RFID reader 2


void setup() {

  Serial.begin(9600);

  

  SPI.begin(); // Initialize SPI bus

  

  // Initialize RFID readers

  rfid1.PCD_Init();

  rfid2.PCD_Init();

  

  // Initialize LEDs as outputs

  pinMode(LED_1_PIN, OUTPUT);

  pinMode(LED_2_PIN, OUTPUT);

  

  // Turn off LEDs initially

  digitalWrite(LED_1_PIN, LOW);

  digitalWrite(LED_2_PIN, LOW);

  

  Serial.println("Place card/tag near one of the readers...");

}


void loop() {

  // Check RFID Reader 1

  if (rfid1.PICC_IsNewCardPresent() && rfid1.PICC_ReadCardSerial()) {

    Serial.print("Reader 1 detected card ID: ");

    printCardID(rfid1);

    rfid1.PICC_HaltA(); // Halt reader 1

    

    // Blink LED for RFID reader 1

    blinkLED(LED_1_PIN);

  }

  

  // Check RFID Reader 2

  if (rfid2.PICC_IsNewCardPresent() && rfid2.PICC_ReadCardSerial()) {

    Serial.print("Reader 2 detected card ID: ");

    printCardID(rfid2);

    rfid2.PICC_HaltA(); // Halt reader 2

    

    // Blink LED for RFID reader 2

    blinkLED(LED_2_PIN);

  }

}


// Function to print the RFID card ID

void printCardID(MFRC522& reader) {

  for (byte i = 0; i < reader.uid.size; i++) {

    Serial.print(reader.uid.uidByte[i], HEX);

  }

  Serial.println();

}


// Function to blink the LED

void blinkLED(int ledPin) {

  digitalWrite(ledPin, HIGH); // Turn on the LED

  delay(500);                // Keep it on for 500 ms

  digitalWrite(ledPin, LOW); // Turn off the LED

}


Thursday, January 23, 2025

8x8 Dot matrix display (4 matrix wala)_Sunil_Singh_Negi

 #include <MD_Parola.h>

#include <MD_MAX72XX.h>
#include <SPI.h>

// Define hardware type and number of modules
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 4 // Updated to match 5 dot matrix displays

// Define pins for the MAX7219
#define DATA_PIN   11
#define CLK_PIN    13
#define CS_PIN     10

// Initialize the Parola library
MD_Parola display = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);

void setup() {
  // Initialize the display
  display.begin();
  display.setIntensity(5); // Set brightness (0-15)
  display.displayClear();
 
  // Set scrolling speed
  display.setSpeed(50);
}

void loop() {
  // Display scrolling text
  if (display.displayAnimate()) { // Check if the animation is complete
    display.displayScroll("Welcome Sunil Singh", PA_LEFT, PA_SCROLL_LEFT, 50);
  }
}

Wednesday, January 22, 2025

Difference between Ultrasonic sensor and IR sensor.

 

Feature Ultrasonic Sensor IR Sensor
Working Principle
Uses sound waves (ultrasonic waves) to measure distance Uses infrared light (emission and reflection) to detect objects.
Speed Slower, becuase sound wave is slower then light wave.Faster response time, light wave is faster then sound wave.



MUD Three Mode operation Manual Automatic GPS

 Code for three mode operation: /*   3-Mode Headlight Controller   - Manual mode (driver uses a toggle to pick high/low)   - Auto mode (LDR...