Smart mailbox saga, and success

If you can find no other place to discuss a home automation related topic, add it here. This is a completely open forum. Want to discuss competitors? Have any general comments about home automation? This is the place!
User avatar
berkinet
Posts: 3306
Joined: Tue Nov 18, 2008 2:08 pm
Location: Berkeley, CA, USA & Mougins, France

Smart mailbox saga, and success

Post by berkinet »

Our mailbox is not attached to the house. It is outside a gate, on the road. So, to avoid unnecessary trips to check if we had mail or a package over the past few years I have made several attempts to create a smart mailbox. The basic idea was to be notified when there was mail in the mailbox. Up until now, all of these attempts failed for one reason or another.

The initial concept was to be notified each time the mailbox door was opened. My first approach was to use a tilt-sensor (a typical alarm element) on the door of the mailbox. Each time the door opened, it would light a key on a keypad link (via an alarm interface plugin). The light could be reset by pressing the key. Technically, it worked. But, what happened was nobody would ever bother to reset the system after collecting the mail. Also, simply opening and closing a mailbox is not, per-se, an indication that mail has arrived or been collected.

My next attempt was to find a way to be notified of the actual presence of something in the mailbox. This approach would have no need to be reset since it was the state of the mailbox I would monitor rather than delivery or collection of the mail. My first approach at mail detection was to use a distance sensor at the top of the mailbox. The hypothesis being the presence of something in the mailbox would shorten the distance between a sensor at the top, and the mailbox floor. I tried sonar and light based sensors. But, both were unreliable because of the different ways mail could land in the mailbox. Another issue was something like a single postcard which was not easily measurable.

I then tried simply measuring reflected light. The hypothesis here is if the mailbox inside is black, the presence of anything (other than something 100% black) would reflect additional light. I painted the inside of the mailbox black and mounted an LED and light detector at the top of the mailbox, looking towards the mailbox floor. This worked to a degree. But, was fooled by the mailbox being opened (daylight or even streetlights) or objects that were dark in color. In the end, there was just not a reliable differentiation between presence and absence of an object.

Next, I considered using a camera with image detection. But, set that aside for a while because of the complexity.

Then, I returned to an idea I had considered early on, but discarded because it seemed to be too much work. This idea was to essentially install a scale on the bottom on the mailbox with a false floor resting on it. I decided to use a 0-5kg load cell as the detector and connect it through a Wheatstone bridge to an analog I/O port and on to Indigo via a plugin. This had moderate success. I could detect a change in weight of less than 1 gram. However, there was a major issue with the load cell - it was not temperature stable. This meant I had no reliable zero-point to use as an "empty" reference. I tried looking for a change of a certain minimum value. But, even that was unreliable - simply having a letter fall out of my hand and back into the mailbox would fool the system.

However, I knew I had the right approach and all I needed to do was find the right hardware. With no easy way to know which load cells would work, I decided to try to adapt a regular electronic kitchen scale. But, while looking for the right scale I happened upon the Stamps.com 0-5lb USB mail scale. This scale is typically given away when someone opens an account and they are readily available on the used market. ebay has loads of them at an average price of $10 USD. I then found someone's project where they figured out how to read the scale directly from a computer. That was all I needed.

I got the scale, removed the (very simple) load cell an d electronics from the case and placed them under my false floor. (The scale automatically sets the tare weight when it turns on, so the false floor weight is no issue.) I then adapted the software I had found to read the scale once a minute and compare the weight to the last reading, or see if it was zero and had the program update Indigo using the RESTful API. It works! I get notified when the weight becomes n on-zero and again when it becomes zero. I also mounted a bright blue LED outside the gate so we can see if there is mail when we arrive.

There is a potential gotcha, If there is a power failure when there is mail in the mailbox and the power comes back on with the mail still present, the tare will now include the mail. This hasn't happened yet. But, it is easy enough to simply power cycle the scale.

YMMV.
noel1983
Posts: 446
Joined: Fri Oct 17, 2014 1:35 pm

Re: Smart mailbox saga, and success

Post by noel1983 »

Pics man give us pics!!!
Great write up and perseverance:)


Sent from my iPhone using Tapatalk
User avatar
pocster
Posts: 276
Joined: Sat Nov 15, 2014 9:26 am

Re: Smart mailbox saga, and success

Post by pocster »

Fantastic! Well done !!!
MR_ROBOT_
Posts: 28
Joined: Mon Feb 11, 2019 11:18 am
Location: Lancashire, UK

Re: Smart mailbox saga, and success

Post by MR_ROBOT_ »

This sounds great. I have been experimenting with motion detectors in my external post box on my gate to no avail.
Any further info on parts needed and code would be greatly appreciated.

Great write up as well.

As per "noel1983", we need pics :D :D :D
User avatar
berkinet
Posts: 3306
Joined: Tue Nov 18, 2008 2:08 pm
Location: Berkeley, CA, USA & Mougins, France

Re: Smart mailbox saga, and success

Post by berkinet »

Per request, here is some additional information.

The scale was a Stamps.com model 510
The software to read the scale which I started with, and then modified a bit, is usbscale on GitHub
The wrapper shell script that compares readings and notifies Indigo is at the end of this post.
I used a Phidgets SBC-3 to run the software. But, you could use any single board computer with a usb interface. A Raspberry-Pi would work very well.
The mailbox is a standard french mailbox (I am in France) but you can adapt this to most any reasonable sized mailbox or seat the bottom of a mail drop or chute.
  • Pics...
    • The scale
      the scale
      the scale
      scale-new.png (209.3 KiB) Viewed 2016 times
    • The mailbox
      the mailbox
      the mailbox
      mb-1.png (456.64 KiB) Viewed 2016 times
    • Closeup of the installed scale
      installed closeup
      installed closeup
      mb-2.png (300.8 KiB) Viewed 2016 times
    • The signal LED
      signal led
      signal led
      mb-3.png (174.91 KiB) Viewed 2016 times
shell wrapper for usbscale

Code: Select all

#!/bin/sh

LASOBS=0
while true
	do CUROBS=`/usr/local/sbin/usbscale 2>/dev/null`
	echo "Received :${CUROBS}: " `date`

	if [ $CUROBS != $LASOBS ]; then
		echo "Measurement change = ${CUROBS}"
		# curl -u foo:lbar --digest -X PUT -d value=${CUROBS} http://192.168.1.10:8176/variables/mailWeight
	fi

	LASOBS=$CUROBS 

	sleep 1
done
noel1983
Posts: 446
Joined: Fri Oct 17, 2014 1:35 pm

Re: Smart mailbox saga, and success

Post by noel1983 »

Awesome thanks for the pics. How do you have power down there by the way?
User avatar
berkinet
Posts: 3306
Joined: Tue Nov 18, 2008 2:08 pm
Location: Berkeley, CA, USA & Mougins, France

Re: Smart mailbox saga, and success

Post by berkinet »

One more link. Here is a video showing the insides of the scale. Note there are at least two varieties of the model 510 scale. The differences between them are small and either will work for the mailbox application..
User avatar
berkinet
Posts: 3306
Joined: Tue Nov 18, 2008 2:08 pm
Location: Berkeley, CA, USA & Mougins, France

Re: Smart mailbox saga, and success

Post by berkinet »

noel1983 wrote:Awesome thanks for the pics. How do you have power down there by the way?

Good question. There was already power there for the electric gate and door phone along with a second unused duct. When I changed to an IP based door phone (the DoorBird) I pulled a cat-6 cable down there. This could be done wirelessly in many ways (like an R-Pi w/wifi). However, the problem, at least for this particular scale, is that power must be constantly powered on. Otherwise, when it powers up, it will reset the tare. Unfortunately, this function his done in the firmware on the scale.

If you could find a decent, temperature stable, load cell, you could simply set the tare when the system is installed, and leave it. Then, you could power the scale down between readings, and set the readings to be less frequent. Switching to a Pi-Zero or low-powered Arduino would then probably allow you to switch run on solar power.
Post Reply

Return to “General Home Automation”