|
Post by papa on Aug 30, 2018 1:07:13 GMT
Improved RFM69 Mail Box Node, Introduction Thread Updated April 1, 2019 for at least openHAB 2.5.0.M1, MQTT Binding 2.xx, & the Embedded MQTT Broker
For convenience sake & for security sake, it would be useful to have device that reported activity at our mail box. Here we call that a Mail Box End Node.
Previous versions of the Mail Box Node were DIY Arduinos with only one switch. Actually, they detect an open/close of the mail box door rather than mail presence. This version intends to report a truer state of mail presence & what direction it is heading (out or in) by using two switches. We might say that there are two general types of mail boxes: 1. 2.
This mail box node version is intended to work especially with the first type of mail box. With some adaptation & some limitation, it might be used with mail boxes like the second type that have mail slots.
Next: Improved RFM69 Mail Box Node, Introduction Continued
|
|
|
Post by papa on Aug 30, 2018 1:08:45 GMT
Improved RFM69 Mail Box Node, Introduction ContinuedThis improved mail box node version will be tested on a wall-powered Buono Uno Arduino compatible. Then in another improvement, it will use an Arduino Miniwireless, a manufactured Arduino with included RFM69 radio. One can attach an USB device to program & test the Miniwireless, but then can detach the USB device & use battery power. The Miniwireless (no permanent USB circuit) needs less current than a regular Arduino & avoids building a DIY Arduino. Via the sketch, the mail box node sleeps most of the time to save battery power. It only wakes when weight on a levered micro switch changes the Arduino pin D3 state. At that time, the sketch reads the D3 state & after waiting 5 seconds (for mail box flag action by us or the mail carrier), the sketch also reads the D6 state obtained via the other (tilt) switch on the mail box flag. The sketch tracks & sends the current combined states of D3/D6 & the just prior combined states of D3/D6 via device 71. It also sends Radio Signal Strength (device 2) & node voltage (device 4) which will be useful for the later battery-powered node.
OpenHAB 2 can use the node-sent data (device 71) to determine mail status: D3 switch open = no mail. D3 switch closed & D6 switch closed = mail weight + flag up = outgoing mail. D3 switch closed & D6 switch open = mail weight + flag down = incoming mail ... etc. Using current & just past D3/D6 states, OpenHAB can indicate that outgoing mail has changed to an empty box or to incoming mail, etc.
After the node sends the combined statuses of the D3 switch (mail weight) & D6 switch (Flag orientation) & the other data, it returns to sleep until the next change in D3 status. Continued: This thread will document building & using the Improved Mail Box Node
|
|
|
Post by papa on Sept 2, 2018 19:28:41 GMT
Preparation for the Improved Mail Box Node Updated Feb. 27, 2019
Ability to solder items 2.54mm apart
Have experience building & programming other Arduino compatible projects. This project is usually hard & can be frustrating. Prior experience can help you be ready to make workable RFM69 radio devices.
Get experience building the simplest RFM69 DIY Home Automation network & using it with OpenHAB. This thread & its links lead you through (so far) the simplest & plainest I can make this VERY CHALLENGING PROJECT of building & programming the RFM69 Gateway & first RFM69 end node & getting them communicating with each other & with OpenHAB. Another thread gives you a way to test that your RFM69 radios are working. For the Mail Box Node to communicate with OpenHAB, you will need the RFM69 Gateway. Once you have your first end node working with the Gateway, you can re-purpose that end node into a test version of the Mail Box Node. Building from the above experience, you can then make a battery powered mail node from an Anarduino Miniwireless (Arduino compatible). The first end node can be then re-purposed into other types of end nodes documented on this forum.
Next, Preparation to Simulate the Improved Mail Box Node
|
|
|
Post by papa on Sept 3, 2018 19:49:59 GMT
Preparation to Simulate the Improved Mail Box NodeYou can simulate the improved mail box node by using the build of the first RFM69 Gateway & the first end node (above) plus two wires whose male ends can plug into Arduino female sockets (D3, D6, & 2 GNDs.) This could be short pieces of insulated 22 gauge wire (different colors ?) with bared ends OR male to male dupont cables. Thus, to simulate this mail box node, besides the parts listed for the basic RFM69 DIY Home Automation network above, you also need 2 short (10cm ?) insulated jumper wires with bare ends.
See the following schematic. On the first end node, connect one male to male jumper to D3 (simulates the micro switch to be closed by mail weight) & connect the other male to male jumper to D6 (simulates the tilt switch that is closed when the mail box flag is vertical. You simulate mail box activity by connecting & disconnecting one or both jumpers to Arduino GND.
<< Forum members, click on the pic for a larger view. (Free registration) If you already have experience with an RFM69 node's successfully communicating with an RFM69 Gateway & OpenHAB, you might skip ahead to using an Anarduino Miniwireless board for this node. (Later I will suggest parts to order for that.)
Next, Software for the Improved Mail Box Node
|
|
|
Post by papa on Sept 4, 2018 21:05:02 GMT
Software for the Improved Mail Box Node Updated Feb. 27, 2019
Forum members, from this thread, get the latest version of the choose_nodes Sketch & its initial customization. To previous coding, I have added an update to the previous (one-switch) mail box node plus new coding for this (two-switch) mail box node. ( Membership only requires free registration). This sketch can program several other types of end nodes. See a list of other projects here. To see this sketch's coding for the two-switch mail box node, use the Arduino IDE's Edit/Find menu to search for MAILFLAG. For some more insight, see this above post. This mail box node needs the sketch customizing in the next post. Next, Customizing the choose_nodes Sketch for the Mail Box Node
|
|
|
Post by papa on Sept 4, 2018 21:17:24 GMT
Customizing the Multi-Choice Sketch for the Improved Mail Box Node Updated Dec. 16, 2018
Find these lines & UNcomment them ( delete // at their start): // #define MWMAIL // #define MAILFLAG #define NODEID 05 << change 05 to a unique number in your RFM69 network (For this mail box node, I suggest you use NODEID 84 as I will below.) #define ENCRYPTKEY "xxxxxxxxxxxxxxxx" ^^ change xxx... to the same 16 character key you gave your Gateway #define DEBUG << make sure this line is UNcommented (no // at the start) UNcomment only one of these lines based on your RFM69 radios' frequency: // #define FREQUENCY RF69_433MHZ // #define FREQUENCY RF69_868MHZ // #define FREQUENCY RF69_915MHZ UNcomment this line if your RFM69's radio has an "H" in its part number: // #define IS_RFM69HW Connect the node to your computer's USB. Using the Arduino IDE, upload the customized sketch to the simulated Mail Box End Node. Next, Simulated Mail Box End Node, Serial Monitor Results
|
|
|
Post by papa on Sept 6, 2018 21:34:39 GMT
Simulated Mail Box Node, Getting Serial Monitor Results With the Simulated Mail Box Node connected to USB, open the Arduino IDE's Serial Monitor (SM). In the IDE's lower right corner, make sure communication rate is 115200 baud. When you open the Serial Monitor, the node should report there a few lines of data sent & then go to sleep ("lights out"). Only a change of the Arduino D3 pin (connecting or disconnecting its jumper from GND to simulate mail added or mail removed) will wake the sleeping node. Before the node sleeps, I added a delay(1500) or 1.5 secs that made the node wake up & send data more reliably when D3 changes. You may still need to change the D3 connection a couple times to get the node communicating properly. When it is communicating properly, it will report "Awake after sleep_cpu & wake routine. Wait for results..." As set by #define FlagWait, the node waits 5 seconds to allow time for a mail carrier or us to move the mail flag. After waiting, the D6 pin is read (will indicate the mail flag's position, vertical or horizontal.)
On the SM, the node then displays a 4 digit code after ">>>": 1) MailSwitch state 2) FlagSwitch state 3) LastMailStatus 4) CurrentMailStatus. Since each jumper or switch connects D3 or D6 to GND, closing a jumper or switch generates a pin state of 0 or LOW or false. Open gives a pin state of 1 or HIGH or true since the sketch attaches a software pullup resistor to both pins. The sketch calculates a CurrentMailState that adds a 1 for MailSwitchClosed & adds a 2 for FlagSwitchClosed. The node also uses its RFM69 radio to send 3) & 4) as a 2 digit (device 71) & returns to sleep until the next change on D3. Some sample Serial Monitor results (black text) & interpretation (blue text)... mail jumper closed = 0, flag jumper open = 1 >> means incoming mailAwake after sleep_cpu & wake routine. Wait for results... < wait 5 seconds for flag value to be read In order, each place reports >>> 0101 MailSwitch FlagSwitch MailStatusLast MailStatusNow Node: 84 dev: 2 cmd: 0 Ival: 0 Fval: 0.00 RSSI: -58 < Radio Signal StrengthNode: 84 dev: 4 cmd: 0 Ival: 0 Fval: 3.39 RSSI: -59 < Node voltageNode: 84 dev: 71 cmd: 0 Ival: 1 Fval: 0.00 RSSI: -58 < Mail Status Code data sent. lights out. mail jumper open = 1 & flag jumper closed = 0 >> mail in changed to flag left upAwake after sleep_cpu & wake routine. Wait for results... In order, each place reports >>> 1012 MailSwitch FlagSwitch MailStatusLast MailStatusNow ... data sent. lights out. mail jumper closed = 0 & flag jumper closed = 0 >> flag left up changed to outgoing mailAwake after sleep_cpu & wake routine. Wait for results... In order, each place reports >>> 0023 MailSwitch FlagSwitch MailStatusLast MailStatusNow ... data sent. lights out. Next, Mail Box Node, Getting OpenHAB Results
|
|
|
Post by papa on Sept 7, 2018 20:31:59 GMT
Simulated Mail Box Node, Configuring for OpenHAB 2 Results Updated April 1, 2019 (No fooling ;-)
(Note: the following assume NODEID 84 & installation of OpenHAB 2, MQTT Binding 2.x, & the embedded MQTT broker. See above.)
Go to PaperUI\Inbox\MQTT Binding\Search Manually Add. Click the ">" at right of Generic
Configure a Node84 Generic MQTT Thing using the following fields: Name: Node84 Location: BaseFR [Thing's location on which tab of PaperUI\Control, could also be physical location ] Bridge Selection MQTT Broker - mqtt:systemBroker:embedded-mqtt-broker PaperUI\Configuration\Things\ Node84 Add 3 channels (click + in blue disc)
Type: Text Channel ID Node84Channel02 Label: Node84_RSSI MQTT State Topic: home/rfm_gw/nb/node84/dev02
Type: Number Type: Number Channel ID: Node84Channel04 Channel ID: Node84Channel71 Label: Node84_Volts Label: MailStatus84 State topic: home/rfm_gw/nb/node84/dev04 State topic: home/rfm_gw/nb/node84/dev71
Mail.items (1.04 KB) << Download & save to OpenHAB 2's \conf\items folder This file contains items for Node 84 radio signal strength, voltage, & mail status. It also includes commented (de-activated) items for a Node 82, a one-switch mail node.
Important: Link the 3 items from the Mail.items file to their matching channels above.
mail.map (324 B) << Download & save to OpenHAB 2's \conf\transform folderThe Mail Status item (Mail84) in the Mail.items file uses mail.map to translate the 2 digit mail status code the mailbox sends in device 71. For example, the code 13 translates to "mail in to outgoing" (1, incoming mail changed to 3, outgoing mail)
mailbox.svg (3.37 KB) << Download & save to OpenHAB 2's \conf\icons\classic folderThis icon is associated with the Mail Status item (Mail84) & will display on the OpenHAB user interface. Add this line to your xxx.sitemap file in OpenHAB 2's \conf\sitemaps folder: Text item=Mail84 On the OpenHAB User Interface in a browser or mobile app, this will display the mailbox.svg icon & the device 71 mail status. Next, Simulated Mail Box Node, Getting OpenHAB 2 Results
|
|
|
Post by papa on Sept 7, 2018 20:41:09 GMT
Simulated Mail Box Node, Getting OpenHAB 2 ResultsIn a web browser running on your computer that host OpenHAB & Mosquitto, enter: http://localhost:8080/basicui/app?sitemap=[name of your sitemap] For example, you might have My.sitemap in OpenHAB 2's \conf\sitemaps folder AND at the top of My.sitemap you could have sitemap My label="My House"
^^ If so, you would enter: http://localhost:8080/basicui/app?sitemap= MyHere is a sample of a Mail Box Node's Mail Status displayed in an OpenHAB User Interface displayed in a browser.
<< Forum members, click on pic for larger view. Next, Preparing for a Battery-Powered Mail Box Node, Essential Parts
|
|
|
Post by papa on Sept 11, 2018 20:36:24 GMT
Battery-Powered Mail Box Node, Essential Parts You still need the RFM69 Gateway that you should have built above. Disconnect the Simulated Mail Box Node if you built it above. (Otherwise it conflicts with what we're making now.) In the following, you will not use the Arduino compatible or the RFM69 radio you used for the simulated node. Re-purpose it later to be another node documented on this forum. Essential parts for this battery-powered mail box node:1) An Anarduino Miniwireless (Arduino compatible) Choose HW-433 or HW-868 or HW-915 that includes an RFM69 radio with the same frequency as you chose for your RFM69 Gateway & first end node above. Make sure "H" is in the part number (for higher power). Those versions communicate longer distances. Disclosure: A couple years ago, I was given 5 Miniwirelesses in appreciation for documentation I did. I've had no compensation from Anarduino since then. 2) USB device to program & power the Anarduino Miniwireless for testing Tools & supplies are needed to solder: The USB device kit includes a 6-socket female header you must solder to the USB device. I believe it also includes a 6-pin male header you must solder to the GND--DTR end of the MiniWireless. If not, use the breakaway male headers listed below. Caution: switch the USB Device to 3.3 volts so you don't damage your Miniwireless with 5 volts. This USB device can be used to program & test other devices, like the ESP8266 WiFi devices in another board on this forum.
<< Switch is smaller than it appears. ^^
I ordered 3 to make the shipping more worth it.
^^ Sept. 12, 2018, link changed to what seems a sturdier tilt switch.
Other parts are needed. I give hints below. I suggest you read this thread to the end for ideas about those parts.
Next, Programming a Miniwireless with the Mail Box Node Sketch
|
|
|
Post by papa on Sept 12, 2018 19:45:08 GMT
Programming a Miniwireless with the Mail Box Node Sketch
Remember to disconnect the simulated Mail Box Node (if you made it above), so it does not interfere with the Miniwireless node (because they have the same NODEID).
In order to test the programmed Miniwireless node, you will need to accomplish more than items 1 & 2 from the last post.
Next, Miniwireless' Mail Box Node Connections
|
|
|
Post by papa on Sept 12, 2018 20:01:45 GMT
Miniwireless' Mail Box Node ConnectionsFor programming & testing, this diagram hints how you connect the USB device on the Miniwireless' short end & how (somehow) you will connect jumpers to D3-GND & D6-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.
<< Forum members (free registration), click on pic for larger view.
To the Miniwireless, we are applying the connections that we used for the simulated mail box node. Again you can use jumpers to simulate the two switches.
Next, Other Possible Parts to Get the Above Connections
|
|
|
Post by papa on Sept 12, 2018 20:50:46 GMT
Other Possible Parts to Get Miniwireless Connections For the Improved Mail Box End NodeI recommend you solder breakaway male headers like these (.1 inch or 2.54mm spacing) to the Miniwireless' longer sides (Rather than solder wires, etc directly to the Miniwireless GND, VIN, D3, & D6 holes) This allows flexibility in using the Miniwireless. For this project & others, Male to Male, Male to Female, & Female to Female dupont cables like this selection can give you a variety of ways to make connections. For this project & others, something like this kit supplies you for installing dupont male or female connections. There are special tools for installing these connectors, but if careful, you can do it with needle nose pliers.
Forum members, click on pic for larger view >>
When the USB device is connected, the Miniwireless only has one GND free & needs two GND connections (D3 & D6). You can connect the available Miniwireless GND to the GND rail of a small solderless breadboard like this. Then as desired, you can connect the Miniwireless' D3 & D6 to the breadboard's GND rail (near the board's blue line. Using from the above to make the diagrammed connections, I believe you should be ready to test the Miniwireless mailbox node like you did the simulated mailbox node above, starting here.
Next, Switching the Mail Box Node to Batteries
|
|
|
Post by papa on Sept 13, 2018 19:44:20 GMT
Mail Box Node on Battery PowerFor testing the Improved Mail Box Node with battery, this diagram hints how to make the connections.
More parts: Work out what battery supply you will use, any needed battery cases, & how to connect to the Miniwireless. So far, I've chosen 4 rechargeable AA Ni-MH batteries plus a battery case (1.2 volts X 4 = 4.8 volts). On the battery case's wire ends, I installed female dupont connectors which connect to the male header pins soldered to the Miniwireless' VIN & GND locations. Caution: Do not connect the USB device & batteries at the same time.
Similar to the simulated mail box node above, you can test this battery-powered version by connecting & disconnecting D3 & D6 jumpers. Since you should not be connected to USB, you cannot see feedback on the Arduino IDE's Serial Monitor. In your browser, you should see reports on OpenHAB's User Interface (UI). Just remember, the UI won't show changed mail status until a change in D3's state & a few seconds after that (delays explained here & here).
Next Thoughts on Installing Improved Node at a Mail Box
|
|
|
Post by papa on Sept 14, 2018 20:03:36 GMT
Thoughts on Installing Improved Node at a Mail BoxThe following diagrams & text are how I imagine installing the node at the mail box. I have not tried this yet.
< Forum members, click on pic for larger view.
Based on observation, find a place for the micro-switch so its lever will protrude thru the mail box's inside in a place likely to be covered with mail. Maybe make a small rectangular hole in the floor 1.5-2 inches from the mail box's front opening & in the middle between the two sides.
Next, Thoughts on Installing the Node's Micro-Switch
|
|
|
Post by papa on Sept 14, 2018 20:23:03 GMT
More Thoughts on Installing the Node's Micro-Switch We need a way to hold the micro-switch at the hole made in the mail box floor. Get a Solder-able Breadboard, preferably double-sided like this from SparkFun or this from Jameco. << Forum members, click on pic for larger view. Adapt two small wood or plastic spacers that are about the same thickness as the micro-switch's plastic block & just big enough to hold a thin screw without breaking. (adapt from 2 pieces of paint stick ??) Cut a piece of breadboard, big enough to mount the micro-switch in parallel solder strips, solder wires to the breadboard rails holding micro-switch pins," AND mount the blocks on each side of the micro-switch.
Insert the micro-switch's pins so each is in parallel solder strips of the breadboard (so the pins will not connect electrically until the switch closes). The micro-switch's pins are a bit large, but with care & gradual force, you can probably insert them into the breadboard's solder holes. The pins' forced insertion might be adequate without soldering. Expanding the holes a little may help.
The micro-switch has 3 pins with small labels in the plastic: "c" for common, "no" for normally open, & "nc" for normally closed. To the strips holding the micro-switch pins, solder wires for "c" & "no" (not "nc") so current only flows from D3 to GND when the switch closes. Allow generously for the wires to reach from the breadboard thru any mounting pieces under the mail box & reach easily to the Miniwireless node contained in a project box underneath.
Next, More Thoughts on Installing the Mail Box Node
|
|
|
Post by papa on Sept 14, 2018 21:00:45 GMT
More Thoughts on Installing the Node's Micro-SwitchGet suitable thin screws with flat heads for this: On both sides of micro-switch's hole in the mail box floor, drill a hole for the thin screw to travel from inside the mail box thru the mail box floor, thru the spacers & thru the breadboard). Drill a suitable hole in the spacers. If necessary, drill holes to allow the thin screws to start threading securely into the breadboard. Use the screws, etc. to fasten the micro-switch to the mail box's bottom with the switch lever peeking thru the floor hole. I believe mail boxes often have a mounting board beneath them. My thought is to make a cavity in such boards to hold the micro-switch plus breadboard piece.
Next, Thoughts on Installing the Node's Tilt Switch
|
|
|
Post by papa on Sept 14, 2018 21:18:59 GMT
Thoughts on Installing the Node's Tilt SwitchFor this & other projects, have assorted sizes & colors of Heat Shrink Tubing to protect & strengthen wiring (including 3/32 inch or 3mm) Have small, flexible insulated wire generously long enough to connect the tilt switch's 2 pins to the Miniwireless D6 & GND in a project box below the mail box. Maybe use 2 wires within a length of flexible USB cable. On the USB cable, free a couple inches of two individual insulated wires from the outer insulation. Slip a piece of heat shrink tubing on each wire away from the end. Strip the wire's end. If needed, shorten the tilt switch pins. Solder the stripped wires to each tilt switch pin, slip the tubing over pin, solder, & bare wire & heat shrink the tubing.
Fasten the tilt switch to one side of the mail box flag so when the flag is up, the switch is vertical. Fasten the switch so neither it nor its wires rub or bump much. (See the diagram in this post above.)
Next, Final Thoughts on Installing the Node
|
|
|
Post by papa on Sept 14, 2018 21:36:14 GMT
Final Thoughts on Installing the NodeIn my experience, the mail box node inside a metal mail box did not communicate well with the gateway. So I do not recommend that.
I suggest a water-resistant plastic project box big enough to hold the Node with its antenna vertical to the Miniwireless board plus batteries & any battery container. See the solar charger documentation linked above & allow any space that might be needed later for that. I recommend project boxes that have soft plastic inserts to pierce for wire entry. Try to have a project box that can be mounted with its lid on the side so you can most easily install & service inside the box (like getting the batteries for re-charging).
Drill holes in the project box's side that will be up against the mail box mounting board.
As needed, install dupont connectors on wire ends so they will connect to the Miniwireless locations. Thread wires into the project box. With screws, fasten the box to the bottom of the mail box boards. Connect the wires. Etc.
As I wrote earlier, I have only simulated the improved mail box node with the Miniwireless. I have yet completely installed things at a mail box. When I get opportunity to do that, I will post any new thoughts.
|
|