|
Post by papa on May 25, 2016 22:05:21 GMT
This is my take on a battery-powered Mailbox Node that changes state when the mailbox door is opened & closed & posts that time to the User Interface on a browser. This node can be used in other situations to sense when something opens & closes (like a door or window) & a battery-powered node is needed / desired. This post below will add a few details for this to work.
Parts list for a Battery-Powered Bare Bones DIY Mailbox, etc Node
(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) + alkaline or rechargeable batteries Optional: one 3.7 volt Lithium-ion battery with holder, charger, & germanium diode 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 developing skills.) 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 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. (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 or 220 ohm or 1 kilo ohm resistor for each) ^^ Note: computourist uses 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) To be continued...
|
|
|
Post by papa on May 25, 2016 23:21:12 GMT
Building a Battery-Powered Node for Mailbox, etc. See the parts list in the first post of this thread
Updated Aug. 20, 2018: For general hints about tools & assembly, I recommend you skim & glean what you need from my Building an RFM69 Home Automation Network. You'll still need the Gateway whose build & code I linked there. You'll still need OpenHAB server & its config files which I linked (& provided samples) in that thread. For this node, you will need to solder wires to the RFM69 radio transceiver (as described in the Building-related 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. I re-purposed what I built in the Dec 16, 2015 at 2:56pm post in this thread, except I removed the resistor tying Arduino d3 to Arduino GND. This node is a typical bare bones Arduino, a bit like a battery powered node in the original Uber Home Automation Instructable plus wiring for the switch (tilt, reed, or micro.) Optional: Instead of or in addition to the MCP1702 regulator & its capacitors, you might use a 3.7 volt Lithium-ion battery that is charged to or reduced (via a germanium diode) to less than 3.6 volts (for the safety of the RFM69 radio. This would be directly connected to the node’s positive & negative rails. (My Lithium-ion batteries must be junk. : - ( I did not get this to work.) I soldered breakaway female headers (see parts list in the first post of this thread) where I wanted to plug in the wires of the switch & the RFM69 radio transceiver. 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 & in this thread. See soldering hints at the Sep 28, 2015 post. << Tweaked on 2/14/2017 ^^ Schematic for a Battery-Powered Mailbox Node (with voltage regulator) (click pic for larger view) Caution: The following Fritz file & the Fritz pic were corrected & replaced on 5/26/2016. (One leg of the switch should be connected to Arduino GND instead of 3.3 volts.) The schematic just above was & is correct for the sketch. My apology for the error. Mail Node-battery-terminal-no reset-twk-cho....fzz (28.92 KB) << Fritz of Battery-Powered Mailbox Node (Note: You need the open source Fritzing program.) Parts' positions & shapes are skewed for visibility & Fritzing's limits. Use your judgment when assembling. Caution: Use only one of the 3 options for battery power in the Fritz. ^^ A picture of the Fritzing layout of the node (much more useful in the Fritzing program) (Click on the pic for a larger view) Caution: As in the schematic, the crystal's capacitors are to be 22pF, not 10pF the closest value I could find in Fritzing.
Next: Some pictures ... Then Battery-Powered Mailbox Node program sketch.
|
|
|
Post by papa on May 25, 2016 23:40:08 GMT
Using the Tilt Switch Sensor
^^ This drawing depicts my tilt switch from the top. Connecting one left pin to Arduino d3 & the other left pin to GND works well for me. Connected that way, the switch is closed when the "Up" face is up & level. The switch is open when the up face tilts down 45 or more degrees. You can test how your tilt switch works by connecting your multimeter's probes to different combinations of two pins. Speaking of the tilt switch, my node seemed to start off best when power connected as the "Up" face was up & level. When the node started that way, it seemed more reliable in reporting node voltage to OpenHAB. A picture of the Battery-Powered Mailbox Node (with 3.3 volt regulator, not using direct battery power)
^^ Click on pic for larger view.
|
|
|
Post by papa on May 25, 2016 23:43:12 GMT
A Battery-Powered Mailbox Node Sketch, a la CompuTourist, Eric Tsai, & jimkernjr?? (Preliminaries)
The software is based on code from Eric Tsai’s version ( Instructables: Uber Home Automation) plus computourist nodes plus maybe some code from jimkernjr’s adaptation of Eric’s. This sketch is an expanded version of my choose_nodes Sketch that now includes a MAIL option. You can see documentation for using other sketch options in this thread. The hardware for the Mailbox Node has Arduino d3 pulled HIGH by an internal Arduino pullup. When the switch closes, d3 goes LOW & the MAIL sections of the sketch sense that & sends it to OpenHAB & also sends the node’s signal strength (RSSI) & voltage. This sketch needs one library downloaded & installed to your computer. Make sure you have the RFM69 library in the right place on your computer by getting what you need from this thread. (The SPI & avr/sleep.h libraries come with the Arduino IDE install.)
|
|
|
Post by papa on May 25, 2016 23:50:29 GMT
Mailbox, etc. Node (Software) Updated Feb. 28, 2019
See this thread to download the latest choose_nodes sketch & to do the initial customization. Added customization to program only the Mail Box Node,
Find this line & UNcomment it (delete // at its start): // #define MAIL
#define NODEID 05 << change 05 to a unique number in your RFM69 network (For this mail box node, I suggest you use NODEID 82 as I will below.)
You can test the mailbox node on a wall-powered 3.3 volt manufactured Arduino compatible: Make sure #define DEBUG is UNcommented so the Arduino serial monitor will use 115200 baud to display node debugging output. With Arduino IDE running on a computer & the Mailbox Node connected via USB, upload the sketch program to the node. Then with the node still on USB, the Gateway successfully running connected to your Ethernet network & the IDE serial monitor running at 115200 baud, the serial monitor will display connection & data info about the Mailbox node.
Update, March 7, 2019: Instead of making the DIY Arduino in the next post, you can follow this post for a battery-powered mail box node on a manufactured Arduino compatible (which already includes the RFM69 radio). Before you program a battery powered Mailbox node, you may comment the line #define DEBUG, i.e. put // at its start. Next: Programming the ATMega328 chip with the Mailbox, etc. Sketch
|
|
|
Post by papa on May 25, 2016 23:55:14 GMT
Without a USB port on the Mailbox 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 end section of this thread’s first post. Arduino as Flash Programmer.fzz (8.65 KB) < Here is a Fritzing file of the circuit ^^ Here is a pic 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. 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 Mailbox 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 Mailbox 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.
|
|
|
Post by papa on May 26, 2016 0:06:07 GMT
OpenHAB configurations needed for the Mailbox, etc. Node: Updated, Feb. 28, 2019
For the following, you need OpenHAB 2, the MQTT 2.xx Binding, & a MQTT message broker: See this thread on installing OpenHAB 2.5.0.M1, the MQTT 2.x Binding, & the Embedded MQTT broker. The official OpenHAB documentation is also helpful.
(Presupposes NODEID is 82. In the following, replace 82 with the NODEID you assign)
In PaperUI, Configure a Generic MQTT Thing using the following fields: Name Node82 << This is the RFM69 Node to be accessed. Thing ID [ randomly generated ?? ] Location Mail [Thing's location on which tab of PaperUI\Control ] Bridge Selection MQTT Broker - mqtt:systemBroker:embedded-mqtt-broker ----------------------------
At PaperUI\Configuration\Things\Node82, add a Channel, Click on the "+" in a blue disc beside "Channels"
In the Add Channel Window, fill the fields: Channel type Text Value < choose type according to the item data type we want Channel id Node82Channel02 < arbitrary ? as long as we match in a linked item later Label Node82_RSSI < arbitrary ? MQTT State Topic home/rfm_gw/nb/node82/dev02
----------------------------------
At PaperUI\Configuration\Things\Node82, add more Channels.
In the Add Channel Window, fill the fields: Channel type Text Value < choose type according to the item data type we want Channel id Node82Channel04 < arbitrary ? as long as we match in a linked item later Label Node82_Volts < arbitrary ? MQTT State Topic home/rfm_gw/nb/node82/dev04
In the Add Channel Window, fill the fields: Channel type Open/Close contact < choose type according to the item data type we want Channel id Node82Channel46 < arbitrary ? as long as we match in a linked item later Label Node82_Volts < arbitrary ? MQTT State Topic home/rfm_gw/nb/node82/dev46 ----------------------------------------------
Add to . items file entries: Number Node82Rssi "Mail82_RSSI [%.3f db]" <network> (Nodes) { channel="mqtt:embedded-mqtt-broker:topic:mything:Node82Channel02" } Number Node82Voltage "Mail82Voltage [%.3fVdd]" <battery> (Nodes) { channel="mqtt:embedded-mqtt-broker:topic:mything:Node82Channel04" } Contact Mail82 "Mail82 [%s]" <lock> { channel="mqtt:embedded-mqtt-broker:topic:mything:Node82Channel46" }
DateTime mailbox_time "Mailbox Updated [%1$tA, %1$tm/%1$td, %1$tI:%1$tM %1$tp]" < mailbox>
Important: In PaperUI, link the three above channels to the FIRST three items above (mailbox_time does not use its own channel.)
Note: The first two items above gather the signal strength & voltage of the Mailbox node (if the node's code for those is enabled). The third item records the last change in the relevant pin's state. The last item will hold the last time the mailbox door was open & closed. Sitemap entries below report these item’s data on the Classic UI (user interface) displayed on a browser. Add to sitemap file entries: Text item=mailbox_time << Use this entry for sure. Text item=Node82Rssi Text item=Node82Voltage ^^ These second & third sitemap lines are optional. Add to rules file entries: (updated 5/16/2017) rule "update mailbox" when Item Mail82 received update then postUpdate(mailbox_time, new DateTimeType()) end Note: When the mailbox door is opened & closed, the node sends the change of mailbox state. When OpenHAB receives that update of D3's state via device 46, the rule above also updates the date & time to be posted on the UI. The node will also send signal strength & voltage unless that part of the sketch is disabled.
^^ Download this icon & add to OpenHAB 2's \conf\icons\classic folder
|
|
|
Post by papa on May 26, 2016 0:11:30 GMT
Once nodes & OpenHAB (& its configuration files) are working, have your browser display the Classic UI by entering the address:
(Replace My with the name of your sitemap)
http://localhost:8080/openhab.app?sitemap=My#
Or view / control your DIY home automation network via your smart phone: See my Success... thread at the end of the Oct 17, 2015 at 6:10pm post. On the User Interface, OpenHAB should post the radio signal strength & voltage of the Mailbox node & the last time the mailbox door was open & closed. Perhaps an improved node could actually sense the presence of mail in the box & even distinguish between outgoing & incoming mail. One can hope the Mailbox Node's batteries will last a fairly long time since it's mostly sleeping, except to wake briefly at door open/close & send 3 pieces of data. However, the voltage regulator will use some power even when the node is sleeping. I have not permanently installed this node in my mailbox. I did test it by putting it inside the mailbox & simulated the door opening & closing. The tilt sensor is very sensitive. Just a little tilting closes the switch. Even through the mailbox's metal & across an estimated 90 feet (27.4 meters), the node transmitted to the Gateway & OpenHAB very reliably. How will you use this node? What is your experience & learning in using it for a mailbox? What is your experience & learning in using it for other purposes (to sense opening & closing)? Post your answers below this post.
|
|
|
Post by papa on May 27, 2016 13:53:56 GMT
Update: As long as battery level is adequate, this node works. However, I'm not pleased with how the node uses battery power. I tried it with 4 AA alkaline batteries through a 3.3 volt producing voltage regulator. Batteries depleted sooner than I hoped. Then I tried disabling the voltage regulator & directly powering the node with 2 AA batteries. Plus I turned off DEBUG mode that might use power transmitting data even though the node was not connected to a serial monitor. Battery levels still depleted sooner than desired.
With the exception of how battery level is measured, my node resembles Eric Tsai's stripboard version that seems to have used 4 AA batteries through the same voltage regulator. I wonder how long batteries lasted for him. I also wonder how long batteries last for jimkersjr's printed circuit board version.
Areas to explore: Try jimkernsjr's adapted sketch instead of my multi-choice sketch. Disable the node's sending signal strength & voltage level. Try the node sleeping methods I used with the PIR battery-powered node based on gandalph's work. Try using a miniwireless to build the node.
Thoughts, anyone? What are your experiences with battery-powered nodes?
|
|
|
Post by jimkernsjr on May 28, 2016 19:53:46 GMT
Wow, thanks to Papa for working on it again!
Just a couple of points from me: -I haven't had bad luck at all with mine, but it's still new. I haven't implemented it yet-it's still sitting on my kitchen bar, and I set it off 2x a day to simulate usage. He uses a cheap cell bank with a lithium battery from the $5 store. I tapped the battery direct like I mentioned (of course with a resettable fuse) and kept the other circuitry to recharge it. I got tired of opening the case to check the voltage, so I just have been doing a voltage check from what it reports in MQTT. I've dropped .02 volt in about the month it's been running. -If anyone really likes my PCB, I'll clean it up and repost it. I advise against using it as is-it needs some small tweaks for the voltage sensor voltage divider, and the cap for the programming header reset line. Other than that, it's pretty much what Eric designed with the exception of LED on D8. -If you like my adapted sketch, I think it needs some "cleanup" work too, it was in no way intended to be final. When I decide I'm happy and stick it in the mailbox (probably in another week or two), I'll try to neaten it up and repost it. Conceptually, I like the way Eric wrote it - for such a node it's simplicity was appealing. -Mine still has DEBUG on - I didn't think this would much matter being opened 2x, and without the serial monitor physically connected no resistance? But I still struggle with electrical circuits so I am probably wrong about that...
Papa-did you test your consumption? I think I was close to what Eric had-I'm not at home for a while, but I'll check it active and sleeping and let you know. I'd love to know your meter readings, sleep and active, as I'm very surprised of your comments about it's high consumption. Seems my node is following the trend of Eric's, I don't know why yours would not be - seems we all used the same voltage regulator. I did look at others, but I didn't see a better choice either.
Good luck all!
|
|
|
Post by papa on Feb 15, 2017 2:44:33 GMT
In posts above, I've tweaked, clarified, & added missing aspects (later-version sketch with matching customization, icon missing from before). ----------------------------------------------- See the dated changes in the following posts: May 25, 2016 post, that starts with " Building a Battery-Powered Node for Mailbox, etc" May 25, 2016 post, that starts with " Mailbox, etc. Node (Software)" May 25, 2016 post, that starts with " OpenHAB config files needed for the Mailbox, etc. Node" ----------------------------------------------------- I encourage you to first get this Mailbox Node working on a wall-powered Arduino INSTEAD OF on a DIY Arduino on battery power ^^ For that, use this schematic instead of the DIY Arduino schematic above Next: Getting Results from the Mail Box End Node
|
|
|
Post by papa on Feb 15, 2017 3:08:18 GMT
Getting Results with the Mail Box End NodeUsing the above tweaked posts, I just built, programmed, & tested the Mail Box Node on a wall-powered Arduino & it still works. Looking at it now, the programming could be improved, but it works as is. This Node had worked in the earlier version with OpenHAB 1.8.x & now it works with OpenHAB 2. With the built, programmed Mail Box End Node connected to your computer's USB, the Arduino IDE Serial Monitor Output should look something like the following (before & after D3 connects to ground through some switch or jumper. The relevant OpenHAB User Interface lines should look like this ...
|
|
|
Post by papa on May 17, 2017 2:03:23 GMT
In this thread, ragoth reported he had problems when tried to use the MAIL option on a battery-powered node to sense (via a reed switch) if a door was open or closed. Useful for battery power, the node mostly sleeps on low power until a change on pin D3 wakes it to report. However as previously written, the MAIL-type node & OpenHAB only reported the time when pin D3 changes states, not what that state is. I have currently rewritten the MAIL code to report the D3 change of states. The sketch version provided above has the new MAIL code. The changes will make no noticeable difference for the Mailbox End Node. However, the changes will make it possible to use the coding for other purposes like battery powered nodes that sense whether windows or doors are opened or closed.
|
|
|
Post by papa on May 17, 2017 2:19:04 GMT
Building & Programming a Door or Window or ?? Sensing Node Updated Feb. 28, 2019
Follow the above directions, with the following changes & additions: To program only the Door or Window or ?? Node, in the choose_nodes sketch, UNcomment (remove the starting //) a line so it reads #define SWITCHIRQ. (This works the same as #define MAIL, but indicates better what is happening.) Add another sitemap file entry: Text item=Mail82 The node will mostly sleep, but when D3 changes state, the node will wake & report its data. The above sitemap file entry will use the D3 state (via the Mail82 item) to report the door or window open or closed.
|
|
|
Post by sunbloquer on Feb 4, 2018 17:01:13 GMT
<< Tweaked on 2/14/2017 ^^ Schematic for a Battery-Powered Mailbox Node (with voltage regulator) (click pic for larger view) Caution: The following Fritz file & the Fritz pic were corrected & replaced on 5/26/2016. (One leg of the switch should be connected to Arduino GND instead of 3.3 volts.) The schematic just above was & is correct for the sketch. My apology for the error. << Fritz of Battery-Powered Mailbox Node (Note: You need the open source Fritzing program.) Parts' positions & shapes are skewed for visibility & Fritzing's limits. Use your judgment when assembling. Caution: Use only one of the 3 options for battery power in the Fritz. ^^ A picture of the Fritzing layout of the node (much more useful in the Fritzing program) (Click on the pic for a larger view) In the schematic, you have 22pF for the crystal and in the Fritzing 10pF ?
papa: Yes, 22pF in the schematic is the correct value for the crystal's capacitors. 10pF seemed to be the closest value that Frizting would let me enter. I added a note to the post about the difference in values.
|
|
|
Post by papa on Feb 28, 2019 18:07:45 GMT
Mail Box Node with Manufactured Arduino CompatibleInstead of the DIY Arduino above, you can do this project with a manufactured Arduino compatible (that also has the RFM69 radio installed). From this post, you need the items 1), 2), & 4).
Battery-Powered Miniwireless' Mail Box Node ConnectionsFor programming & testing, the following diagram hints how you connect the USB device on the Miniwireless' short end & how (somehow) you will connect the tilt switch's pins to D3 & GND. The diagram also shows where you solder the antenna. The antenna's length depends on the RFM69 radio frequency you chose. For that, see this post on antennas in the thread for building an RFM69 Gateway.
For some applications (windows & doors), one might use a reed switch (& magnet) instead of the tilt switch. Or for the tilt switch, one might substitute a 3 pin Hall Effect Switch (& magnet). For that, connect the Hall Effect Switch's (HES) Gnd to Arduino Gnd, HES Data Out to Arduino D3, & HES vcc to Arduino 3.3 volts.
Use the same sketch, customizing, & OpenHAB configurations as above ( starting here) which were updated to be compatible with OpenHAB 2.5.0.M1, MQTT 2.xx Binding, & the Embedded MQTT message broker.
|
|