Aj Sr04m Datasheet -
long duration = pulseIn(ECHO, HIGH, 30000); // timeout 30ms (≈5m) if (duration == 0) Serial.println("Out of range"); else float distance = duration / 58.3; Serial.print("Distance: "); Serial.print(distance); Serial.println(" cm");
1. Overview & Key Differentiators The AJ-SR04M is an improved, industrial-grade variant of the popular HC-SR04. Unlike the standard HC-SR04, this module is enclosed in a waterproof, IP67-rated housing , making it suitable for outdoor, dusty, or humid environments (e.g., tank level sensing, outdoor robotics, car reverse sensors). aj sr04m datasheet
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); long duration = pulseIn(ECHO, HIGH, 30000); // timeout