

The AJ-SR04M is an ultrasonic distance sensor designed to measure distances by emitting ultrasonic waves and calculating the time it takes for the echo to return. This sensor is widely used in robotics, automation, and IoT applications for tasks such as obstacle detection, distance measurement, and level sensing. Its robust design and reliable performance make it suitable for both indoor and outdoor environments.








The AJ-SR04M offers precise distance measurement capabilities with a durable and water-resistant design. Below are its key technical details:
| Parameter | Value |
|---|---|
| Operating Voltage | 5V DC |
| Operating Current | ≤ 15mA |
| Measuring Range | 2cm to 450cm |
| Accuracy | ±3mm |
| Operating Frequency | 40kHz |
| Output Signal | High/Low digital pulse |
| Trigger Input Signal | 10µs TTL pulse |
| Echo Output Signal | Pulse width proportional to distance |
| Operating Temperature | -15°C to +60°C |
| Dimensions | 45mm x 20mm x 15mm |
| Waterproof Rating | IP65 |
The AJ-SR04M has four pins for interfacing with microcontrollers or other devices. The table below describes each pin:
| Pin | Name | Description |
|---|---|---|
| 1 | VCC | Power supply input (5V DC) |
| 2 | Trig | Trigger pin: Sends a 10µs pulse to initiate measurement |
| 3 | Echo | Echo pin: Outputs a pulse width proportional to distance |
| 4 | GND | Ground connection |
Below is an example of how to interface the AJ-SR04M with an Arduino UNO to measure distance:
// Define pin connections
const int trigPin = 9; // Trigger pin connected to digital pin 9
const int echoPin = 10; // Echo pin connected to digital pin 10
void setup() {
pinMode(trigPin, OUTPUT); // Set trigPin as an output
pinMode(echoPin, INPUT); // Set echoPin as an input
Serial.begin(9600); // Initialize serial communication at 9600 baud
}
void loop() {
// Send a 10µs HIGH pulse to the Trig pin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Measure the duration of the HIGH pulse on the Echo pin
long duration = pulseIn(echoPin, HIGH);
// Calculate the distance in centimeters
float distance = duration / 58.0;
// Print the distance to the Serial Monitor
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");
delay(500); // Wait for 500ms before the next measurement
}
No Output from the Echo Pin
Inaccurate Distance Measurements
Fluctuating Readings
Sensor Not Working Outdoors
Q: Can the AJ-SR04M detect transparent objects?
A: Ultrasonic sensors may struggle with transparent objects like glass, as they can absorb or refract ultrasonic waves. For such cases, consider alternative sensing technologies.
Q: What is the maximum effective range of the AJ-SR04M?
A: The sensor can measure distances up to 450cm, but accuracy may decrease at longer ranges.
Q: Can I use the AJ-SR04M with a 3.3V microcontroller?
A: The AJ-SR04M requires a 5V power supply. If using a 3.3V microcontroller, a level shifter is recommended for safe operation.
Q: How do I improve measurement accuracy?
A: Ensure the sensor is mounted securely, avoid environmental noise, and calibrate the sensor in the intended environment.
This concludes the documentation for the AJ-SR04M ultrasonic distance sensor.