ESP32 + JSN-SR04T wont read more than 40cm
Posted: Thu Nov 10, 2022 9:25 pm
Hi all. If I use the JSN-SR04T sensor on the ESP32 it will read fine between 20 - 40 cm.
It will not read more than 40 CM yet the same code on an Arduino Uno will read up to 4 meters.
Why is that?
if I use a 5v 3 amp power supply the distance will jump around from 40 - 200 cm.
It will not read more than 40 CM yet the same code on an Arduino Uno will read up to 4 meters.
Why is that?
Code: Select all
#define ECHOPIN 17
#define TRIGPIN 16
void setup() {
Serial.begin(115200);
pinMode(ECHOPIN,INPUT_PULLUP);
pinMode(TRIGPIN, OUTPUT);
digitalWrite(ECHOPIN, HIGH);
}
void loop() {
digitalWrite(TRIGPIN, LOW);
delayMicroseconds(2);
digitalWrite(TRIGPIN, HIGH);
delayMicroseconds(15);
digitalWrite(TRIGPIN, LOW);
int distance = pulseIn(ECHOPIN, HIGH, 26000);
distance=distance/58;
Serial.print(distance);
Serial.println(" cm");
delay(1000);
}