25 years expertise in connectivity

Aj Sr04m Datasheet -

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

| Pin | Name | Function | |-----|------|-----------| | 1 | VCC | +5V DC (regulated) | | 2 | Trig | Trigger input (active high, 10 µs min pulse) | | 3 | Echo | Echo output (PWM width = time of flight) | | 4 | GND | Ground | aj sr04m datasheet

// 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) For better than 1% accuracy, read a separate temp sensor (e

Actual distance = Measured distance * (343.0 / sqrt(331.3 * (1 + T_celsius/273.15))) | Parameter | Conditions | Value | |-----------|------------|-------| | Supply voltage | Absolute max | 5.5V | | Supply voltage | Operating | 4.5V – 5.5V | | Logic input low | Trig, EN | < 0.8V | | Logic input high | Trig, EN | > 2.0V (3.3V compatible) | | Echo output low | IOL = 2mA | < 0.4V | | Echo output high | IOH = 2mA | > 4.0V (5V logic) | | Output impedance | - | 100 Ω | JSN-SR04T has longer range but larger blind zone (20 cm)

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);

void loop() digitalWrite(TRIG, LOW); delayMicroseconds(2); digitalWrite(TRIG, HIGH); delayMicroseconds(10); digitalWrite(TRIG, LOW);