Looking for ideas...

Posted on
Thu May 17, 2018 2:19 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Looking for ideas...

I am building a mailbox monitor and am looking for some ideas.
(BTW, this is really an example of pattern detection that probably has value run many circumstances.)

Background
The mailbox is a typical french mailbox with a flap-slot set into a large door
mailbox.png
Typical French Mailbox
mailbox.png (16.2 KiB) Viewed 3895 times

There are several options for sensing either the opening of the flap or door, or the presence of mail in the mailbox. I have chosen to use a light detector placed at the back of the mailbox to detect changes in light caused by the opening of the flap or door. This will also work at night because off the presence of a nearby street light.

I have created an Indigo device that contains the state brightness which is an integer value in (lux). Changes in light level are broadcast to Indigo (i.e. I am not polling the sensor) Opening the flap or door causes an instantaneous increase in brightness and closing the flap/door is reflected by an instantaneous drop. I have created an Indigo trigger to record changes in brightness. Here is a typical sequence of results from opening the flap under bright sun:
    2018-05-16 15:06:38.195 Mailbox light level: 35.0
    2018-05-16 15:06:38.219 Mailbox light level: 29.0
    2018-05-16 15:06:38.247 Mailbox light level: 22.0
    2018-05-16 15:06:38.347 Mailbox light level: 16.0
    2018-05-16 15:06:47.769 Mailbox light level: 23.0 <- Starting to open flap
    2018-05-16 15:06:47.798 Mailbox light level: 32.0
    2018-05-16 15:06:47.813 Mailbox light level: 40.0
    2018-05-16 15:06:47.838 Mailbox light level: 47.0
    2018-05-16 15:06:47.866 Mailbox light level: 55.0
    2018-05-16 15:06:47.879 Mailbox light level: 62.0
    2018-05-16 15:06:47.913 Mailbox light level: 78.0
    2018-05-16 15:06:47.925 Mailbox light level: 84.0
    2018-05-16 15:06:47.963 Mailbox light level: 92.0
    2018-05-16 15:06:47.986 Mailbox light level: 98.0
    2018-05-16 15:06:48.021 Mailbox light level: 106.0
    2018-05-16 15:06:48.061 Mailbox light level: 112.0
    2018-05-16 15:06:48.136 Mailbox light level: 105.0
    2018-05-16 15:06:48.743 Mailbox light level: 111.0 <- Flap fully open
    2018-05-16 15:06:48.926 Mailbox light level: 104.0
    2018-05-16 15:06:48.972 Mailbox light level: 97.0
    2018-05-16 15:06:48.998 Mailbox light level: 91.0
    2018-05-16 15:06:49.014 Mailbox light level: 75.0
    2018-05-16 15:06:49.050 Mailbox light level: 53.0
    2018-05-16 15:06:49.074 Mailbox light level: 46.0
    2018-05-16 15:06:49.099 Mailbox light level: 37.0
    2018-05-16 15:06:49.111 Mailbox light level: 31.0
    2018-05-16 15:06:49.147 Mailbox light level: 23.0 <- Flap fully closed
    2018-05-16 15:06:49.213 Mailbox light level: 17.0
    2018-05-16 15:13:51.508 Mailbox light level: 23.0

Notes:
  1. There are continual small variations in light level
  2. I can set the minimum amount of change required for the light sensor to report. In the test above it was set to 8

The challenge
The basic task is to detect a significant rise in light followed by a significant drop within 2 seconds to 2 minutes (the time to deliver letters or a package) and ten send a notification. The means of the notification is not an issue here.
However, this task is made more complex because the background level of brightness changes greatly during the day based on weather and time-of-day. This means that the change detection must be relative and cannot be based on absolute brightness values.
I am open to using any means available within Indigo (except AppleScript, of course). It would be nice to use just built in aspects of Indigo, but scripting is fine as well.

Ideas?

Posted on
Fri May 18, 2018 10:23 am
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Looking for ideas...

[MODERATOR NOTE] moved to a more appropriate forum.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri May 18, 2018 3:26 pm
durosity offline
User avatar
Posts: 4320
Joined: May 10, 2012
Location: Newcastle Upon Tyne, Ye Ol' England.

Re: Looking for ideas...

I’m curious why you chose to use a lux sensor over a contact sensor? I’d have thought that would have been the simpler solution.


Sent from my iPhone using Tapatalk

Computer says no.

Posted on
Sat May 19, 2018 12:53 am
noel1983 offline
Posts: 446
Joined: Oct 17, 2014

Re: Looking for ideas...

I was thinking the same, lux levels aren’t in my experience reported very quickly so two changes in 2 seconds maybe too quick.

Whereas simply having a door/window sensor on the flap tells you it’s been opened. If it’s been opened then surely that’s pretty much certain that someone has put something into the box?


Sent from my iPad using Tapatalk

Posted on
Sat May 19, 2018 1:31 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Looking for ideas...

I chose to try the light detector for a few reasons.

  1. There are actually 2 openings (not clear in the first post, but clearer here:
    Image
    Note the flap, for letters, and then the entire front panel opens for delivering packages and collecting mail.
  2. This means two switches (they could be in series)
  3. It also means having wiring on the opening door... exposed to the animals who deliver our mail and packages
  4. The light sensor (Phidgets 1127) I am using reacts in near real time (see the timing on the observations in my previous post). The frequency of the notifications depends on the change threshold I set, which is currently 8 lux.
  5. I liked the simplicity of the light sensor and wanted to add a little challenge to this project.
Also, as is evident from the test observations, this means of detection does work (I.e. it generates a signal stream that contains clear evidence of an event. The challenge is decoding that signal stream.

Posted on
Sat May 19, 2018 1:33 am
noel1983 offline
Posts: 446
Joined: Oct 17, 2014

Re: Looking for ideas...

Aah cool and fair enough.

Worth noting that there’s no wiring with a door sensor you’d just have the magnet stuck to the opening flap,

Like the ‘added challenge’ bit :) if it’s too easy it’s just not fun!


Sent from my iPhone using Tapatalk

Posted on
Sat May 19, 2018 2:26 am
durosity offline
User avatar
Posts: 4320
Joined: May 10, 2012
Location: Newcastle Upon Tyne, Ye Ol' England.

Re: Looking for ideas...

noel1983 wrote:
if it’s too easy it’s just not fun!


I prefer easy. :lol: :wink:

Computer says no.

Posted on
Sat May 19, 2018 2:56 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Looking for ideas...

noel1983 wrote:
...Worth noting that there’s no wiring with a door sensor you’d just have the magnet stuck to the opening flap, ..
True enough.... but for the fact the mailbox is 60 meters from the house and all metal.. Which equals poor signal propagation for wireless devices. In any case, the mailboxes is near the gate, where I have LAN access and a single-board-computer, so, wiring is easy.

I may well end up with switches or similar. But, I may also try motion detection or a light beam across the opening. The actual best solution would be to mount a false floor on some load sensors. But, that requires a lot of hardware effort and I really wanted to try and do it mostly in software.

Posted on
Sat May 19, 2018 8:51 am
mat offline
Posts: 769
Joined: Nov 25, 2010
Location: Cambridgeshire - UK

Re: Looking for ideas...

I would go with contact sensors. but ...How about a variable updated every 5 minutes to give you the background luminance (only updated within say 5% of previous) then watch for the spike in luminance compared to the variable value.

Late 2018 mini 10.14

Posted on
Sat May 19, 2018 10:57 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Looking for ideas...

mat wrote:
...How about a variable updated every 5 minutes to give you the background luminance (only updated within say 5% of previous) then watch for the spike in luminance compared to the variable value.

Interesting concept. However, there are three issues with this approach. 1) The ambient light level can change significantly in a very short period, like when a cloud passes, though, rather than sample the ambient light level every 5 minutes, I could do it continuously. Then, 2) when the ambient light is low, the brightness increase is also less. But, the real killer is 3) the sensor is inside the mailbox. So, I'd need to mount a second sensor outside (and protect it from the elements). If I need to mount two light sensors, I lose the simplicity of this approach and might as well use two switches in series.

But, the idea of using two sensors for the same thing, one for an ambient measurement and another for a measurement in a controller environment is interesting. I will save that one away.

Thanks.

Posted on
Sat May 19, 2018 11:11 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Looking for ideas...

I think I may have a solution:

First, I moved the sensor to be on the side wall, at the from and directly alongside the flap/slot. Now, when the flap opens the increase in light measured is much greater (since the sensor is not at the back of the mail box). Then, second, I changed the processing on the incoming data from lux (which gave readings in the range of 8-200 with the sensor at the rear of the mailbox) to the raw data from the A-to-D converter: 0-1024. With these two changes the jump from closed to open is unambiguous.

However, I am still interested in the original question, if only for academic purposes. But also for anyone else who has a need to reduce background noise to spot patterns.

And, finally, if anyone else is going to try this. I also tries a sonar distance sensor (LV-MaxSonar-EZ1). On my bench it worked perfectly, showing a clear drop in distance when something passed or was placed in front of the sensor. However, when placed in my all metal mailbox, it went nuts and showed almost no sensitivity to objects placed inside the box. My guess is too much echo in the enclosed space.

The only problem with my approach, as well as switches or any scheme that only detects the opening or insertion of an object is that it is not self resetting. I cannot assume that the second opening is to remove an object. It could be a second delivery. So, I will have to create a simple clear function to reset my control page alert. For that reason, I am still tempted to build a false floor with load cells. But, I am concerned about detecting something as light as a postcard. Probably, in the end, the best way to go is an IR camera with motion and presence detecting image processing. Probably way overkill for this simple project.

Posted on
Sat May 19, 2018 11:51 am
noel1983 offline
Posts: 446
Joined: Oct 17, 2014

Re: Looking for ideas...

One way to detect when you’ve collected the mail would be to automate the lock. (Warning this could be complete overkill!)

So if the ‘lock’ was triggered or opened by you doing something or your presence with an iBeacon for example indigo would know that you’d collected the mail!

Posted on
Sat May 19, 2018 12:41 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Looking for ideas...

noel1983 wrote:
One way to detect when you’ve collected the mail would be to automate the lock. (Warning this could be complete overkill!)

In home automation there is no such thing as overkill (which is very good, otherwise home automation might not exist at all - at least according to my wife)

then noel1983 wrote:
So if the ‘lock’ was triggered or opened by you doing something or your presence with an iBeacon for example indigo would know that you’d collected the mail

Ah, but there is a rub. French mailboxes have a slot (covered by a flap) and a locking door. However, the post office and certain delivery services have a master key. In other words, probably the only person who can't open your mailbox is you, after you lose your key. But the point is, the door may be opened by someone delivering anything larger than can pass through the slot as well as by the mailbox owner. Some mailboxes also have a separate door on the rear allowing the mailbox to be built into a wall. In this case, you could detect the opening of the rear door and use that to clear the mail alert. Unfortunately, my mailbox is freestanding and has no rear door.

OTOH, an iBeacon might work. :D

Posted on
Sat May 19, 2018 12:43 pm
noel1983 offline
Posts: 446
Joined: Oct 17, 2014

Re: Looking for ideas...

Hmm tricky. There’s a ton of ways with a physical button that you’d push to reset but that’s rubbish and requires an action which would be missed or forgotten.

How about a combination of two things

If mailbox door opened AND front door is opened within 2 minutes then mail has been collected

This assumes you always collect the mail on your way into the house.

If there’s something like that you can tie to your routine then that would work.

You could do this through the use of a timer that starts running when mailbox door is opened and a trigger that when front door is opened if mailbox timer running then set variable x etc

Love challenges like this :)


Sent from my iPhone using Tapatalk

Posted on
Sun May 20, 2018 2:27 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Looking for ideas...

noel1983 wrote:
Hmm tricky... ..Love challenges like this :)

Yup. The core problem is my scheme, as well as schemes like switches on the door/flap/slot, are all based on detecting a singular event. Either the actual arrival of mail, I.e. something passing through the slot, or, they detect a surrogate activity, the opening of the mailbox that is assumed to be correlated with the arrival of mail.

In the case of actually detecting something arriving, we know there must be something in the mailbox (unless someone pushed a letter into the slot and then pulled it back,, though we do not have any specific means to determine if it is actually in the box at any one point in time. Detecting opening of the mailbox is even less precise since we don't know if anything was actually deposited.
Also, both the arrival and opening detection methods detect singular events and must be reset by some out of band signaling system... like a reset button.

Clearly, the best way to do this is to detect the presence of an object in the mailbox. The challenge is detecting a small thin object, like a postcard or airmail letter (does anyone used them anymore?). This method also detects the removal of the object and is therefore self-contained. That is, it keeps constant track of the presence, or lack thereof, of mail in the mailbox with no external intervention.

As noted in an earlier post, load cells are well suited for this task. But, the mechanics are complex and likely to be unreliable, especially in an outdoor mailbox exposed to shifts in temperature and humidity. I a now thinking the way to go is to use an IR emitter/sensor attached to the "ceiling" of the mailbox. The presence of anything would change the amount of light reflected fro the floor of the mailbox and should be detectable. I am currently looking for suitable parts. Stay tuned.

Who is online

Users browsing this forum: No registered users and 3 guests