Long Distance Mailbox Alert using LoRa

You’ve got mail! An IoT project using solar power and long range radio

In these pandemic times of limited mobility, I become more like a dog every day: looking forward with great enthusiasm to meals, walks and car rides. One of the daily events that’s taken on new importance is walking down to the mailbox. But it’s over 100 yards away from the house, so it’s nice to know when there’s actually something in it to collect. So I devised a means of getting an alert when the mail is delivered.

There are simple mechanical devices that set a visible flag when a mailbox is opened but ours is too far from the house to see. And the distance exceeds the range of commercially available Bluetooth and WiFi solutions. There is no source of power near the mailbox. Running hundreds of feet of cable seemed like an expensive and impractical means of solving the problem.

I cobbled together the perfect solution using a repurposed solar-powered floodlight and LoRa transmitter/receiver pair. LoRa (Long Distance Radio) works great for sending short data packets great distances. Unobstructed range can exceed several miles. LoRa modules are inexpensive and consume very little power.

An ideal IoT solar-powered enclosure

I found a $30 solar floodlight on Amazon that is perfect for this and would be for many other IoT (Internet of Things) projects. The device has a weatherproof enclosure, two user-replaceable 2200 mAh batteries and charging circuit. One screw opens it up and there’s plenty of room inside to add your own circuitry inside. The only deficiency I see with this product is that it lacks an O-ring or other means of weatherproofing, although the Amazon product page claims it is IP65 splash resistant.

Interior of solar panel before any modification

The project is described below in detail below in case you want to build something similar

Project Summary

A pair of LoRa radios is used for this project, one as transmitter and the other as receiver. The transmitter spends most of its time in low power mode with the radio sleeping. In that state it draws only around 10 mA. We’re powering it from the solar panel’s two 2600 mAh batteries, enough to power the module for 500+ hours. That’s a lot of cloudy days!

Whenever the state of the connected switch changes, the transmitter sends a short string of text: “1” indicating open or “0” for closed, followed by a space then the battery voltage. For example, “1 4.07”. The receiver listens for these packets. When one is received, an LED and/or servo are activated.

The LoRa module also echos the message to its serial port for interfacing with other systems (more about that in the next post).

Keep in mind that this project could be adapted for many other open/closed, true/false monitoring scenarios, e.g., driveway gates, doors, motion alarms, etc.

Bill of Materials

  • Hikeren Solar Light or similar
  • Pair of LoRa32u4 development boards like this set
  • An ESP8266 WiFi board (optional) like the D1 Mini (see next post)
  • Magnetic reed switch like the kind commonly used for alarm systems or other suitable contact for mailbox door
  • 10K pull-down resistor (exact value isn’t too important)

Arduino code is located at: https://github.com/RatRanch/Long-Distance-Mailbox-Alert

Assemble the Transmitter

  1. If you haven’t yet set up the Arduino IDE for use with your LoRa32u4 board, follow along with this guide. The setup only needs to be performed once.
  2. Upload the mailbox_transmitter sketch to one of the LoRa32u4 boards.
  3. Open the solar panel enclosure by removing one screw
  4. If you are attaching an external antenna, drill a 6mm (1/4″) hole in a suitable location and attach the antenna. Use an O-ring or some silicone sealant to keep it watertight.
  5. Clip the wires that attach the LED floodlight–which isn’t used for this project–to the circuit board. We will be using this cable to connect to a switch instead. Attach these wires to pins 5 and 3V3 (polarity doesn’t matter) and attach 10K pull-down resistor between pin 5 and Gnd. Solder these connections.
  6. Mount the LoRa board above the existing charging board. You can use two of the existing screw holes with spacers or a piece of double-sided tape. Make sure the charging and LoRa boards aren’t touching each other (I used a piece of Kapton tape as an insulator).
  7. Attach positive and negative power leads to the corresponding battery rails.
  8. Then re-attach the enclosure cover. Make sure the power switch on the back of the case is in the On position.

    The completed transmitter assembly interior should look something like this:
Installed LoRa Board

Here’s the installed transmitter assembly:

Installed LoRa Transmitter Assembly

Assemble the Receiver

  1. Upload the mailbox_receiver sketch to one of the LoRa32u4 boards. The code repository is here.
  2. If you just need an indication of when the mailbox is opened, you can stop here. The built-in LED will alternate between on and off every time the mailbox is opened. You could optionally connect an external LED to pin 13.
  3. Or you could have a little more fun and make an enclosure for the receiver. With a working flag that goes up when mail is delivered!
  4. You can more or less follow the instructions here to print and assemble the mailbox enclosure and mount the flag servo. The mounting holes don’t quite line up with the LoRa board but I had good results mounting it with only one screw. Double sided tape would also work fine. A nice remix of the design is here if you want a post and stand.
  5. Solder three wires from the servo to the LoRa board. Power positive goes to the 5V pin and negative to the Gnd pin. The signal wire gets attached to pin 11.
  6. Short pin 5 to 3V3 (or install a momentary switch between these pins) to test the servo action and align the flag.
  7. There is just enough room in the mailbox to fit the “rubber duckie” antenna that comes with the LoRa board if you rotate it to the 90 degree position. Cover the metal portion of the antenna with heat shrink tube, tape or whatever to prevent it from shorting the circuit board. You could also use a 78mm length of wire as an antenna but the range won’t be as good.

Operation

There’s really not much to it. 🙂

When the receiver is powered on, the flag will rotate clockwise to its down position. Every time the contact switch attached to the transmitter closes, the flag will toggle position. If you’re putting mail into your mailbox for collection, you can just open and close the mailbox door an extra time to reset the receiver flag to its down position. Or cycle power to the receiver, which will also reset the flag.

In the next post, I’ll describe how I interfaced the mailbox receiver with the awesome Indigo Smart Home Software platform. It sends a text message to my cellphone when the mail arrives.

Technical note: conflict between servo and RadioHead libraries

The RadioHead library is used to operate the LoRa 32u4 RFM95 radio. Out of the box, this conflicts with servo.h, which we would normally use for projects involving servos (more details here).

One solution is to modify the RadioHead library to eliminate the conflict by using a different hardware timer, however, I wanted to make this project easy for others to implement.

You’ll note that I’ve “rolled my own” soft servo control code in the mailbox_receiver.ino sketch (moveServo() function). This technique would not work well if any degree of precision is required but we’re just concerned about moving the flag 90 or -90 degrees for this project. Unlike other examples I found on the web, this function sends multiple positioning pulses instead of just one to prevent position drift.

A $2 Development Board Test/Programming Jig

I’ve been using LoRa (Long Distance Radio) boards for a few recent projects. At $20 a pop, these aren’t exactly cheap. I didn’t want to dedicate one to breadboard prototyping by soldering headers to it and sought a commercial solution that would allow me to easily make a reliable temporary connection. I did not find anything like that on the market (please leave a comment if you know of such a device).

I did a bit of research and learned that pogo pins are commonly used for constructing test jigs. The downside to all the designs I saw is that they required either 3D printing parts or drilling.

I found this P75-E2 pogo pin with a diameter that can fit into a standard breadboard. But the problem is that the pins are too long and don’t stay in alignment. As you can see in the photo, my solution is to sacrifice a second breadboard by removing all of its metal clips (pry them out from the bottom) and then stacking it on top of an unmodified breadboard. Mini breadboards like these are cheap enough to devote a pair to each development board format you use.

I find that a piece of rubber electrical tape (the kind without adhesive) or a rubber band is sufficient to keep the part in contact with the board. Here is a jig for Adafruit Feather format boards with a LoRa card on top:

Why Backups Matter (even when they don’t matter)

Apple continues its multi-year assault on my beloved “late 2011” 17 inch MacBook Pro. First by shipping it with a famously defective logic board, which I learned to repair by periodically baking and now by stymying my efforts to to restore backups to it.

When the 17-incher’s hard disk started to suffer from an “invalid fsroot tree” as reported by Disk Utility, I migrated my account over to a new 15 inch MacBook Pro and started using it as my primary computer. But the 17 kept chugging along and I continued to use it mainly for designing and slicing 3D prints for my awesome Prusa MK3S.

It wouldn’t support any OS after High Sierra and occasionally I was unable to open documents but the laptop performed well enough for its current purpose.

All the work I was creating on the 17″ Mac was either one-off stuff or stored in the cloud. So I saw no point in wasting storage and backing the laptop’s increasingly corrupt file system. When the time came, I would just reformat or replace its SSD and restore from the 15-incher’s backup. Easy peasy.

So the day finally came when ‘Ol Seventeen just kept crashing and I replaced it’s 1 TB SSD with a 2TB disk. I fired it up in Internet Restore mode (Command-Option-R), formatted the SSD, and installed High Sierra.

So just use Migration Assistant to restore my account from a Time Capsule backup, right? Nope, that didn’t show any valid backups to restore from. No problem, I could use Migration Assistant to push the account from the 15-inch to the 17-inch, correct? Um no, Apple wouldn’t have any of that either.

Backups from the 15″, which is running Catalina, could not be migrated to the older High Sierra OS. So instead of restoring my account the easy way using Migration Assistant, I will need to manually copy my stuff over from the 15″, reinstall applications, re-set preferences, re-enter passwords and all that kind of fun stuff. Uck.

So don’t assume that the migration tool that makes it so easy to move from an old to a new Mac works the other way around. In retrospect, I can understand why this isn’t just a diabolical plot to get me to buy another new Mac. There’s no practical way for an OS to know what incompatible applications, features or documents could be added in future operating systems, so no way to determine what stuff is compatible and what isn’t. Lesson learned.

Reflow Madness

Over the past several months, I did a few more reflow repairs with my trusty heat gun.  I successfully resurrected a Beats Pill bluetooth speaker but it failed again after a few weeks.  Another Pill is still working okay.  I rescued a 15″ MacBook Pro with video problems but had no success with a 17-incher.

Meanwhile, my own 17″ MacBook Pro, which had been limping along with disabled AMD graphics (thanks to Cody Krieger’s excellent gfxCardStatus menu bar app), went fully dim after a reboot.  This was my excuse to hang up the heat gun for good and invest in a cheap Chinese reflow oven.

At $369, the Happybuy Reflow Soldering Machine is very cheap for a reflow oven but pricey given its design flaws and build quality.  The oven I purchased is an example of the T962A design, which is produced by several different manufacturers.  Google “T962A” and you’ll find various hardware fixes as well as improved firmware.

As shipped, the T962A is both unpleasant and dangerous to operate.  At this stage, I’ve made two modifications that should be considered mandatory

The first problem is that the metal case is not properly connected to ground, posing the potential risk of electrocution!  This is a widely known (and easy to fix) issue.  I’m amazed that units with such a serious defect continue to be shipped.

The second problem is that a heat shield is secured with what appears to be paper masking tape.  It produces noxious fumes and smoke when the oven heats up.  This is also easy to fix by replacing the tape with Kapton tape.  LOL, on Amazon the oven and tape are “frequently bought together.”

There are other fixes available to improve the UI and performance that I haven’t bothered with.  After fixing the ground and tape issues, the oven performs fine for repair work.  I use profile #3 for lead free solder.

To date, I’ve had one success and one failure with the oven.  I wrecked the aforementioned Beats Pill by melting the line in and out jacks.  These are apparently installed after the SMD components are reflowed.  On the other hand, my ailing MacBook Pro was a complete success.  Time will tell if this repair lasts longer than the heat gun fix.

Nuvico HDocs Mobile HD app stopped working

Here’s a quick one for anybody with a legacy Nuvico HD-TVI security DVR, e.g.,model DT-E800.  The iOS app stopped being updated in 2014 and doesn’t work with iOS versions 11 and later.  My user was ready to ditch his perfectly functional DVR because of this.

Long story short, a little reverse engineering revealed that the Nuvico platform is identical to another DVR branded “Hikvision”.  And Hikvision has a current app that is a drop-in replacement.

Replace HDocs Mobile HD with iVMS-4500 lite.  You’re welcome.