Aj Sr04m Datasheet May 2026

// Add 1kΩ resistor from Echo to ESP32 pin, and 2kΩ from pin to GND. // Then code same as Arduino but use pulseIn() or interrupts. 10.3 Raspberry Pi (Python) import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) TRIG = 23 ECHO = 24 GPIO.setup(TRIG, GPIO.OUT) GPIO.setup(ECHO, GPIO.IN)

AJ-SR04M is the best all-rounder for outdoor/wet applications needing short-range detection (2 cm blind zone). JSN-SR04T has longer range but larger blind zone (20 cm). HC-SR04 is indoor only. 10. Application Circuit & Code Examples 10.1 Arduino (Standard) #define TRIG 9 #define ECHO 10 void setup() Serial.begin(9600); pinMode(TRIG, OUTPUT); pinMode(ECHO, INPUT); aj sr04m datasheet

void loop() digitalWrite(TRIG, LOW); delayMicroseconds(2); digitalWrite(TRIG, HIGH); delayMicroseconds(10); digitalWrite(TRIG, LOW); // Add 1kΩ resistor from Echo to ESP32

while GPIO.input(ECHO) == 0: pulse_start = time.time() while GPIO.input(ECHO) == 1: pulse_end = time.time() JSN-SR04T has longer range but larger blind zone (20 cm)

For better than 1% accuracy, read a separate temp sensor (e.g., DS18B20) and compute:

Some versions have a 5th pin (EN – Enable), but standard 4-pin is most common. If present, tie EN to VCC to enable. Wiring Example (Arduino): AJ-SR04M → Arduino Uno VCC → 5V Trig → Digital Pin 9 Echo → Digital Pin 10 GND → GND 3. Theory of Operation & Timing Diagram The AJ-SR04M uses the same timing protocol as HC-SR04, but with improved signal conditioning for longer cable runs.