If you want to use the original code, then this is how to connect your sensor to your D1 Mini:
#define echoPin 14 // Echo Pin <--------- Pin D5 on Wemos D1 Mini
#define trigPin 12 // Trigger Pin <--------- Pin D6 on Wemos D1 Mini
If you want to use the connections you’ve specified, then change the code to this:
#define echoPin 2 // Echo Pin <--------- Pin D4 on Wemos D1 Mini
#define trigPin 0 // Trigger Pin <--------- Pin D3 on Wemos D1 Mini
However, using pin D3 (GPIO0) isn’t a good idea, and pin D4 (GPIO2) is connected to the builtin LED, which also isn’t a good idea.
See this post for more info…
Pete.