Don't eat my candies!
This is the best solution for cookie monsters! We quickly made a smart lid with sensors that watch how many candies are left in the jar, check if the jar is open or not and have a loud buzzer to scare snackers.
Step 1: Circuit Diagram
Connect HC-SR04 ultrasonic sensor to the hSens1 port of your CORE2. Connect ESP8266 adapter of course, to make your lid internet connected. Connect also buzzer to any hServo port - we only use it as program controlled power source. Think of how you can put everything in to the lid or print in 3D your customized lid as we did. Then attach CORE2 and microswitch to the lid, so the switch is released when jar is opened. At the and connect power supply. We used 3 rechargeable batteries and attached it with zip ties.
Step 2: Assembly
Simply connect CORE2 with 4x M3 screws and nuts to any jar's lid. We prepared our unique, 3D printed lid.
Then try to put any sensors, buzzer and battery underr the lid, as we did.