I am trying to build a motion sensor with my Pi that can deliver notification to a program on my computer when it detects motion. I installed apache on the Pi, the server works. I wrote a very simple python script for motion detection which writes the file 'motion' when it detects something, and deletes it otherwise.
My index.php looks something like this:
<?php
while(!file_exists('motion')) {
sleep(0.5);
}
echo "MOTION DETECTED";
?>
The program on my computer tries to access the page every 60s until it has a response, in which case it delivers a notification.
Everything works well, but it seems to me that writing a file accesses the disk which is slower than accessing the RAM. I was wondering if there is anyway to communicate between the python script and the php script without having to write a file (or using a file related method). This would also prevent errors in file reading/writing permissons.
Thank you.