|
Post by papa on Dec 3, 2015 0:16:43 GMT
Added 12/9/2015: This became a Multi-Choice Node (with battery-sipping option)
(This thread was formerly "Battery-sipping DHT Node (a la Computourist)." In a new thread, One Sketch Generates Many Node Functions, I have updated this multi-choice sketch & added new options. (3 additions were made there on 5/4/2016)
Info in this thread below may be useful to implementing the latest version.
I aim here to post some history & progress about a Battery-sipping DHT Node (a la Computourist) & then document more progress later. On Nov 16, lhw455 started the New transmission control for RFM69's thread to which I responded interest regarding the possibility of a RELIABLE battery powered node, saving power through sleeping, etc. I invited Computourist to respond. He said maybe he'd add the Automatic Transmission Control in a future update & continued ... With my limited coding (actually better adapting existing stuff), but dogged determination, I offered ... Well that bare bones 3.3v Arduino DHT end node worked as a DHT node, but drained the battery pack about .4 v every 24 hours, probably better than a manufactured board, but not close to good enough. So I studied JeeLabs, LowPowerLabs, Gammon, etc & begin to adapt the original Computourist DHT End Node, using the LowPower library & #ifdefine statements. It was not working so well. Meantime, Gandalph referred to & updated his previous post on a battery powered node ... Here's the sketch posted from the June 12 posting ... Gandalph's sketch used the LowPower library & #ifdefine statements somewhat like I had, but his showed promise of working better than mine. So I started tinkering with it. It offers #ifdefine statements aimed to select what sensors to be used: PIR, DS18 Temperature, DHT Temp / Humidity, push button, & a sleep mode for battery powered. It's program code starts: // #define DHT #define PIR // #define BUTTON // #define DS18 #define SLEEPY //node on batteries? can be used with either DS18 or PIR (not both due watchdog interference) So as is, it's set for using a PIR sensor on a battery-sipping node. I assume that works, but I did not try it. I wanted to do a basic battery-sipping DHT node & add from there. When for that, I changed the above code like this, I got various problems ... #define DHT // #define PIR // #define BUTTON // #define DS18 #define SLEEPY //node on batteries? can be used with either DS18 or PIR (not both due watchdog interference) First off, "DHT" is a keyword in the DHT library. Using it for the define statement threw error message at regular code referring to the library. The way the #ifdefine statements were used did not seem to work for a DHT only battery node. So I worked on that. I also had an exchange with kmac about using DHT sensors with sleep modes ... PS The data sheet I saw said, "DHT11’s power supply is 3- 5.5V DC. .... One capacitor valued 100nF can be added between VDD and GND for power filtering." Regarding warm up times for DHT sensors, I decided for the moment NOT to sleep that sensor. I'm guessing the main power draw is when the Arduino sketch calls for a reading & when the Arduino is sleeping (& not calling) maybe the DHT won't draw much power. So I believe I've come up with a reliable bare bones Arduino on a solder board with no LEDs, no USB, no push buttons, etc (though still a MCP 1702 3.3v voltage regulator with a drop out voltage of .625 volts) to minimize power somewhat. I also adapted gandalph's sketch so on battery, it sleeps the radio transceiver AND in chosen increments of 8 seconds (now at 64 seconds), it sleeps the Arduino. Then it awakens to send the data: RSSI, voltage, temperature, & humidity. So far, it's reporting data nicely to the OpenHAB user interface & the node seems to be not dropping the voltage near as fast. I'll let it run & see how it does. [ I know some of you will want to hear what current it draws, but so far my current readings with my multimeter are not working. ] When I clean up the adapted computourist/gandalph sketch, I will post it plus some pics & a fritz of the board. To be continued ...
|
|
|
Post by papa on Dec 4, 2015 2:08:39 GMT
The same bare board node with no sleeping dropped battery pack about .4 volts per 24 hours. With radio & microprocessor mostly sleeping then waking every 64 seconds to send data, the battery pack voltage has not dropped enough to show on my multimeter. The node continues to post reliably to OpenHAB & the user interface. I'll now start to document the hardware & software. Below on Dec 14, I begin documenting a new version of the sketch that I hope is easier to configure & tests / tweaks using a PIR sensor Parts list for a Bare Bones Arduino DHT Node, especially for batteries (Assuming tools like soldering iron, solder, something to hold the board while soldering, needle nose pliers, nippers) Battery box with wires (3 or 4 AA or AAA) + batteries Note: All parts with solder pins need to be spaced .1 inch apart 2 position terminal block, .1 inch pin spacing A Solder-able Breadboard, preferably double sided like this from SparkFun (I believe double sided solder better, especially for those of us whose skill is still developing.) OR (Single Sided) BusBoard Solderable PC BreadBoard (SB404) at JamecoRFM69Hx radio transceiver, frequency determined by what's allowed in your region / country (915 MHz for the U.S. & I believe 433MHz for Europe & 868MHz for UK) ATMEGA328P-PU microprocessor (integrated circuit or IC) 28-pin IC socket22 gauge insulated wire (multi-colors ??) MCP1702 3.3v voltage regulator AND two ceramic 1 micro farad capacitors DHT11 temperature / humidity sensor AND a 4.7 kilo ohm resistor 8 MHz Crystal AND two ceramic 22 pico farad capacitors to use with it About 30 Break Away Female Headers (.1" spacing), if like me, you want to plug in components like rfm69 transceiver & DHT11 sensor Here's one source. Optional: LED & 100 ohm or 220 ohm or 1 kilo ohm resistor ^^ Note: computourist used 1 kilo ohm resistor with LEDs. I prefer 100ohm which lets the LED be somewhat brighter without burning out. For dimmer LED & to reserve more current to other node parts, use higher than 100 ohms. May 19, 2016, computourist said: With 100 ohms, current will be around 15 mAmps, well within specs. 12/6/2015 addition to the Parts List (The circuit to program the Bare Bones Arduino.) A regular 5 volt Arduino Uno & a half solder-less breadboard (30 x 14 holes, .1 inch apart) a 16 MHz crystal & two 22 pico Farad capacitors one 100 nF (0.1 μF) capacitor One each of red, green, & yellow LED (& a 100 ohm or 220 ohm or 1 kilo ohm resistor for each) See Note above about LED resistors. several colorful jumper cables (male connectors on both ends) To be continued ...
|
|
|
Post by computourist on Dec 4, 2015 15:51:28 GMT
Sounds good papa, maybe some hints: - You could use one of the Arduino outputs as a power supply to the DHT. In this way you can shut it off when the Arduino is asleep. Once woken, set the output pin high, wait 2 secs and off you go..
- The voltage regulator still uses power, even when the Arduino is asleep. You could try connecting the Arduino it directly to the batteries (2 AA batteries for 3 volts). If you use Lion I would put a diode in series with the RFM69. The 3.7 Volts of the Lion battery would then be lowered by 0.7 Volts by the diode.
Hope this helps to lower your power needs...
|
|
|
Post by lhw455 on Dec 6, 2015 16:11:03 GMT
Thanks for this papa, am excited for this!
|
|
|
Post by papa on Dec 6, 2015 20:31:07 GMT
You're welcome, lhw455, it's satisfying to make some progress.
Thanks, Computourist, for your followup. Yes, I was aware of that method of powering the DHT sensor from digital output, but again I wondered if the sensor was mostly using power when the sketch called for it & not when the ATMega328 was sleeping. What do you think on that? Also looks to me like a DHT warmup of 1 second (or a little more) might be enough.
Yes, I realized the MCP1702-33 voltage regulator had overhead power waste. Acc. to the data sheet, "The MCP1702 is a family of CMOS low dropout (LDO), positive voltage regulators that can deliver up to 250 mA of current while consuming only 2.0 μA of quiescent current (typ.). The input operating voltage range is specified up to 13.2V, making it ideal for lithium-ion (one, two or three cells), 9V alkaline and other three to six primary cell battery-powered applications. The MCP1702 is capable of delivering 250 mA with an input-to-output voltage differential (dropout voltage) of 650 mV. [0.65 volts]"
I had already built the test battery node & first wanted to see how it did with no sleeping (about .4 volt fall per 24hours, not too good). Then I wanted to see what improvements happened from sleeping the radio & the ATMega for 64 seconds & then sending RSSI, voltage, temp, & humidity. (So far that's just .02 TOTAL voltage drop over about 100 hours, pretty good I think without waiting too long for the data on the user interface.
Yes, from my research, it also looked like the next low hanging fruit for nice-sized improvement might be direct battery power (eliminating the voltage regulator & directly using battery combinations to achieve safe & effective power for the node components.) From the data sheets, seems like ATMega328P-PU operates fine 1.8 V to 5.5 V & RFM69 1.8 - 3.6v so 2 AA batteries should work well for them. However, data sheet says DHT11 should operate 3.3 - 6V. One AA in the green on a battery tester reads 1.5 volts on my multimeter & two AA's read 2.99v so I wonder if two AA's would be adequate for the DHT.
On the other hand, ATMega & DHT should be ok with 3 AA's at 4.5 volts & falling, but 4.5v seems too much for for the RFM69. Until you mentioned it, I did not consider using a diode to reduce voltage (to protect the RFM69), like that from a 3.7 Lion battery, but that would "waste" & use up battery power like a voltage regulator, right? Though I suppose that waste would only happen when the radio is awake. Likewise if we intend to power the DHT from an ATMega328 digital pin, we need to run the ATMega at adequate voltage for DHT11 (3.3 - 6 volts), but not too much for the RFM69 (1.8 - 3.6volts).
Looks like the sweet spot for ATMega328 AND RFM659 AND DHT11 is the 3.3 volts we get from the MCP1702 voltage regulator. Or am I missing another possibility? If I'm right, we could just use the voltage regulator & 3 to 4 AA batteries. OR we could use a 3.7 Lion battery with something to knock it down to 3.3-3.5 volts. Acc to Wikipedia "A silicon diode has a typical voltage drop of 0.6–0.7 V, while a Schottky diode has a voltage drop of 0.15–0.45 V." Sparkfun tutorial on diodes says, "Typically, a silicon diode will have a forward voltage around 0.6-1V. A germanium-based diode might be lower, around 0.3V." If we can find the right germanium diode 3.7v - .3 = 3.4 volts, ok for all the components & (?? less waste of battery ??).
Not having a 3.7 volt Lithium ion battery at present, I may let the node run as is with the voltage regulator OR make a new one seeing if two AAs will provide right power for all components. Meanwhile I can consider ordering a 3.7 Lion & making sure I have a diode with the necessary forward voltage.
Anyone else see other options?
Oh, I can continue documenting building a battery power node & providing the gandalph sketch as I adapted it for DHT11 alone.
|
|
|
Post by papa on Dec 6, 2015 22:15:24 GMT
Building a Battery-Sipping DHT End Node (Hardware)See the parts list I posted above on Dec 3, 2015 at 8:08pm. For general hints about tools & assembly, I recommend you skim & glean what you need from my Success... posts starting Oct 8, 2015 at 6:40pm. You'll still need the Gateway whose build & code I described there. You'll still need OpenHAB server & its config files which I described (& provided samples) in that thread. For this node, you will need to solder wires to the RFM69 radio transceiver (as described in the Success... posts). This hardware will NOT start with a manufactured Arduino [or compatible] or add-on shield, but rather will build the main Arduino guts from scratch on a circuit board. Note: What follows builds a bare bones Arduino that uses a voltage regulator to achieve 3.3 volt operation from 3 or 4 AA batteries. It is a typical bare bones Arduino, a bit like a battery power node in the original Uber Home Automation Instructable plus wiring for the DHT11 temp / humidity sensor. Caution: I'm looking at eliminating the voltage regulator for possibly better battery efficiency. So as you build, you might keep in mind that the MCP1702 regulator & its capacitors may go away in the future. Added 12/9/2015: I soldered breakaway female headers (see Dec 3 parts list) where I wanted to plug in the wires of the DHT11 sensor, the RFM69 radio transceiver, & the optional LED. See the Success... post Oct 10, 2015 at 8:01am for hints on using the breakaways. I soldered the 28 pin IC socket so as to receive the ATMega328 microprocessor. See pictures below at the Dec 7, 2015 at 1:23pm post. See soldering hints in the Success... post Sep 28, 2015 at 6:52pm. << Schematic for a Battery-Sipping DHT End Node (voltage regulator) ^^ Schematic correction: for the optional LED it's ok to use a 100 ohm resistor. DHT Node-battery-LED-terminal-no reset-twk.fzz (36.54 KB) << Fritz of Battery-Sipping Node (Note: You need the open source Fritzing program.) Parts' positions & shapes are skewed for visibility & Fritzing's limits. Use your judgement when assembling. << A picture of the Fritzing layout of the node (much more useful in the Fritzing program) (Click on the pic for a larger view) Next: Without a USB port on the Battery Node, how do we program it? Then one version of the Battery-Sipping DHT End Node program sketch. (See 1/6/2016 post for the latest version.)
|
|
|
Post by papa on Dec 7, 2015 1:32:54 GMT
Without a USB port on the Battery Node, how do we program it? We can use a regular Arduino as a programmer.
This programmer circuit works well for me:
For the parts, see the 12/6/2015 addition at the end of the Dec 3, 2015, 8:08pm parts list. Arduino as Flash Programmer.fzz (8.65 KB) < Here is a Fritzing file of the circuit < Here is a picture of the Fritzing file (Click on the pic for a larger view) On the bread board, the ATMega328's pin 1 is the lower left pin connected to Arduino digital pin 10. ATMega328 pin numbers increase counterclockwise from there. How to use the programmer you've built: Before connecting the Arduino to your computer's USB (& powering it), ( carefully, not bending the pins) insert the ATMega328 microprocessor into the solderless bread board. Pins 1 & 28 are on the end with the semicircular notch. If you hold the ATMega328 with the notch at the top, pin 1 (reset) is on it's left & often has a "dot" beside it. Insert the ATMega328 pins to straddle the groove in the middle of the breadboard. Place pin 1 in the row even with the wire jumper coming from Arduino digital pin 10. Start your Arduino IDE that you use to program Arduinos. Do the following carefully. 1) Now you'll program the Arduino to be a programmer. In the IDE Tools > Port menu, select the port assigned to the Arduino & in the Tools > Board menu, select the board as Arduino/Genuino Uno. In the Tools > Programmer menu, choose AVR ISP near the top. In the Files > Examples, choose ArduinoISP. In the Sketch menu, choose Upload. The sketch should compile then the Arduino's LEDS should flash while it says it's uploading. Hopefully, it will say "done uploading" & this Arduino / bread board is almost a programmer for ATMega microprocessors. 2) Now following all this VERY carefully, you'll program the ATMega microprocessor on the breadboard. Open the sketch you want on the ATMega328, like the Battery-Sipping DHT End Node when it's provided. In the IDE Tools > Port menu, make sure the Arduino is assigned a port. In the Tools > Board menu (very important), be sure to select "Arduino Pro ..." In the Tools > Processor menu, be sure to select "ATMega328 (3.3v, 8 MHZ)" because this matches how the DHT battery node will be built. In the Tools > Programmer menu, choose "Arduino as ISP." Again very important, in the Sketch Menu, choose "Upload Using Programmer." Careful, careful because if you choose just "Upload" from the Sketch Menu, you will program the Arduino NOT the ATMega328 on the bread board & you will have to start over with step 1 just above. The sketch should compile then the Arduino's LEDs & the bread board's yellow LED should flash while it says it's uploading. Hopefully, it will say "done uploading" & the ATMega328 microprocessor will contain the DHT End Node sketch. You can carefully remove the ATMega328 from the bread board. It's ready to insert carefully into the socket on the Bare Bones Arduino you build. To remove an ATMega328 from socket or breadboard, insert a small, slotted screw driver head alternately under each end of the ATMega328 & pry gently until it releases. Especially avoid touching ATMega328 pins if you've been generating static electricity sparks. The three (optional, colored) LEDs on the bread board are status lights. Green will pulse while the Arduino ISP waits for programming to start, yellow will light when it’s transferring code to the ATMega328, and red will light if there’s an error. So far as of now, the Battery node has had just a .02 TOTAL voltage drop over about 108 hours Future: The Battery-Sipping DHT End Node program sketch (after I recheck & tweak it a bit).
|
|
|
Post by papa on Dec 7, 2015 19:23:42 GMT
Some pictures of the Battery-Sipping Node (with 3.3 volt regulator, before direct power with 2 AA's):
PS, after 134 hours, the Node's battery pack has lost a TOTAL of only .03 volts. << Click on pictures for larger view As of 12/8/2015, after 149 hours, the Node's battery pack has lost a TOTAL of only .04 volts.
|
|
|
Post by papa on Dec 8, 2015 19:17:26 GMT
A Multi-Choice (including Battery-sipping) End Node Sketch, a la CompuTourist, Beta Testing Important Preview & PreparationAs noted above, I started with Gandalph's sketch (based on a Computourist sketch), tweaked & added to code to be selected (or not) within #ifdef (or #ifndef) #endif sections I reworked the version numbers so they might indicate their connection to Computourist's work. Gandalph's & my sketch are based on DHT End Node v2.1 which works with Gateway version 2.2. So I renamed Gandalph's last version as 2.1 e. My version is labeled computourist_node_v2.1 f_choices_battery.ino. (I'll consider updating later to work with a later Gateway version.) In the sketch I tried to label (with "Papa...") much of where I changed Gandalph's adaptation of Computourist's original sketch. Thus, maybe you can follow my tracks & if necessary, help correct mistakes I may have added. Again, this is meant to be a Multiple Choice End Node Sketch (including Battery-sipping) I tested these devices successfully to the degree indicated: DHT11 alone compiled, uploaded, function on bare bones Arduino DHT11 + SLEEPY (Battery) compiled, uploaded, function on bare bones Arduino DHT11 + SLEEPY + ACTOR compiled, uploaded, function on bare bones Arduino (not practical to include BUTTON since node won't necessarily be awake when node button is pushed) DHT11 + BUTTON + ACTOR compiled, uploaded, function on 3.3v Arduino compatible Needing other users to test further: PIR alone & with SLEEPY, compiled only DS18 alone & with SLEEPY, compiled only Caution: Be aware that using the wrong combination of devices may create interference OR use more current than provided In a sketch header line, Gandalph says, "use SLEEPY with DS18 OR PIR (not both due watchdog interference)" (I have not verified.) More choices could be added later, like a reed switch & a jumper that signals another special mode. Note: So far, I've only tested this sketch with DHT, BUTTON, ACTOR, & SLEEPY & it assumes a battery node built like above or an 3.3 volt Arduino compatible (perhaps with shield) like that described in Success... thread posts before & after Oct 15, 2015 at 10:32am. If you change where sensors are connected, you need to change the sketch accordingly. For PIR & DS18 sensors, you need (for the time being) to read & edit the code & attach the sensors accordingly This sketch needs several libraries downloaded & installed to your computer. ...
Close all open windows of the Arduino IDE (what you use to edit, compile, & upload Arduino sketch programs). Make sure you have the RFM69 & DHT libraries in the right places on your computer by getting what you need from my Success... thread post for Oct 7, 2015 at 10:15am. (The SPI library comes with the Arduino IDE install.) From what you did for RFM69 & DHT libraries, follow similar procedures to install these 4 libraries (each name has the link to get it): Now you may restart the Arduino IDE when you want. Obtaining & Customizing the Multi-Choice End Node Sketch
(Note: Below starting at the Dec 14, 2015 at 2:59pm Post, I start documenting a "g" version of the sketch with more capabilities.
Download my adapted sketch computourist_node_v2.1f_choices_battery.ino (28.89 KB) & save it where you can find it in the Arduino documents folders. With the Arduino IDE, open the sketch (perhaps go to the save location & double left click the file name.) Necessary customizing of the sketch ... About line 80, only the HT device is uncommented & selected (for DHT11 sensor. Do NOT change line 183 to #ifdef DHT or you'll get errors). At lines 81-99, you may CAUTIOUSLY (see above) select other devices by uncommenting or deleting // that starts a line. Line 104 makes this Node 02 which should work as is with the openhab-papa.zip OpenHAB config files (see more below. If you already have & want to keep another Node 2, change this sketch's NODEID & rename accordingly in the openhab-papa config files. About line 107, ENCRYPTKEY, replace "xxxxxxxxxxxxxxxx" with the same 16 characters you use with your Gateway & other nodes. About line 108, DEBUG mode is active & will display data & errors on the Arduino IDE Serial monitor set to same baud rate as line 118 Probably best to leave for now, but comment out the line (// #define DEBUG) for a battery node, where it will not work. I changed the code so DEBUG output will start with listing the device options chosen. In lines 110-113, choose & uncomment one of the frequencies, acc to what is allowed in your region / country. Does your radio transceiver model # start with RFM69 H (H for high power, better range)? Then leave line 114 uncommented & active. If not, comment it out (add // to the line's beginning) Added, Dec. 9: Line 138 says "TXinterval = 30" that is IF NOT in SLEEP mode (to save the battery), the node will send data every 30 seconds. In the comment, I note that Computourist (CT) used 20 & Gandalph used 900 or 15 minutes. If desired, you could change this setting, though 20 or 30 seconds works well. When the sketch defines SLEEPY mode (especially for battery nodes, Arduino & radio sleep for 8 Loops of 8 seconds each & then wakes briefly to send data) If you want to change the sleep time, change Loops = 8 in line 212. Lines 783-806 define what data the Multi-Choice node will aim to send: NOT uptime or Transmission Interval (unless uncommented), radio signal strength, & voltage (esp. good for battery node). Sends in line 788-805 are only active if they match the #ifdef above them. That might cover the customization. Now via USB, you should be ready to upload to a wall powered node (that includes TESTING code for a battery node). OR upload for a battery powered node using the Arduino as a Programmer described above on Dec 6, 2015 at 7:32pm (follow this carefully). In addition to this node, you need a Gateway node built & programmed (See Success... posts starting Oct 8, 2015 at 6:40pm). You also need OpenHAB server & supporting programs installed & running a computer. (For Windows install, see Success... posts starting Oct 16, 2015 at 8:52am. Some not-verified Raspberry Pi install at Success... post Oct 18, 2015 at 4:08pm) Also install & customize OpenHAB config files to work with your gateway & nodes as described in Success... post starting Oct 16, 2015 at 4:30pm. If your NODEID is NOT 2, be sure you change the node name accordingly in the openhab-papa.zip files.
|
|
|
Post by papa on Dec 8, 2015 22:07:01 GMT
OK, above, I've documented a Multi-Choice End Node (including battery power) a la Computourist.
Happy DIY Home Automating & let me know how the above works for you & what you believe are problems to fix. I'd especially appreciate your testing / troubleshooting the PIR & DS18 aspects. As of now, the DHT Battery End Node based on the above build & sketch has run for 152.5 hours & its battery pack has lost a TOTAL of only .04 volts.
|
|
|
Post by papa on Dec 9, 2015 0:33:37 GMT
A Battery-Sipping Node Directly Connected to Batteries (Not through a voltage regulator or diode) ??
On Dec 6, 2:31pm, I wrote, As I've been reporting, 4 batteries running through a 3.3 volt regulator is pretty efficient, with the node using less than .01 volts per 24 hours. However one always wants MORE if possible ;-) AND ... I just now connected two AA's (2.98 volts total on my multimeter) directly to the bare bones Arduino (bypassing the MCP1702 voltage regulator) & so far it seems to read & report temp & humidity. OpenHAB User interface reports 2.95-2.98 volts on the battery pack. I'll let the node run & see what happens. If this works for a while, this could suggest some battery power options. One could still build the 3.3 volt voltage regulator section of the bare bones node & with a 4 position battery box, connect 4 AA's or 3 AA's & a jumper across one compartment. This gives one power option, fairly efficient. (Thanks, Computourist for the following suggestions.) The other option might be to ALSO assemble so one could connect a 4 position battery box directly to the positive & negative rails of the bare bones node & then use 2 strong AA's + 2 jumpers for the other battery compartments or 3 weak AA's + 1 jumper. (One would need to test the total voltage provided by the direct battery pack & keep it under the 3.6 volts safe for the RFM69 radio.) This latter way we could avoid wasting battery power on voltage regulator or diode. These direct power options might depend on what sensors / devices are running on the node. Maybe a third battery power option using less space for batteries: a 3.7 volt lithium ion rechargeable battery connected to the Arduino power rail via a removable jumper which could first be a suitable diode to reduce voltage to a safe level for the RFM69 & then when the battery depletes to a safe voltage, replace the diode with a wire jumper. Or maybe one could somehow charge the Lion battery to a little under its full 3.7v capacity.
|
|
mmk
New Member
Posts: 6
|
Post by mmk on Dec 11, 2015 6:11:13 GMT
Hello papa! I think you are doing an excellent battery-conservation project! Is people like you that keep searching for a better ways of improving system and efficiency that makes the world a better place. I am keeping a close eye on your project and I am all out rooting for you! Of course, compu-tourist guru is also helping out. Cheers to you too. I wish I can help but I don't know much.
|
|
|
Post by papa on Dec 11, 2015 14:20:14 GMT
Thanks, mmk, it helps to get feedback after trying things & then documenting them.
I agree that Computourist has provided & expanded an excellent base to build on. I also appreciate Eric Tsai who did the original Uber Home Automation Instructable & started this forum plus others like Gandalph who provided the sketch which I adapted.
We all start somewhere, which you can see if you read my early posts on this forum. I believe I've learned a lot about electronics, but find I have so much I still could learn. That makes it challenging, interesting, & FUN.
Keep researching, trying things out, asking questions. Keep trying to tweak what's offered here & elsewhere & next thing you know, you have something to offer confirming or extending what others have learned.
|
|
|
Post by papa on Dec 13, 2015 5:16:16 GMT
An Update on the DHT Battery End NodeThis is the bare bones Arduino with a DHT11 sensor. Four days ago, I connected 2 AA's (2.98 volts total) directly the bare bones Arduino power rails. (No USB, No LEDs, no voltage regulator. Sleeping 64 seconds then waking briefly to send data.)
Four days later, the batteries read 2.94 volts, a loss of only .01 volts per 24 hours
The node is still reporting RSSI, Voltage, Temp, & Humidity to the OpenHAB user interface.
|
|
|
Post by papa on Dec 13, 2015 5:24:03 GMT
An Update on the Multi-Choice Node
For a long time today, I fussed with the Multi-Choice Node sketch & hacking what must have been a defective PIR sensor. After I tried another sensor ( no hacking, though the PIR worked better with PIR power pin connected to Buono Uno Arduino compatible's 5 volts), the sketch worked just fine with PIR + DHT. I have not tried it with the SLEEP mode for the battery node yet. When I test options a bit more, I'll document what's needed to build a PIR function on the node.
|
|
|
Post by papa on Dec 14, 2015 20:59:53 GMT
Update: Previously with no sleeping, the battery pack (4 AA's going through MCP1702 voltage regulator) on the same bare board node dropped about .4 volts per 24 hours. With radio & microprocessor mostly sleeping then waking every 64 seconds to send data, the battery pack (now only 2 AA's & NO voltage regulator) has dropped less than .01 volts per 24 hours. At 2.93-2.94 volts, the node continues to post reliably to OpenHAB & the user interface. Now I begin documenting adding a PIR sensor to the hardware AND a new version of the sketch that I hope is easier to configure & tests / tweaks using a PIR sensor
Parts List (updated on Dec. 15 & Dec. 17 & Dec. 26, 2015): (Assuming tools like soldering iron, solder, something to hold the board while soldering, needle nose pliers, nippers) ============================================= Parts for the circuit to program the Bare Bones Arduino:============================================= A regular 5 volt Arduino Uno & a half solder-less breadboard (30 x 14 holes, .1 inch apart) a 16 MHz crystal & two 22 pico Farad capacitors one 100 nF (0.1 μF) capacitor One each of red, green, & yellow LED (& a 100 ohm 1 kilo ohm resistor for each) ^^ Note: computourist used 1 kilo ohm resistor with LEDs. I prefer 100ohm which lets the LED be somewhat brighter without burning out. For dimmer LED & to reserve more current to other node parts, use higher than 100 ohms. May 19, 2016, computourist said: With 100 ohms, current will be around 15 mAmps, well within specs. several colorful jumper cables (male connectors on both ends) =============================================================== Parts list for a Bare Bones Arduino Node, especially for batteries:=============================================================== Battery box with wires (3 or 4 AA or AAA) + batteries AND MCP1702 3.3v voltage regulator AND two ceramic 1 micro farad capacitors OR Battery box with wires (2 AA) + batteries AND NO voltage regulator (nor its capacitors) (To be flexible, you could use 4 battery box with either option & for 2 AA's, use jumpers across 2 battery compartments.) Or (added on 12/26/2015)one 3.7 volt rechargeable Lithium Ion Battery charged to about 3.7 volts, a battery box for it AND one 1N34A Germanium Diode Connect battery positive to the diode's UNbanded end. Connect the diode's banded end to the Node's positive rail. Connect battery negative to the Node's negative/GND rail You want a multimeter to register near 3.6 volts across the Node's positive & negative rails. This voltage should be safe for the RFM69 & power the Node for a good length of time. ============================================ (Note: All solder pins or holes need to be spaced .1 inch apart) TWO terminals block, each with 2 positions, .1 inch pin spacing ========================================== A Solder-able Breadboard, preferably double sided like this from SparkFun (I believe double-sided ones solder better, especially for those of us whose skill is still developing.) OR (Single Sided) BusBoard Solderable PC BreadBoard (SB404) at Jameco========================================== RFM69Hx radio transceiver, frequency determined by what's allowed in your region / country (915 MHz for the U.S. & I believe 433MHz for Europe & 868MHz for UK) ATMEGA328P-PU microprocessor (integrated circuit or IC) 28-pin IC socket <one source linked in the name 22 gauge insulated wire (multi-colors ??) 8 MHz Crystal AND two ceramic 22 pico farad capacitors to use with it About 30 Break Away Female Headers (.1" spacing), if like me, you want to plug in components like rfm69 transceiver & DHT11 sensor Here's one source. =========================================================== Choose from the Following Depending on What Type of Nodes You Want to Build =========================================================== Push button switch (If node is working when you press, node LED toggles on/off & OpenHAB user interface can toggle a virtual switch.) Shows successful operation (kind of neat), but may be better for a wall-powered node, rather than battery. LED & 100 ohm or 220 ohm or 1 kilo ohm resistor (Shows successful operation by reacting to OpenHAB user interface or push button) ^^ Note: computourist used 1 kilo ohm resistor with LEDs. I prefer 100ohm which lets the LED be somewhat brighter without burning out. For dimmer LED & to reserve more current to other node parts, use higher than 100 ohms. May 19, 2016, computourist said: With 100 ohms, current will be around 15 mAmps, well within specs. DHT11 temperature / humidity sensor AND a 4.7 kilo ohm resistor (reads temp & humidity of a room's air) Added 12/17/2015: PIR sensor AND 10 kilo ohm resistor (senses "motion") To connect PIR to Arduino shield or sockets on a bare bones 3.3v Arduino: 3 Dupont cables (One male pin & one female pin. if possible, red, black, & another like yellow), 10cm long. DS18 (DS18S20, DS18B20, DS1822) temperature sensor on a protected cable (if protected, can read temp of liquids as well as air) AND 4.7 kilo ohm resistor (I have not tested this, but the code is included in the sketch & it worked for Gandalph.) Reed Switch & complementary magnet (preferably encased in plastic with mounting holes) (good for sensing if doors, windows, & gates are open & closed) "NO" Reed Switch means "Normally Open" until magnet is near (cheaper & easier to find) OR "NC" Reed Switch means "Normally Closed" until magnet is near (may last longer in some situations) How to choose which type? Either can work if wired correctly. However I recommend ... minimize closing the switch & running current through it. So ... If the switch is away from the magnet more than it is near, choose "NO" . If the switch is near to the magnet more than it is away, choose "NC" (if you can). To be continued ...
|
|
|
Post by papa on Dec 15, 2015 19:05:34 GMT
Update: Previously with no sleeping, the battery pack (4 AA's going through MCP1702 voltage regulator) on the same bare board node dropped about .4 volts per 24 hours. After nearly 7 days, with radio & microprocessor mostly sleeping then waking every 64 seconds to send data, the battery pack (now only 2 AA's & NO voltage regulator) has dropped less than .01 volts per 24 hours. At 2.93 volts, the node continues to post reliably to OpenHAB & the user interface. Added 12/16/2015: A Wall-Powered Multi-Choice End Node
You may notice this thread morphed from a Battery-Sipping Node & to a Multi-Choice Node with a battery-sipping option. Can you see the advantage of having ONE sketch with multiple choice options, taking advantage of code shared between more than one previous node sketch, shortening what code is used on a node to mostly only what is needed? Updates to core code might only be made to ONE end node sketch. The Battery-sipping node is built on a DIY Arduino & programming it requires taking out the ATMega328 microprocessor, putting it in a programmer breadboard, & returning it to the DIY Arduino. To minimize programming an ATMega328, I use a (wall-powered) Buono Uno 3.3 v mode Arduino compatible with customized shield on top. On the customized shield, I can install or plug in things like RFM69 transceiver, DHT11 sensor, PIR sensor, Reed switch, push button, LED, etc. After I plug in what functions I'm testing, I customize the Multi-Choice Node sketch (versions above & below) including the SLEEPY batter-sipping option & use that to program the Buono Uno via USB (often repeatedly). Only when I'm fairly confident in the code, do I program the ATMega328 for the DIY Arduino end node. You can use & adapt my shield hints in my Success... posts starting Oct 10, 2015 at 8:01am & the following schematics to build such a shield for testing or actual use. << Schematic for a Multi-Choice End Node. All but the Buono Uno are built on a shield. ^^ Schematic correction: for the LED use a 1 kilo ohm resistor as safer. << Schematic for a Multi-Choice End Node. (Click on pic to enlarge) ^^ Schematic correction: for the optional LED use a 1 kilo ohm resistor as safer.Same as above EXCEPT including normally CLOSED reed switch instead of normally OPEN Caution: There are likely limits (current & interference) to how many of the node choices you can use on one unit. The sketch & posts later below will list the results of what I've tested so far.
|
|
|
Post by papa on Dec 16, 2015 19:31:08 GMT
Building a Multi-Choice Computourist End Node (Hardware) that may be Battery-Sipping 12/16/2015, Revised from 12/6/2015
See the parts list I posted above for a bare bones battery sipping end node on Dec 14, 2015 at 2:59pm. For general hints about tools & assembly, I recommend you skim & glean what you need from my Success... posts starting Oct 8, 2015 at 6:40pm. You'll still need the Gateway whose build & code I described there. You'll still need OpenHAB server & its config files which I described (& provided samples) in that thread. For this node, you will need to solder wires to the RFM69 radio transceiver (as described in the Success... posts). This hardware will NOT start with a manufactured Arduino [or compatible] or add-on shield, but rather will build the main Arduino guts from scratch on a circuit board. Note: What follows builds a bare bones Arduino that uses EITHER a voltage regulator to achieve 3.3 volt operation from 3 or 4 AA batteries OR 2 directly-connected AA's to achieve about 3 volt operation. It is a typical bare bones Arduino, a bit like a battery power node in the original Uber Home Automation Instructable plus wiring for the DHT11 temp / humidity sensor. Depending on need / desire, you could wire either battery supply OR both if you put batteries in ONLY ONE battery option. I solder breakaway female headers (see Dec 6 parts list) where I want to plug in the wires of the DHT11 sensor, the RFM69 radio transceiver, & the optional LED. See the Success... post Oct 10, 2015 at 8:01am for hints on using the breakaways. I solder the 28 pin IC socket so as to receive the ATMega328 microprocessor. See pictures of the previous voltage regulator version above at the Dec 7, 2015 at 1:23pm post. See below for picture of the direct battery connection version. See soldering hints in the Success... post Sep 28, 2015 at 6:52pm. << Schematic for a Multi-Choice Computourist End Node (NO voltage regulator) ^^ For the optional LED, it's OK to use a 100 ohm resistor. (Click on the pics for a larger view) << Schematic for a Multi-Choice Computourist End Node (NO voltage regulator) ^^ For the optional LED, it's OK to use a 100 ohm resistor.Same as above EXCEPT for normally CLOSED reed switch instead of normally OPEN reed switch Continues in the next post with a Fritz of the multi-choice end node circuit & a pic of the Fritz plus how to program the battery node.
|
|
|
Post by papa on Dec 16, 2015 20:56:31 GMT
Continues from post just above: Building a Multi-Choice Computourist End Node (Hardware)12/16/2015, Revised from 12/6/2015
Caution: 12/17/2015, PIR power & gnd connections changed in Fritz below.
Computourist Multi-Choice Node-DHT-LED-batt....fzz (46.01 KB) << Fritz of Battery-Sipping Node (Note: You need the open source Fritzing program.) Parts' positions & shapes are skewed for visibility & Fritzing's limits. Use your judgement when assembling.
<< A picture of the Fritzing layout of the node (much more useful in the Fritzing program) (Click on the pic for a larger view) Without a USB port on the Battery Node, how do we program it? See the Dec 6, 2015 at 7:32pm post above. << A picture of the bare bones node powered by 2 AA's directly connected (voltage regulator installed, but NOT used) Over more than 7 days, this DHT end node has lost less than .01 volts per 24 hours & is still sending to OpenHAB at 2.93 volts. Again, caution: There are likely limits (current & interference) to how many of the node choices you can use on one unit. The sketch & posts later below will list the results of what I've tested so far.
|
|
|
Post by papa on Dec 18, 2015 1:56:29 GMT
Hardware Notes on Using a PIR Sensor (To Sense “Motion” or Presence of Heat-Generating Objects)
In his adapted Computourist sketch, Gandalph includes the following in header statements: Papa: The lowpowerlab.com hack has changed to another version of the mysensors hack (removing the voltage regulator & diode fed by PIR’s power pin). Caution: In a later post, I will warn you NOT to hack the PIR unless certain conditions apply. AND there I provide more tips about hacking the PIR if you must. When he posted computourist node v2.23.ino Jun 12, 2015 2:35:05 GMT -6 on this forum, gandalph said: In the sketch, for PIR related code, Gandalph had From all the above & from internet posts about false PIR triggers (signaling motion is happening when an area is apparently still), one starts to see a pattern. As I worked with Gandalph’s version, as is & tweaking, I saw it even more on the Arduino IDE’s Serial Monitor. Turning on the sketch’s DEBUG mode & opening the Serial Monitor to watch PIR fails & successes can be a source of frustration & a source to aid successful troubleshooting. In DEBUG mode, every so often the Serial Monitor shows “curPIRState: “ plus a zero or one. As much as possible we want a zero when NO motion or no presence should be detected & a one when they SHOULD be detected (without compromising too much the effectiveness & responsiveness of the node). I have a cheap, untouched PIR & a PIR hacked like Gandalph referenced above. Doing a simple test on a bread board with battery, resistor, PIR, & LED, things seem to work fine: PIR quickly signaling movement detected & quickly settling down to NO movement detected. However, at least with my two versions of PIRs & (I believe) using Gandalph’s PIR code pretty much as original on a node in SLEEPY mode, I had problems, especially false triggers of motion detection that prematurely awakened the sleeping node. Too many times, I saw “ curPIRState: 1” It’s possible the original code worked fine for Gandalph or good enough for his purposes. I needed to tweak it for my sensors & you many need to for yours. (More on that in a later post.) I have now installed a hacked PIR on a bare bones 3.x volt battery powered node also with a DHT11 sensor. Radio & ATMega328 processor sleep 64 seconds before waking to send data & returning to sleep UNLESS the PIR detects motion & wakes the node early via an interrupt. Following research I saw & my experience, PIR power & GND connect to the bare bones board’s power (3.x) & GND rails near where battery positive & negative connect. PIR data / out connects to Arduino D3. A (pull down) 10 kilo ohm resistor connects Arduino D3 / PIR data / out to the bare bones board’s GND rail. (For how it's wired, see the schematic & Fritz above.) After I programmed the bare bone’s board’s ATMega328 with the tweaked sketch (see upcoming post), it seems to avoid false signals of motion & is reasonably responsive to detect true motion / presence in the PIR’s field of vision. (I did not work much with the two adjustment devices on the PIR. I did select the “repeatable trigger” setting on my PIR by connecting jumper pins 2 & 3, counting from one edge of the PIR). The powered node resumed sending data to OpenHAB user interface which reports the node has a total of only 2.92 volts in the 2-AA battery pack.
|
|
|
Post by papa on Dec 18, 2015 2:14:42 GMT
Multi-Choice Node sketch’s updated header lines related to PIR hardware:
// PIR sensors are sensitive to voltage supply & voltage changes after radio activity. Acc. to Papa's experience this works best: // A 3.3v mode Buono Uno compatible can use a UNhacked PIR if PIR power pin goes to Buono's 5 volt socket, // PIR GND to Buono Uno GND socket close to VIN, & PIR data / out goes to Arduino D3 & 10 kilo ohm resistor goes between D3/PIR data & a Buono GND. // // For a PIR on a 3.3v pro mini arduino, a Buono Uno compatible (3.3v mode), or (probably) a 3.x volt bare bones battery Arduino, // use a PIR hack: forum.mysensors.org/topic/1088/battery-powered-pir OR lowpowerlab.com/motionmote/#pirsensor // avoiding a need for boost regulators etc. (Don't short the PIR circuit when rewiring. // After de-soldering & soldering hack, examine with magnifier & use sharp knife to re-separate places wrongly connected) // // A Hacked PIR sensor connects its data / out pin & 10k ohm resistor same as above. PIR power pin goes to 3.3v. // Buono or battery-powered node: connect PIR GND same as above. // Arduino pro: connect PIR GND to arduino GND pin close to RAW // Battery-powered 3.x volt bare bones Arduino: connect PIR GND to a bare bones GND rail nearest where battery positive connects. // // This adapted sketch tweaks Gandalph's delays to avoid false motion triggers on Papa’s PIRs after radio activity. // A hacked PIR falsely triggers more easily so the variable PIRdelay increases if PIRHACK is defined. // Increased PIRdelay stops false triggers, but somewhat decreases responsiveness to motion
|
|
|
Post by papa on Dec 18, 2015 2:17:38 GMT
Options in the Multi-Choice Node Sketch that I have tested
// Papa tested the listed options below with success or fail indicated: // (incl with sending RSSI & Voltage) // DHT11 alone: compiled, uploaded, function on bare bones Arduino // DHT11 + SLEEPY (Battery): compiled, uploaded, function on 3.3 v bare bones Arduino // DHT11 + BUTTON + ACTOR: compiled, uploaded, function on 3.3v Arduino compatible
// No hacks, PIR power from 5v, 10K ohm pull down resistor on data pin: // Also hacked PIR, PIR power from 3v, 10K ohm pull down resistor on data pin: // PIR alone: compiled, uploaded, function on 3.3v Arduino compatible // PIR + DHT11: compiled, uploaded, function on 3.3v Arduino compatible // PIR + DHT11 + SLEEPY (Battery): compiled, uploaded, function on 3.3v Arduino compatible // !! PIR + DHT11 + SLEEPY (Battery): compiled, uploaded, function on bare bones Arduino // // Needing other users to test / tweak further: // DS18 alone & with SLEEPY: compiled only // MEM (sleeping added flash memory): would not compile even with some tweaks
|
|
|
Post by papa on Dec 18, 2015 5:58:21 GMT
Update: 7+ hours after I installed the PIR on the bare bone Arduino board, it is still sending data to OpenHAB user interface (via the gateway), including only true signals of motion detected, BUT voltage dropped .04 volts in that time, I suppose from the current draws of PIR added to DHT11. Also delays added to stabilize the circuit for reliable PIR reads would increase awake time (vs sleep) & using more power. This battery use may still be acceptable, but may also warrant seeking further battery-sipping measures.
Ohhhhhhhh! Now I maybe see why Gandalph set his PIR node sketch to be sleeping 900 seconds (or 15 minutes) unless motion detection woke it up. I set the possible sleep to 30 seconds AND I lengthened delays during awake time. Those could certainly add up to more power drain. That much should be easy to address & see the effect.
|
|
|
Post by camblonie on Dec 18, 2015 21:28:44 GMT
I'd be interested in a PIR node but for the sake of energy saving drop the temp reading. You would only need to transmit after motion detect and maybe an hourly or daily check in for battery voltage reporting. A node lasting a couple weeks isn't worth the trouble in my opinion. Keep it up papa!
|
|
|
Post by papa on Dec 18, 2015 22:28:08 GMT
Thanks, camblonie, for the encouragement & suggestions. I was thinking somewhat along the lines you mention. Like with other projects before, I wanted to do something of a field test before posting the adapted sketch. Given the increased battery drain, I want to try a thing or two with the PIR aspect of the node, but I think I'm close to posting the sketch. I like to see followup reports on how a build functions over time so I try to provide those updates on this project.
Computourist & some of my research suggested ways to power the DHT11 not constantly, but as desired. I may try that some time in the future, but not necessarily soon.
Your "wish list" is interesting because I've been trying to add to the computourist & Gandalph documentation (in the sketch & on this forum) & sketch structuring (like the "selection among choices" I augmented beyond Gandalph's,) that could allow most users to customize what is excluded & included. Also most configuration possibilities are grouped together.
|
|
|
Post by papa on Dec 21, 2015 19:11:54 GMT
Update on bare bones Arduino node with DHT11 & PIR sensors, directly powered by 2 alkaline AA's. This node's ATMega328 processor & RFM69 radio sleep, but neither DHT nor PIR sleep:
Before adding the PIR sensor, the batteries lost about .008 v per 24 hours.
Through Dec. 17 , the above-configured node was programmed to sleep 30+ seconds (unless awakened by motion detection), but as reported above, it started "slurping" battery power & I disconnected it. (Gandalph's version sleeps 15 minutes (unless motion awakened it).
On Dec. 18, I customized the multi-choice node sketch (with DHT & PIR) to sleep the radio & processor 5+ MINUTES (unless motion awakens it), potentially 10 times as long as before. DHT11 & PIR sensors were still powered even as radio & processor sleep. For about 12 hours, voltage did not change much (reading 2.89v), motion was reliably detected & false triggers avoided, & data (temp, humidity, rssi, voltage, motion) was sent to OpenHAB user interface.
Then I was away from home for a couple days, occasionally checking the user interface on the OpenHAB app. It seemed the node was continuing OK like above. I believe I saw 2.88v on the user interface.
When I returned home, I discovered battery pack voltage had seriously dropped to 2.57v & the node was no longer connecting to the RFM69 OpenHAB network. Perhaps somewhere around 2.88v, the batteries no longer provide enough power for all the node components.
For now, I removed the DHT sensor & installed 2 more alkaline AA's totaling 2.98+v. Sending data to the OpenHAB user interface has resumed. For a while anyway, I want to test the battery node with just a PIR sensor, sleeping the radio & processor about 5 minutes & see how it uses power.
On Dec 6, 2015 at 2:31pm, I said, Learned so far ?? : At least down to 2.89 volts for my node, 2 AA's can power ATMega328, RFM69, DHT11, & hacked PIR. Sleeping the radio & processor (as expected) does decrease battery's power drop per 24 hours from .4 volt (on FOUR AA's) to .008 volts. Two alkaline AA's on a battery node may last until descending to 2.89 volts. At that rate, 2 alkaline AA's starting about 2.99-3.00 volts could last about 12 days.
The above result is a definite improvement over using .4 v per day from 4 AA's, but 12 days is still too short. Presumably for a longer lasting battery node, longer sleep times, & using a PIR alone or with an intermittently-powered DHT should extend battery life. The challenge is typical battery voltages on one side (1.5 v, 3.7 v) & the range of safe voltages for the node's components, especially the RFM698 radio.
I will continue to test the results from different combinations of batteries, sensors, & sleep times. However, I believe the Multi-Choice Node sketch is stable enough & customizable enough that other users can experiment as well.
Next, below I post & document & latest version of the Multi-Choice Node sketch.
|
|
|
Post by papa on Dec 22, 2015 15:04:05 GMT
The Updated Multi-Choice End Node Sketch (version …2.1g) computourist_node_v2.1g_choices_battery.ino (34.59 KB) << Here is the updated sketch itself. Documentation follows below. ^^ Sketch tweaked on 12/26/2015 (corrected so that compiling withOUT PIR option does not throw an error about line 646) Updating what I said above in the Dec 8, 2015 at 1:17pm Post … The following refers to line numbers in this 2.1g version of the Multi-Choice Node Sketch. In the Arduino IDE, when the cursor is on a line, the IDE tells the line number in the sketch window’s lower left corner. I’ll do my best to give the right location, but editing can change line numbers & is why I say “about line xxx.” In the IDE’s Edit menu is a “go to line” option (or [CTRL] + L) that will let you jump to a given line number. In many ways, Gandalph’s adaptation was already “multi-choice.” I increased the code lines that those choices included or excluded & tried to clean up some issues. My intent with most of the below is compactness of code (on the ATMega328 processor), convenience & educational. Compactness: Selecting what code a node only or mostly needs helps to minimize the code in the processor & allow adding more choices. Convenience: I wanted to attempt one sketch that could offer choices to program nodes with different combinations of functions. On the Arduino IDE Serial Monitor, when the node boots up, DEBUG not only shows the sketch version, but also the choices (DHT, SLEEPY, etc). I grouped together as much as possible of what needed customizing. Educational: I edited & increased comments to help document sketch features & to show where more code sections begin & end. As said below, early #define statements offer choices to tailor a node’s functions. Also later are sections bracketed by #ifdef (or #ifndef) and #endif. Those sections set variables based on whether an earlier #define statement is true or not. By starting with a define statement & then finding later sections testing for that define, I believe a reader could learn much about what is important to that function’s working & how they might adapt or imitate that function. For example, about line 123 says #define HT // for DHT11 temp / humidity sensor. About line 238 says #ifdef HT // DHT11 sensor & then until about line 246 are items set if HT was defined (& the items are not commented (//)) so we see (about line 241), the DHT11 data/out line should connect to Arduino pin 4, etc. The following customization will tailor things to your components AND to work with openhab-papa++PIR.zip, sample OpenHAB configuration files I will supply later. I explained how to use the config files in my Success… post Oct 16, 2015 at 4:30pm. Here’s where to edit & customize the Multi-Choice End Node sketch for your setup: About lines 112-142, fairly early in the sketch include a series of #define statements, most commented (start with //). The unedited sketch activates only HT (for DHT11 sensor) & CELS (for Celsius temperature scale.) Uncomment a line to select that option. Leave / make lines commented to negate an option. SLEEPY is the option for a battery-sipping node. ( Caution: choosing too many options may cause interference & may tax the node’s available power. Discover by experimenting.) About lines 145-163 have other items that may need customizing. About line 145, if you already have a node 2, replace NODEID 2 with NODEID xx (xx is new node number). About line 146, replace the “xxxxxxxxxxxxxxxx” with the same 16 character key you created & put into your Gateway Node sketch. About line 147, unless you are programming a battery node, make sure the DEBUG line, is uncommented (NO “//” at the start) at least until you feel confident about your edit of the sketch. To select the frequency of the RFM69 transceivers you have, about lines 149-151, be sure that the same line is uncommented & activated as you did for the Gateway Node & that the other lines are commented. If & when you build more end nodes, be sure you give each node a unique NODEID about line 145. If your radio transceiver’s part number include an “H” Uncomment about line 152. If not, comment it. At line 153 (from here on, line references assume “about”), Txinterval sets how many seconds between the node’s “pushing” or sending data to the gateway (unless in SLEEPY mode). 30 works, but can be changed. At line 154, PIRloops sets how many loops of 8 seconds the node will sleep if battery sipping node has a PIR (now 38 loops = 304 seconds, 5+minutes). At line 155, Loops sets how many 8 second loops the node will sleep between data sends (now 8 loops = 64 seconds) if it’s not a battery-sipping node with a PIR. Lines 919-922 have other items that may need customizing. Now lines 919 & 920 are commented so the node will NOT send uptime or transmission interval. Now lines 921 & 922 are NOT commented so the node will send signal strength & voltage level. You can change these. Next: Installing code libraries, as needed.
|
|
|
Post by papa on Dec 22, 2015 15:21:53 GMT
Installing Code Libraries, As Needed, for the Multi-Choice Node Sketch
Before you compile & upload the sketch, make sure several libraries are where the Arduino IDE can find them. Close all open windows of the Arduino IDE (what you use to edit, compile, & upload Arduino sketch programs). Updating my Success... thread post for Oct 7, 2015 at 10:15am ... From what you did for the RFM69 & DHT libraries, follow similar procedures to install these 4 libraries (each name has the link to get it): OneWire DallasTemperature LowPower SPIFlash Now you may restart the Arduino IDE when you want.
|
|
|
Post by papa on Dec 22, 2015 15:28:35 GMT
Notes on Tweaking the Multi-Choice Node Sketch for YOUR PIR Sensors:
Above, I described the problems I had with false triggers for motion. I had the sketch in DEBUG mode & watched the Serial Monitor’s (SM) output of curPIRState for where the PIR should see if things were still or in motion. As Gandalph warned, at first, on SM I saw false triggers after every other batch of radio sending messages or at least every other send. From results I saw, I kept tweaking Gandalph’s version. I ended up with a larger PIRdelay variable (about line 159, 3000 or 3 seconds instead of 2000 or 2 seconds) AND using PIRdelay twice (lines about 647 & 770). Since a hacked PIR (removed voltage regulator) triggers falsely more easily, I added #define PIRHACK, which when uncommented, increases PIRdelay more to 3600 (about line 161). With MY sensors, the above got me lack of false triggers & still fairly good responsiveness & true triggers from the node. YOUR sensors may need a PIRdelay of less or more. If so, perhaps now, helped by the sketch’s DEBUG mode & the Serial Monitor, you can experiment with PIRdelay in line 159 & see what you get that works best. My conclusion: If like me, you mostly use Buono Unos (mostly 3.3v mode, but also having a 5 volt socket), do NOT hack the PIR. Instead connect (unhacked) PIR’s power pin to the Buono 5 volt socket. Only hack PIR if you absolutely need it on a (mostly) 3.3 volt node that does not also have a 5 volt supply (battery-powered & maybe an Arduino Pro??). If you must hack, here are more tips on desoldering the small PIR voltage regulator & diode: For the diode, alternate a small hot solder tip between the 2 connectors WHILE with a small screwdriver, you gently push diode’s center toward the board’s edge. For the regulator, hold a small, hot, narrow solder tip across all 3 connectors (avoid burning nearby capacitor cylinder) WHILE with a small screwdriver, you gently push the regulator’s opposite side toward the board’s edge.
|
|
|
Post by papa on Dec 22, 2015 15:32:01 GMT
To Post the Multi-Choice Node’s PIR Data to the OpenHAB User Interface:
Caution: When editing OpenHAB configuration files on a Windows computer (especially if the files will be used on a Raspberry Pi or other Linux computer), only use OpenHAB Designer or Notepad++. Windows editors like Notepad & Wordpad treat line endings differently & your resulting configuration files may cause baffling errors. The following configurations assume a mosquitto broker service "mosquitto" & a Node 2 & C:\openhab\ path. Match them to your mosquitto broker & node ID & path. openhab-papaPIR.zip (228.44 KB) << Here is a file package with starter configurations for a Node 2 Multi-Choice End Node (including PIR). In my Success... post, Oct 16, 2015 at 4:30pm, I documented installing & configuring OpenHAB server on a Windows computer. You can follow the instructions there, EXCEPT, use openhab-papaPIR.zip instead of openhab-papa.zip & copy 16 images instead of 14. OR ... Using the comparable path on your computer, in the file C:\openhab\configurations\items\ My.items, add the line: String Node02_PIR "Node02 PIR [%s]" <PIR> {mqtt="<[mosquitto:home/rfm_gw/nb/node02/dev41:state:STILL:OFF],<[mosquitto:home/rfm_gw/nb/node02/dev41:state:MOTION:ON]"} Using the comparable path on your computer, in the file C:\openhab\configurations\items\ My.sitemaps, add the line: Text item=Node02_PIR Using the comparable path on your computer, in the folder C:\openhab\webapps\ images, add the images, PIR-motion.png & PIR-still.png
|
|