An Arduino IDE sketch (and a video) for using an ultrasonic HC-SR04 sensor with an ESP 8266 / ESP 32 microcontroller in order to detect and report motion by e-mail. Please just read the code, the thing is pretty obvious, the "hardest" part for you will be picking where to send your e-mails to and which two pins to connect the ultrasonic sensor on.
Video explanation: https://youtu.be/u5eR52f5Wx4