Chip ROM

Hello guys. I need your help about chips and EEPROM (or ROM). I want to make a system with an arduino chip OR attiny85 (doesnt matter) that counts everytime it detects movement in a room for a very big time span (for a prank). I can use PIR sensor. BUT the problem is that it will often run out of power. So I have to make the chip write somewhere that when the chip is off, the variable with stored memory is not lost. It has to write in its ROM everytime the value of the variable "checks" increases. How to make a chip write in its ROM and then read it back?

(deleted)