What is wrong with this sketch?
-
Ok, I am going to try to make some use of that info. But can I still use "sleep( <interrupt>, <time>) ;" when I also need to monitor the A0 (Pressure)? Will the Pressure still trigger when the sensor sleeps and there are no motion?
-
Ok, I am going to try to make some use of that info. But can I still use "sleep( <interrupt>, <time>) ;" when I also need to monitor the A0 (Pressure)? Will the Pressure still trigger when the sensor sleeps and there are no motion?
@Cliff-Karlsson
You cannot use sleep of any kind, because it will power down the radio, and you need that running 100% of the time for the repeater function. -
Ok, I am going to try to make some use of that info. But can I still use "sleep( <interrupt>, <time>) ;" when I also need to monitor the A0 (Pressure)? Will the Pressure still trigger when the sensor sleeps and there are no motion?
@Cliff-Karlsson It depends what kind of pressure sensor you have, i will probably be enough if you poll it each second or so. And as @corbin mentioned don't use repeater function when you sleep.
-
@Cliff-Karlsson It depends what kind of pressure sensor you have, i will probably be enough if you poll it each second or so. And as @corbin mentioned don't use repeater function when you sleep.
Ok, I know this is probably very basic. But exactly how would I modify the original sketch to have it behave like this?
-
Ok, I know this is probably very basic. But exactly how would I modify the original sketch to have it behave like this?
I dont really understand what you mean. You want it to send its value every second? In that case my attempt still works. You want to use interrupts?
-
@nielsokker said:
I dont really understand what you mean. You want it to send its value every second? In that case my attempt still works. You want to use interrupts?
I just want a sketch that updates the status of the pressure sensor when it goes from HIGH to LOW or from LOW to HIGH. And when Movement is detected, but does only report back to the controller when a actual change has happened.
In my last sketch all seemed to work except it "spammed" the controller with the motion-sensor:
2016-07-19 11:38:53.250 (RFM) Lighting 2 (Säng Motion) 2016-07-19 11:38:54.354 (RFM) Lighting 2 (Säng Motion) 2016-07-19 11:38:54.411 (RFM) Lighting 2 (Säng Motion) 2016-07-19 11:38:55.515 (RFM) Lighting 2 (Säng Motion) 2016-07-19 11:38:55.574 (RFM) Lighting 2 (Säng Motion) 2016-07-19 11:38:56.678 (RFM) Lighting 2 (Säng Motion) 2016-07-19 11:38:56.736 (RFM) Lighting 2 (Säng Motion) 2016-07-19 11:38:57.842 (RFM) Lighting 2 (Säng Motion) 2016-07-19 11:38:57.899 (RFM) Lighting 2 (Säng Motion) 2016-07-19 11:38:59.003 (RFM) Lighting 2 (Säng Motion) 2016-07-19 11:38:59.061 (RFM) Lighting 2 (Säng Motion) 2016-07-19 11:39:00.166 (RFM) Lighting 2 (Säng Motion) -
@nielsokker said:
I dont really understand what you mean. You want it to send its value every second? In that case my attempt still works. You want to use interrupts?
I just want a sketch that updates the status of the pressure sensor when it goes from HIGH to LOW or from LOW to HIGH. And when Movement is detected, but does only report back to the controller when a actual change has happened.
In my last sketch all seemed to work except it "spammed" the controller with the motion-sensor:
2016-07-19 11:38:53.250 (RFM) Lighting 2 (Säng Motion) 2016-07-19 11:38:54.354 (RFM) Lighting 2 (Säng Motion) 2016-07-19 11:38:54.411 (RFM) Lighting 2 (Säng Motion) 2016-07-19 11:38:55.515 (RFM) Lighting 2 (Säng Motion) 2016-07-19 11:38:55.574 (RFM) Lighting 2 (Säng Motion) 2016-07-19 11:38:56.678 (RFM) Lighting 2 (Säng Motion) 2016-07-19 11:38:56.736 (RFM) Lighting 2 (Säng Motion) 2016-07-19 11:38:57.842 (RFM) Lighting 2 (Säng Motion) 2016-07-19 11:38:57.899 (RFM) Lighting 2 (Säng Motion) 2016-07-19 11:38:59.003 (RFM) Lighting 2 (Säng Motion) 2016-07-19 11:38:59.061 (RFM) Lighting 2 (Säng Motion) 2016-07-19 11:39:00.166 (RFM) Lighting 2 (Säng Motion)I see why. But once again, i think i made your sketch work.
As i see it. This is the current desired logic.
once per second, you want to check the following things:
- is there motion?
- has there been a change in pressure (HIGH to LOW or LOW to HIGH)?
But actually you want to check both ALWAYS. The thing you are obviously looking for, are interrupts. I do not know how these work if you do not want to sleep. Maybe there is a wait(interrupt_pin_1_functor, interrupt_pin_2_functor, waittime=forever) function (I know the sleep() version exists).
Maybe you already know what interrupts are but, in short: When a given interrupt pin notices a difference in value (HIGH to LOW, for example) it gives a signal. The current code is being stopped and the function that is bound to the pin is executed. This function could be sending the new value to the gateway.
Can someone confirm this?
-
I tried again with your sketch @nielsokker , I think I only added some sleep. But the motion-sensor just turns on/off super-quick every time the motion triggers. What am I doing wrong ?
-
I tried again with your sketch @nielsokker , I think I only added some sleep. But the motion-sensor just turns on/off super-quick every time the motion triggers. What am I doing wrong ?
@Cliff-Karlsson how is your motion sensor powered? It needs a solid power supply
-
I tried again with your sketch @nielsokker , I think I only added some sleep. But the motion-sensor just turns on/off super-quick every time the motion triggers. What am I doing wrong ?
@Cliff-Karlsson said:
I tried again with your sketch @nielsokker , I think I only added some sleep. But the motion-sensor just turns on/off super-quick every time the motion triggers. What am I doing wrong ?
Yea, my example just checks both sensors every second. So it sends both values every second. I know now that is not what you want. At least the code looks better in my opinion (ofc its my code :) ).
I have to agree with @AWI that it seems like your sensor does not work properly.
-
ahh!!!, you where right. I powered the node using a mobile charger but had not connected the PIR to the same GND as the charger. Now it works.