ESP32 + JSN-SR04T wont read more than 40cm

JacoFourie
Posts: 13
Joined: Mon Jan 22, 2018 7:54 pm

ESP32 + JSN-SR04T wont read more than 40cm

Postby JacoFourie » 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?

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);
}
if I use a 5v 3 amp power supply the distance will jump around from 40 - 200 cm.

JacoFourie
Posts: 13
Joined: Mon Jan 22, 2018 7:54 pm

Re: ESP32 + JSN-SR04T wont read more than 40cm

Postby JacoFourie » Fri Nov 18, 2022 6:35 pm

Anybody ?????

Who is online

Users browsing this forum: No registered users and 46 guests