Introduction: Smart B.A.L (connected Mailbox)

You are tired of checking every time your mailbox while there is nothing inside. You want to know if you receive your mail or a parcel during a trip.
So the connected mailbox is for you. It will notify you if the postman has deposited a mail or a parcel, directly on your smartphone by means of an email, thanks to the latest technologies LORAWAN made in France. We are going step by step how to design a prototype throughout this instructable.

Step 1: Equipement

Languages used: C/C++


Basic knowledge in digital electronics.

Hardware requirements:

Grove - 3-Axis Digital Gyro : http://wiki.seeedstudio.com/Grove-3-Axis_Digital_...

Kit sigfox module with antenna : https://yadom.fr/carte-breakout-sfm10r1.html

Random push button (choose what you want).

Nucleo F030R8 : https://fr.farnell.com/stmicroelectronics/nucleo-f...

Software requirements:

A computer with a good browser to work with Mbed compiler.


Step 2: Prepare Your Device

First, we need to connect all of the modules to the chip.

Power the Sigfox module and the gyroscope with 3.3voltage!
Then connect the UART wires to the Sigfox module (PA_9, PA_10) and the I2C wires to the gyroscope( PB_10; PB_11). Connect the button with PB_3 pins. when finished, Compile the code below.

You can test the prototype by placing the gyro on a mailbox and get some values related to the movement and thus check whether it is a package that has been deposited or a letter.

#include "mbed.h" <br>#include "ITG3200.h" 
 
//------------------------------------ 
// Hyperterminal configuration 
// 9600 bauds, 8-bit data, no parity 
//------------------------------------ 
 
Serial pc(SERIAL_TX, SERIAL_RX); 
Serial sigfox(PA_9,PA_10,NULL,9600); 
InterruptIn bouton(PB_3); 
ITG3200 gyro(PB_11, PB_10); 
volatile int app; 
int facteur=0; 
Timer t; 
AnalogIn batterie(A3); 
AnalogIn ref_batt(ADC_VREF); 
 
 
void lol() 
{ 
    pc.printf("appui\r\n"); 
    app=1; 
} 
/* 
void batt() 
{ 
    pc.printf("batterie faible !\r\n"); 
}*/ 
     
int main() 
{ 
    int x, y, z; 
    //Set highest bandwidth. 
    gyro.setLpBandwidth(LPFBW_42HZ); 
    char buffer[20]; 
    bouton.fall(&lol); 
    bouton.mode(PullDown); 
    //batterie_faible.rise(&batt); 
    //batterie_faible.mode(PullDown); 
    pc.printf("commencement\r\n"); 
    while(1) { 
     
        app=0; 
        x = gyro.getGyroX(); 
        y = gyro.getGyroY(); 
        z = gyro.getGyroZ(); 
         
        if(x > 5000) 
        { 
            t.start(); 
            pc.printf("debut minute\r\n");  
            while(t.read() <10); 
            pc.printf("fin temps\r\n"); 
            //pc.printf("app= %d\r\n",app); 
            if(app == 0) 
            { 
                sigfox.printf("AT$SF=636f757272696572\r\n");  //colis : 636f6c69732e202020 
                sigfox.scanf("%s",buffer); 
                pc.printf("%s\r\n",buffer); 
            } 
            pc.printf("fin if\r\n"); 
            t.stop(); 
            t.reset(); 
        } 
        /* 
        if( batterie.read() <= (2.8*ref_batt.read()/1.23) ) 
            pc.printf("batterie faible\r\n"); 
         
         
         
        sigfox.printf("AT$SF=636f757272696572\r\n");  //colis : 636f6c69732e202020 
        wait(10); 
        sigfox.printf("AT$P=1"); 
        wait(10); 
        sigfox.printf("AT$P=0\r\n");*/ 
         
 
         
         
         
    } 
}

Step 3: Assembly PCB

The previous prototype is too big to put it on mailbox. Here some Gerber files to print your circuit and assembly your component.

Step 4: Back-end Website

We have based our backend architecture on IBM Cloud (IBM IoT Watson Platform and NodeRED) and on API REST requests. The IBM Cloud was used to manage the communication between different parts of our system. As you can see on our NodeRED flow, we control all requests received from the Sigfox API (that sends the messages from our device) and from our Wix website (for registering a new device). Also, the cloud is responsible for sending the notification email to the client and for registering a new client whose informations will be stored in our cloud-based database (MongoDB). Thus, NodeRED basically manages the API REST requests and database queries (INSERT and SELECT) to assure that the right notification will be sent to the right client on time.