hrs04 distance sensor not working

Hello, I'm trying to measure distance on a client and on a server on a ESP8266 (using ESPAsyncTCP) and the distance sensor is working on the client only with the same code of the server.
The server serial always displays 0 cm, what could be the problem? I'm using the NewPing library to control the hrs04.
Thank you for helping

what could be the problem?

It could be the code you didn't post, or the wiring you didn't post the schematic of.

while(distance>20 || distance==0)
        {
        
        uS = sonar.ping(); // Send ping, get ping time in microseconds (uS).
        distance=sonar.convert_cm(uS);
        Serial.print("Distance: ");
        Serial.print(distance); // Convert ping time to distance and print result (0 = outside set distance range, no ping echo)
        Serial.println("cm");
       
        delay(50);              // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings.
        }

This is the code I used in both programs, the wiring is correct because the sensor is working with a test code, does anyone knows if there is any problem with ESPAsyncTCP?

That code doesn't compile.

It is just a portion,

add
#include "NewPing.h"
NewPing sonar(TRIG_PIN, ECHO_PIN, MAX_DIST);
unsigned int uS;
unsigned int distance;

Still doesn't compile.
Please stop time-wasting.

I'm just looking for help, the code itself compiles and it doesn't work probably because of some other library

Ok.
Best of luck.

giacomoporetti:
probably because of some other library

Sorry, crystal ball is out of order, no "some other library" found.

wvmarle:
Sorry, crystal ball is out of order, no "some other library" found.

I mean ESPAsyncTCP