Page 1 of 1

Turning on/off motion sensor through android

Posted: Tue Mar 22, 2016 4:53 am
by eternalfroast
here is the basic of the code

if motionVallue == 3 when on is pressed in android 3 comes as value in python
then it search for the input from the motion sensor
infinite loop

if motionValue == 2
stop the motion sensor


This is not working. i can turn on the motion sensor. then the loop continues. and it never accepts motionValue == 2 part. It just continue the motion.. I did try using break. Then it stop sensing. Any ideas on how to make the motionValue == 2 work..The loop should be continuous and when press off button it should off the motion sensor and if on the motion sensor should be on without the programming terminating.

Re: Turning on/off motion sensor through android

Posted: Tue Mar 22, 2016 5:14 am
by Laurens-wuyts
I think you should try something like this:

Code: Select all

infinite loop {
    if motionVallue == 3 when on is pressed in android 3 comes as value in python
    then it search for the input from the motion sensor

    if motionValue == 2
    stop the motion sensor
}
Laurens

Re: Turning on/off motion sensor through android

Posted: Tue Mar 22, 2016 10:55 pm
by mysen
in python it's this...

and by the way, i looked EVERYWHERE on the internet for this code but i had to work it out myself through alot of pain and frustration. consider this an internet exclusive haha!

Code: Select all

import subprocess
subprocess.call("sudo -u root service motion start/stop", shell=true)
also go to /etc/init.d find the service and set permissions that work. i suggest 755 but it depends on your situation because of security.

Code: Select all

sudo chmod 755 motion