This is a very simple project. In principle it is a power socket which has to be explicitly switched on then stays on while a person remains in its vicinity. After a pre-set period of not detecting any activity via its PIR sensor, it switches off until it is explicitly switched on again by the user. Prior to switching off, it alarms the user during a timed interval and any activity detected during this interval resets the timer keeping the device switched on.
The main use cases would be, for example, controlling a soldering iron or similar device which should not be left unattended for an extended period.
It is based on an ATtiny1614 using the development core megaTinyCore by SpenceKonde (aka @DrAzzy) however, it could easily be ported to other Arduino capable chips since the code uses no explicit register manipulation or other low level accesses.
The main controls are an AM312 PIR sensor, but others may also work, and a push button. The PIR sensor detects persons in its vicinity and the push button is used to toggle the device on and, if necessary, also off. Two pre-set potentiometers control the main “ON” period and the “Alarm” period. Another potentiometer controls the buzzer alarm volume.
The schematic diagram and code are supplied for anyone attempting to duplicate this project. The schematic, however, omits details of the mains side wiring and this project should be tackled by makers only with experience of mains circuits.