It is an IOT subject and an ESP-Basic subject. However it is also a complete project.
My girlfriend has some paintings in a gallery that is sometimes unmanned. However there are people in the same building (it's a library) so I had to find a way to warn them when a painting is being moved.
This can easily be adapted for being an alarm when a door or window is opened or someone is trying to steel your cookies or butterfingers......
Easy with a vibration sensor, an ESP8266-01 and some simple ESP-Basic code. Packed in my own designed 3D printed box.
Look here for full instructions, schematics and code:
http://lucstechblog.blogspot.com/2018/11/alarm.html
Luc