ragoth
Junior Member
Posts: 64
|
Post by ragoth on May 7, 2017 2:10:43 GMT
Dear Papa, I am having a peculiar problem with my battery operated "Door Sensor Node" that is, Sometimes it misses to send or may be the receiver fails to receive the status Open or Closed, and it stays in that condition and goes to sleep mode. Unless the door is activated again from open to close or close to open to make it awake it keeps on sleeping with that false status of the Door. About the Node: That node has nothing but only one reed switch connected to D3 to make it awake and send the status. The interrupt option is set to respond to Change i.e., triggered by Low to High or High to Low of D3 so that it wakesup for open or closing of the door to send the status and then sleep. Suppose if it misses to trigger it shows the false status untill it is wakesup again by the door. Please advise, how can I include a periodic transmission so that even while it sleeps it should wake up once in a Minute, send the status then goto sleep.
|
|
|
Post by papa on May 8, 2017 1:16:02 GMT
I'm moving ragoth's request to its own thread. I'd prefer we do it this way rather than add a new request to a thread of a different topic. I believe this is easier to follow & easier to index for future reference.
ragoth, it's been a while since I looked at this low power / sleep stuff so it's a little fuzzy to me. Besides for my irrigation automation project, I'm in the middle of running water lines & electricity while I have good weather.
That said, looking over the version of the Multi-Choice End Node Sketch you are using, I believe instead of #define MAIL, you could use #define PIR & you might get or be close to what you're looking for: a trigger when D3 changes & a periodic wakeup & send no matter what.
In the sketch version you posted, particularly look at the code starting at line 1391: #else // when node is on battery power & PIR
The length of sleep (unless D3 changes) is set by line 218) int PIRloops = 112; // If PIR on battery sipping node, how many 8 sec loops of sleep ?? With PIRloops = 112, the node will sleep up to nearly 15 minutes. If you change it to PIRloops = 6, then 8 times 6 gives you 48 seconds of sleep (unless D3 interrupts). (Be aware this will use more battery than the way with #define MAIL. However, you might tolerate a longer sleep than 48 seconds & improve battery life.
Try experimenting with the above. I don't have time at the moment to do so.
Does anyone else want to give a shot at helping ragoth?
|
|
|
Post by papa on May 8, 2017 3:11:19 GMT
PS ragoth, if you are wiring your node like the Mail End node, you might need to add this piece similar to the MAIL code into void setup() [after line 487]
#ifdef PIR pinMode(PirInput, INPUT_PULLUP); // pull D3 high w internal resistor #endif // ifdef PIR Accordingly in lines 1391 - 1425, change all instances of HIGH to LOW
This will muddy things for actual PIR usage, but we can clean things up later if the above tweaks work for you.
PPS The PIR function communicates via device 41. So the OpenHAB item entries would use dev41 accordingly.
Again, does anyone else want to give a shot at helping ragoth?
|
|
|
Post by papa on May 15, 2017 20:36:53 GMT
ragoth, what I proposed above (modified PIR option) does not seem to work so I'm taking another approach. I believe what you ask is possible, that a sleeping node wakes & sends the state of pin D3 ... 1) when pin D3 changes state AND 2) when a determined length of time ends. I'll let you now if I work that out later. In this post below, I believe I give a better solution than the one in this post. What I propose here (& successfully tested) is something that may work better than what you have now using the MAIL option. (See the next to the last paragraph below for a summary of how this approach works.) Wire the node like the following, that is connect the reed wires to D 5 (not D3) & ground. << Click pic for larger view. In the choices sketch, use your typical customizations (NODEID, FREQUENCY, etc). For testing purposes, program a wall-powered mode & turn on (UNcomment) DEBUG & watch the Serial Monitor. After you see how it works, you can use a battery powered node & turn off DEBUG. ALSO in the sketch, use (UNcomment) #define SWITCH1 & #define SLEEPY AND comment out #define MAIL. Find the line that starts " int Loops =" & change it. "int Loops = 6" will give 48 seconds of sleep before the node wakes up & sends data (RSSI, volts, resends, AND the state of D5). For testing purposes, you might use a lower number like int Loops = 4 for 32 seconds, or 3 for 24 seconds. In your OpenHAB .items file add a line like (Change ragoth "ragoth07 as you desire, & change accordingly in the following .sitemap file.) Contact ragoth "ragoth07 [%s]" <lock> {mqtt="<[mosquitto:home/rfm_gw/nb/node07/dev43:state:OPEN:OFF],<[mosquitto:home/rfm_gw/nb/node07/dev43:state:CLOSED:ON]"} add .sitemap file entry: Text item= ragothWorking the node like the above means the node will sleep (& save battery power) for the number of 8-second loops you define & only then wake up & report the defined data (including the state of D5). OpenHAB User Interface will report the reed & door OPEN or CLOSED. The node should always report D5's state (reed closed = door closed), but when D5's state changes, it's not reported until whatever is left of the current sleep period ends. This will seem long as you watch it, but should not matter much in real operation. As I said above, using a periodic sleep & send like this will use more battery than only sending data when an interrupt is called via a change in D3, but much less than an always-on node. Let me know how this works for you.
|
|
|
Post by papa on May 16, 2017 1:48:31 GMT
ragoth, I believe I now understand the problem(s) you had with your version of the choices sketch using the Mail option & have now fixed them ( See this post below). 1) The MAIL option had been written to sleep the node & only wake up & report when pin D3 connected to GND. (Otherwise D3 is pulled high via code.) For what you want, you need to detect a reed was OPEN (thus the door was open). The MAIL code was not written that way, but will be in the updated version of your sketch. 2) You commented out MAIL's send RSSI & send voltage (which is fine), but you confused the bracketing & missed adding detection of D3 being HIGH (reed & door open, D3 HIGH via code pull up). Below in blue text, I comment on your version of the code. BTW, you changed the attachInterrupt code somewhat which is necessary to what you want.
|
|
ragoth
Junior Member
Posts: 64
|
Post by ragoth on May 16, 2017 2:26:31 GMT
Thank you so much for keeping my problem in your mind all these days and thinking for a solution. I will try your suggestion and get back to you with my results. Thanks with great regards, Ragoth.
|
|
|
Post by papa on May 16, 2017 2:57:30 GMT
OK, ragoth, I believe this post gives the best solution so far to the problems you had with using the Mail Node for a reed sensor on a door. Selecting the MAIL option, this sketch should sleep the node & only wake up (via an interrupt) to report a change in D3. I believe you'll NOT need to add a periodic wake up & send. This should be best to make the battery last. Try it for a while to be sure. computourist_node_v2.2Mg4_DoorSensor_ragoth....ino (63.15 KB) ^^ Here is the tweaked Choices sketch. Recheck customizations (NODEID, ENCRYPTKEY, FREQUENCY, etc.) As with the original MAIL node schematic, connect the reed's leads to D3 & GND ( NOT D5 as my earlier fix used). In your OpenHAB .items file, add a line like (Change ragoth "ragoth07 as you desire, & change accordingly in the following .sitemap file entry. Note once again, it uses dev46, not dev43) Contact ragoth "ragoth07 [%s]" <lock> {mqtt="<[mosquitto:home/rfm_gw/nb/node07/ dev46:state:OPEN:OFF],<[mosquitto:home/rfm_gw/nb/node07/ dev46:state:CLOSED:ON]"} add .sitemap file entry: Text item=ragoth =========================== BTW, with a minor tweak to the rule originally added for the MAIL function, I believe the altered sketch will still work for a MAIL node. Thanks, ragoth for bring this to my attention. I believe it's resulted in improved code. In the latest version of my Choices sketch, I hope to generalized the changes in the MAIL option for more types of nodes.
|
|
|
Post by papa on May 17, 2017 14:53:05 GMT
In the thread " Battery-Powered Node for Mailbox, Door, Window, etc.", I posted the latest version of my Choices sketch where I generalized the changes in the MAIL option for more types of battery-powered nodes like sensors for doors & windows. That thread contains instructions on building & programming a battery powered node & get it communicating with OpenHAB.
|
|