When I power my esp32 with an USB cable and check the readings of JSN-SR04 it shows correct and consistent readings. But when I connect esp32 and jsn with 5v from LM2596 12V input errors are not correct and sometimes consistent. Can anyone help me with this?
Either the voltage is not 5V, or it cannot supply the current or more likely there is an instability on the power rail. You need to check it with a scope. Also make sure you have all the recommended capacitors in place for smoothing the LM2596. My guess is residual spikes from the switching