ESP32 + JSN-SR04T wont read more than 40cm

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?

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

Hi,
Is your power supply able to feed the ESP32 and JSN-SR04T?
How many mA can it deliver?

Well it is getting the power via the USB port from my PC as I am developing.
I will see what happens if I load the MQTT / Web server code and run it from a power supply.

I have it now on an external power supply and the range is jumping around all over the place if the distance is more than 40 cm. If I use the normal Uno the range is stable up to 4 meters.

The power supply is 5v 3000 mA

Anybody else have this issue?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.