Dear Forum,
I am not a programmer from profession, so i might sounf a bit simple.
Trying to get a graphic with the device code below.
Want to register de number of times the PIR is triggered every 10 minutes and then register the counter, light level and power.
My problem is the PIR trigger which is not counting the events.
Can anyone help with this (simpe??) problem?
Thanks for reply in advance.
Arjen
Device code:
/********************************************************************************* PIR motion sensor device code written in Squirrel For more information on connecting a PIR sensor, check out the following two links: http://electricimp.com/docs/api/hardware/pin/read/ http://codergirljp.blogspot.com/2014/01/electric-imp-hello-world-motion-sensor.html *********************************************************************************/ // Assign pin1 to your PIR sensor. This is important because pin1 supports // wake-from-sleep (which allows you to avoid looping). pir_sensor <- hardware.pin1; local pir_state = pir_sensor.read(); local pir_count = 0 //
motionDetected` will be called each time the PIR sensor’s state
// changes (so, for both “on” and “off” states). We’re going to do all
// our LED state and logging work in here.
function motionDetected() {
local pir_state = pir_sensor.read();
local pir_count = pir_count + 1
}
function SendToXively()
{
local light = hardware.lightlevel();
local power = hardware.voltage()
local pir_state = pir_sensor.read();
agent.send("SendToXively", {id = "Impee_LightLevel", value = light});
agent.send("SendToXively", {id = "Impee_PowerLevel", value = power});
agent.send("SendToXively", {id = "Impee_MotionSensor", value = pir_count});
local pir_count = 0
imp.sleep(600); // 10 minutes
}
SendToXively();`