Smart Mailbox

I am ordering some stuff from eBay quite a lot. Sometimes my mailbox barely accommodate all that Chinese packages  🙂 I hate expectation – disappointment loop when I go to check email and hmm empty. So I decided to make simple notification device…

 

My requirements for smart mailbox

  • battery operated
  • upgrade of existing mailbox I have
  • notifications about incoming mail via SMS
  • number of mail inside (circa)
  • notification about mail extraction (I am not only  user of mailbox)
  • storage of history – just for fun

 

The Solution

I have decided make the simplest solution possible. As the sensor, I used two magnetic switches (reed) one for “input” flap one for mailbox door. Magnetic sensors are connected to TD1208 Sigfox modem with custom firmware. Data are processed by Losant platform including SMS notification.

 

 

Smart mailbox construction

 

Because I have only NO type magnetic switches and they are most of the time closed there is current leak thru internal pull-ups (approx. 2 x 50 uA).  It is not critical but device itself consumes less than 2uA. There are more solutions how to deal with it but I decided to go pank and dirty 🙂  I have made a simple filter which pass just short impulse.

Schematics

 

The Code

The code is pretty straightforward. Only parameters to possible tweak:

delayBlock – how long sensor for incoming mail will be disabled after activation

delaySend – after that delay will be notification send, each activation will reset timer

My mail delivery lady puts small packages and mail one by one with delay approx. 5-10s. She is pretty consistent so volume of mail reported is accurate 🙂

 

Temperature sensing for notifying me when something hot is delivered 🙂  Seriously temperature measurement is just residual part of former code but I actually considering to put scheduler into code to send temperature each hour or so. Not for mail temperature measurement but something like general purpose outdoor thermometer. 

 

Frame structure

1B type of mesage – 0x01 incoming, 0x02 extraction

2B temperature + 1000 (to manage negative temperatures easily with uint)

2B battery voltage in mV

2B count of mail in box (reset by extraction)

 

 

Data  Processing and Visualisation

For data processing from my and other devices, I really enjoy to use Losant platform because it is quick, flexible and very capable. Moreover, they provide a free account with a generous amount of devices possible to add.

here is a general guide how to connect Sigfox device into Losant plaform: https://www.losant.com/blog/collect-monitor-visualize-sigfox-data

Step 1. Create New Application in Losant

Navigate to https://www.losant.com, sign in and create new application

Step 2. Losant Webhook

This will be end-point for Sigfox payload. Copy web hook into clipboard.

 

Step 3. Sigfox Backend Settings

 

Payload detail

 

Step 4. Create Device in Losant

Create device with numeric attributes Stat, Ubatt, Temp, MailCount, AvgSnr, Extraction

Create device TAG “sigfox_id” = your sigfox device ID

5. Create Workflow in Losant

Webhook

Add webhook trigger into workflow and select your previously created webhook. Webhook carries all data recieved from Sigfox backend.

 

Parsing of Sigfox data

Sigfox payload is located in data.body.data 

Use function block to create easy parsing of Sigfox data key, some data postprocessing are made here as well. 

all parsed data are returned back into data.body

 

 

Get Losant device ID

Losant use own internal device ID. So Losant API module has to be used to map Sigfox device ID with Losant one via device tag.

Resource and action: Devices:Get

TAG filter: [{ “key” : “sigfox_id”, “value” : “{{data.body.device}}” }]

Device ID will be stored in: data.deviceResponse.result.items.[0].id 

 

 

Conditional to distinguish between incoming mail and extraction

Expression: {{data.body.Stat}} == 2

 

Make a new attribute for extraction

Math module is used for extraction attribute =1 if conditional above is true, =0 if false

 

Create SMS notification

phone number is stored in “globals”, you can edit it in Globals tab (bottom right)

 

Save data into Losant Device

Use module “Device State” to save data into a device. Device id is used from the payload where was stored previously by API module.

ID Path: data.deviceResponse.result.items.[0].id

Fill all attributes:  Stat = {{data.body.Stat}} and so on…

 

Add debug modules

Debug module is a very handy tool. It can be placed anywhere in the workflow. Results are visible in “Debug” tab once workflow is triggered.

 

Dashboard

Making of dashboard in Losant is super easy. Everybody will manage make own, here is mine…

 

 

Last words

Actually, I have made this mailbox long time ago but just recently I moved the application into Losant so I taught it would be nice to share the idea of smart mailbox. I hope that you found some inspiration for your own project. Smart mailbox is not probably the most practical IoT device ever, but I thing it is cool and prove simple IoT rule – everything could be connected 🙂 

David

David is a innovation professional at TelcCo business, open-minded technological enthusiast who would like to taste everything new. In his free time, David loves to make own DIY projects and exploring word of technology. Any ideas presented here are independent and this page is not sponsored by anyone 🙂

More Posts

Follow Me:
Twitter

Leave a Reply

Your email address will not be published. Required fields are marked *