During our last year of engineering school we designed a connected wallet (named Long Life). The principle is simple: when the wallet is far from you (it is lost) you will see your position (the position of the smartphone) and the position of the wallet on the application. With this product you will never lose your wallet !
Here is the overall diagram:
Figure 1 - Architecture
When the wallet is at a distance of 100 meters then we lose the bluetooth connection with the smartphone. This loss of connection will trigger the sending of a message, containing the position of the wallet, on the Sigfox network. This message will be directed by a callback on a cloud using a POST method(address: /longlife). On the cloud there will be a database with all customers and their position. On the smartphone side it will be necessary to perform a GET method (address: /recuplonglife). From this one, we recover the position of the wallet that must be placed on the map of the mobile application.
Hardware PartWe need to connect the microcontroller, the GPS module and the Sigfox module. The electronic scheme is described above:
Figure 2 - Hardware Part
AOUT= Analogic Out
DOUT = Digital Out
GND = Ground
The Sigfox module will be powered by the NRF51822 P0_13 pin and the Grove GPS will be powered by the P0_19 pin. Les deux modules sont connectés à la même liaison série UART. Ils seront allumés chacun leur tour lorsque l'on aura besoin d'un module.
FirmwarePart
So we chose the microcontroller: nRF51822. This microcontroller is programmed with MBed Compiler (https://os.mbed.com/handbook/mbed-Compiler). You will need to register and add the card.Here's how to do it:
1) Go to this link: https://os.mbed.com/platforms/Nordic-nRF51822/
2) On the right side you will find:
Click on "Add to your Mbed Compiler".
3) At the top of the page you will have:
Click on "Compiler".
4) A window will open :
Just click on "New" then choose the NRF51822 card and you can start from the example of SimpleChat Bluetooth that can be controlled by a mobile application.We will connect the wallet to the application via Bluetooth to ensure the proximity of the 2 devices.
When disconnecting, we will first retrieve the necessary GPS frame by feeding the GPS groove, driven by a DigitalOut:
DigitalOut Alim_GPS(P0_19);The GPS sends a frame of this type:
$GPGGA, 144444.00, 4849.67013, N,00459.18936, E, 1, 07, 1.27, 140.6, M, 46.7, M,, *
We store this frame in a buffer and we will turn off the module again.
We will then cut this frame to recover only the longitude and latitude, which we will then convert from decimal degrees to radial degrees and then multiply by 10000 to convert to an integer. We now feed the Sigfox module and the serial link sends the Sigfox message.
In order to send the portfolio details on the Sigfox network we use the P0_9 and P0_11 PINS which correspond to the PIN RX and TX of our microcontroller nRF51822.
Here is the function that allows us to do that:
void sigfox_pos() {
//On alimente le module
Alim_Sigfox.write(3.3/5);
// char pos[]= "064036.289,4851.2988,N,00217.4020"; Exemple de trame reçu
unsigned char* pos =trame_gps();
char longitudeH[3];
char longitudeM[3];
char longitudeS[5];
char latitudeH[3];
char latitudeM[3];
char latitudeS[5];
int i;
for(i=0 ; i < 2 ; i++){
longitudeH[i] = pos[i+11];
latitudeH[i]= pos[i+23];
longitudeM[i] = pos[i+13];
latitudeM[i]= pos[i+26];
longitudeS[i] = pos[i+16];
latitudeS[i]= pos[i+29];
}
for(i=2 ; i < 4 ; i++){
longitudeS[i] = pos[i+16];
latitudeS[i]= pos[i+29];
}
latitudeH[1]= pos[25];
int longit = atoi(longitudeH);
int latit = atoi(latitudeH);
int longitM = atoi(longitudeM);
int latitM = atoi(latitudeM);
int longitS = atoi(longitudeS);
int latitS = atoi(latitudeS);
// On passe du format décimale au format radiale
float lng = longit + (longitM*1.0 + longitS*1.0/6000)/60;
float lat = latit + latitM*1.0/60 + latitS*1.0/360000;
unsigned int ln=lng*10000;
unsigned int lt=lat*10000;
wait_ms(100);
// On envoie sur Sigfox en Hexadécimale
sigfox.printf("AT$SF=000%x0000%x\r\n",ln,lt );
wait_ms(100);
Alim_Sigfox.write(0);
}
Then just do :
sigfox.printf("AT$SF=000%x0000%x\r\n",ln,lt );
In addition, we feed a buzzer to make a sound to realize that we lost his wallet.
They are called by the following buzzer_on () function:
You will find the whole code in the annexe.
Software PartIn order to have an Android application we used the Android Studio software. On our application there will be a map with our position and position of our wallet. In order to display this map, we will use the Google Map API (https://developers.google.com/maps/documentation/android-sdk/start).
You will need to create an API key, add an object in your XML and manage your Java activity. Here's the tutorial: https://developers.google.com/maps/documentation/android-sdk/start
Figure 3 - Application mobile
CloudPart
For the cloud part we chose Node Red on IBM. Here is the registration link: https://www.ibm.com/cloud-computing/bluemix/fr
There was a problem because the database was not working on Bluemix so we signed up on https://fred.sensetecnic.com/.
This cloud is quite easy to use because it is about nodes (which are functions). For this project, we will need:
- GET node: will be used so that the application has the position of the wallet
- POST node: will serve the wallet to send its position
- Database node: will store user position
- Node of various functions: will create a global variable containing the position
Here is the diagram Node Red:
Figure 3 - Node Red
Figure 4 - Get & Set variable node
And that's it! You now have a connected wallet.
Comments