You might find this tutorial (I wrote for my IoT students) helpful.
One thing to note is the HC-SR04 and -SR05 are powered from +5v.
This means you will need a level shifter (details are in the tutorial) if you plan to use it with a RPi or ESP8266 - otherwise you will probably destroy the Pi or the microcontroller !!!!!!