Thanks! I don't think the SR04 will work at all. Too low voltage. As I don't know everything about the ESP I wonder if the onboard regulator likes such a low voltage.
You can't compare very different kinds of sensors like that. The SR04 is an ultrasonic I think. It uses more power when sending the sound pulse than any passive sensor like soil moisture...
But, of course, try.
ESP8266 and ESP32 can operate from a single 18650 battery, because it´s minimum required voltage is 3V. In the other hand, you´re right and SR-04 won´t operate.
It will not help you at all, because ESP works in 3.3 level and it will not provide you 5V to feed the sensor. Moreover, if you feed the sensor with 5V, the ECHO channel will return a 5V signal to ESP, which can damage it.
Well, that´s a question that I didn´t do to myself before. I´m using a module like the one below. Maybe it has a level shifter on the board, since it´s also able to recharge the battery.
Level shifters are used for logic signals, not for power.
Quoting: "Maybe it has a level shifter on the board". Maybe is alarming. Posting guesses that are wrong will be taken serious by ignorant members giving them really bad advice.
I like these modules. They combine charging of the 18650 battery via USB micro connector, protection circuits for the battery and a boost converter that can be set to 5V to power the HCSR04.
The level shifter will still be required on the echo output of the rangefinder to protect the ESP and I do not know if the HCSR04 will trigger from 3.3V.