Project in progress

Walcard, the Connected Wallet

Lose our wallet lead to wasting time and money. Walcard will help you to prevent the loss of your wallet with a history of his use.

  • 292 views
  • 1 comment
  • 3 respects

Components and supplies

Necessary tools and machines

RFID cards
Wallet

Apps and online services

About this project

Who are we ?

We are a team of three students in Engineering School (Polytech Sorbonne) in Paris. We decided, for our IOT project, to solve a problem that concern everybody. Nowadays, everybody has a wallet with money and many cards. The loss of the wallet or one of these cards can cost money and waste time. That's why we have the idea of a connected wallet linked to an application.

What is our project about ?

The wallet has many features :

- Prevent the loss of the wallet. If you move away from your wallet, you will be notified on your smartphone.

- Prevent the obliteration of an important card. If you leave your house or your workplace without one of your card, you will receive a notification on your smartphone.

- Support to the recovery. You will have access to the history of the use of your cards. you will know the time and the location where you used your card.

How it works ?

The entire technology is composed of a wallet which can detect the presence of each card and communicate this information to a database in a cloud. Then, the application on the smartphone (a web application) interfaces with the database.

Hardware

  • Wallet -> Sigfox

The first part is to detect the presence of a card with the RFID module. The Arduino will process the information to send the message to the Sigfox module. The message is in hexadecimal format :

We had the choice to use a GPS to send the location but we choose to use the location given by the Sigfox' backend.

Software

  • Sigfox -> Node-RED

The sent message goes to the backend of Sigfox. This is where we redirected the data to the database on the Cloud. Thanks to callback functions available on Sigfox, we formated a Json message in order to send the two variables of the wallet : the time and location.

We used two IBM services to manage our cloud. Firstly, the ressource "Node-RED" allows us to link the backend of Sigfox and the Web App to the database of the other ressource "Cloudant NoSQL".

  • Node-RED -> Cloudant -> Node-RED

The tool node-RED allowed us to access the NoSQL database cloudant by writing and reading json format data. Therefore we created 2 functions in javascript on node-RED to update the documents by giving them new values or just read the documents to print them on the webapp.

Basically, with the application the user will be able register his wallet, add new cards, modify or deleted existing cards in the different slots. The interface shows in real time the presence of a card through a simple icon (validate).

  • Cloudant

Our database contains two tables. The first one called "Cards" has 4 documents which represent the 4 slots. Within those documents we can find 4 variables in Json format :

- "isOn" : is false when he slot is not configured with a card.

- "name" : the name of the card that the user wrote.

- "isPresent" : goes true when the card is in the slot.

- "isImportant" : goes true or false according to the user input on the Web App.

The second table called "History" has the same 4 documents. There we have :

- "time" : in seconds from where we can the deduce the date and the time.

- "action" : which is the same as "isPresent" but for the history, to know what was the action at this time on the card (put in or put out).

- "lat" : for the latitude,

- "lng" : for the longitude then we can show on a map the last location where the user acted on his card.

  • Node-RED -> Webapp

The communication with the cloud goes through php programs that access specifics documents via a http input node.

We chose to develop a web app which can be readable on any devices. We used HTML5, CSS3 and javascript functions to make the web app interactive. As mentionned before, php programs allow to access the database for either to print its content or send data to it.

Here is our prototype

Demonstration

Code

Code ArduinoC/C++
To control Sigfox and RFID
#include <SoftwareSerial.h>
#include <SeeedRFID.h>

//Pins for serial connections
#define RFID_RX_PIN 10
#define RFID_TX_PIN 11
#define SIGFOX_RX_PIN 0
#define SIGFOX_TX_PIN 1

//Id of your cards
#define CARDA_ID    12994639
#define CARDB_ID    12994652
#define CARDC_ID    12994709
#define CARDD_ID    12994653

//Set up the two connections
SeeedRFID RFID(RFID_RX_PIN, RFID_TX_PIN);
SoftwareSerial SIGFOX(SIGFOX_RX_PIN,SIGFOX_TX_PIN);

unsigned long id;

//Value of isPresent
bool CardA_value;
bool CardB_value;
bool CardC_value;
bool CardD_value;

void setup() {
  pinMode(SIGFOX_RX_PIN, INPUT);
  pinMode(SIGFOX_TX_PIN, OUTPUT);
  Serial.begin(57600);
  CardA_value = false;
  CardB_value = false;
  CardC_value = false;
  CardD_value = false;
  SIGFOX.begin(9600);
}

void loop() { 
    if(RFID.isAvailable()){
        id = RFID.cardNumber();
        Serial.print("RFID card number: ");
        Serial.println(id);
        if(id == CARDA_ID){
            CardA_value = !CardA_value;
            Serial.println(CardA_value);
            if(CardA_value == true){
                SIGFOX.print("AT$SF=0101\r");
            }
            else{
                SIGFOX.print("AT$SF=0100\r");
            }
        }
        if(id == CARDB_ID){
            CardB_value = !CardB_value;
            Serial.println(CardB_value);
            if(CardB_value == true){
                SIGFOX.print("AT$SF=0201\r");
            }
            else{
                SIGFOX.print("AT$SF=0200\r");
            }
        }
        if(id == CARDC_ID){
            CardC_value = !CardC_value;
            Serial.println(CardC_value);
            if(CardC_value == true){
                SIGFOX.print("AT$SF=0301\r");
            }
            else{
                SIGFOX.print("AT$SF=0300\r");
            }
        }
        if(id == CARDD_ID){
            CardD_value = !CardD_value;
            Serial.println(CardD_value);
            if(CardD_value == true){
                SIGFOX.print("AT$SF=0401\r");
            }
            else{
                SIGFOX.print("AT$SF=0400\r");
            }
        }
    }
}
Web app code : index.phpPHP
Main page of the Web app. Here is the part of the program that allows us to acess the database in php.
When we get the data we print them on the page and the user can see directly the content of the database on his device through a simple app. The same function can also send data to the database
 <!-- Php to access to the database -->
 <?php 
  function accessBD(&$IDdocument,&$card) {
  //API URL
    $url = 'https://walcard-node-red.eu-gb.mybluemix.net/Cards';
    //create a new cURL resource
    $ch = curl_init($url);   
    $payload = json_encode($IDdocument);
    //attach encoded JSON string to the POST fields
    curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);

    //set the content type to application/json
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));

    //return response instead of outputting
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    //execute the POST request
    $message = curl_exec($ch);

    //close cURL resource
    curl_close($ch);

    $jsonIterator = new RecursiveIteratorIterator(new RecursiveArrayIterator(json_decode($message, TRUE)), RecursiveIteratorIterator::SELF_FIRST);

    foreach ($jsonIterator as $key => $val) {
      if(is_array($val)) {
      }
      else {
        if($key == $card['name'])
          $card['name'] = $val;
        if($key == $card['isPresent'])
          $card['isPresent'] = $val;
        if($key == $card['isImportant'])
          $card['isImportant'] = $val;
        if($key == $card['isOn'])
          $card['isOn'] = $val;
      }
    }
           
   }  
  ?> 
  
  <!-- Php to read if the card is set up or not -->
  <?php
    if (isset($_GET['isOn1'])) {
      $IDdocument = array(
        '_id' => 'Slot1',
        'isOn' => $_GET['isOn1']);

      //API URL
      $url = 'https://walcard-node-red.eu-gb.mybluemix.net/delete_Card';
      //create a new cURL resource
      $ch = curl_init($url);   
      $payload = json_encode($IDdocument);
      //attach encoded JSON string to the POST fields
      curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);

      //set the content type to application/json
      curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));

      //return response instead of outputting
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

      //execute the POST request
      $message = curl_exec($ch);

      //close cURL resource
      curl_close($ch);
    }
?>

<!-- Php to read infomation about the card -->
 <?php
    $IDdocument = array(
      '_id' => 'Slot2');
      
    $card = array(
      'name' => 'name',
      'isOn' => 'isOn',
      'isImportant' => 'isImportant',
      'isPresent' => 'isPresent');
    
    $img_On = 'src/img/plus.png';

    accessBD($IDdocument,$card);

    if ($card['isOn'] == 1) { 

      echo $card['name']; 
      if ($card['isPresent'] == 0) 
        $img_present = 'src/img/cancel1.png';
      else 
        $img_present = 'src/img/checked1.png'; 

      if ($card['isImportant'] == 0) 
        $img_important = 'src/img/star.png';
      else 
        $img_important = 'src/img/star_full.png';  
  ?>
Web app code : add_card.htmlHTML
The form to add a card
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
    <link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet"> 
    <title>Walcard</title>
    <link rel="stylesheet" href="src/css/reset.css">
    <link rel="stylesheet" href="src/css/style.css">
  </head>
  <body>
    <header>
      <h2 class="logo">
        MyWalcard
      </h2>
      </a>
       <h3 class="accueil">
        <a href="index.php"> <img src="src/img/home.png"> </a>
      </h3>
    </header>
    <h1 class="content">
      <div class="titre">
        Slot 1 : New card
      </div>
                  
      <div class="formulaire">
        <form action="cible1.php" method="post">
          <label for="fname">Card name :</label>
          <input type="text" id="nom_carte" name="nom_carte">
            Important card :
          <label class="container">Yes
            <input type="radio" name="isImportant" value="1">
            <span class="checkmark"></span>
          </label>
          <label class="container">No
            <input type="radio" name="isImportant" value="0">
            <span class="checkmark"></span>
          </label>
          
          <input type="submit" value="Confirm">
        </form>
      </div>
    </h1>
    

    <script src="src/js/script.js"></script>
  </body>
</html>
Web app code : ChangeStar.jsJavaScript
On click, to change the picture of the star if the card is favorite or not
function changeImage1()
{   
    if (document.getElementById("star1").src == "http://localhost/src/img/star.png")
    {
        document.getElementById("star1").src = "http://localhost/src/img/star_full.png";
        $("#result").load("11.php");
    }
    else
    {
        document.getElementById("star1").src = "http://localhost/src/img/star.png";
        $("#result").load("10.php");
    }
    
} 

Schematics

Node-RED functions part1
How to write in the database from Sigfox
Write db from sigfox hrj9h9cuoi
Node-RED functions part2
How to write in the database from the webapp
Write db from webapp 1 rqbev9ll0g
Node-RED functions part3
How to write in the database from the webapp
Write db from webapp 2 yxqtgnfdnz
Node-RED functions part4
How to read the database
Read db from webapp kbv0jsidza
Database
Database organization.
Base de donnees ya2itjomww
Database [Cards]
Cards table of the database
Card1 sllettc5c8
Database [History]
History table of the database
History1 zv8cd6adn3
Database [Cards][Slot1]
Slot 1 of the Cards table
Card2 ggegh71gzj
Hardware design
Schema hardware get9uspwjz
Database [History][Slot1]
Slot 1 of the History table
History2 fm48udfdyk

Comments

Similar projects you might like

WIZnet S2E Deadbolts

Project tutorial by S2E Lock

  • 469 views
  • 2 comments
  • 4 respects

Super-Go: An Industrial IoT bot

Project tutorial by KS

  • 85 views
  • 2 comments
  • 0 respects

High Precision Scale with Arduino

Project showcase by mPelectronic

  • 535 views
  • 3 comments
  • 11 respects

GPS Tracking System for Vehicles

Project showcase by Sustainable Living Lab

  • 1,776 views
  • 0 comments
  • 7 respects

DIY Photogrammetry Turntable

Project showcase by alfiosky4

  • 3,381 views
  • 5 comments
  • 10 respects

Automatic Watering System

Project tutorial by Manson Hau

  • 5,004 views
  • 11 comments
  • 27 respects
Add projectSign up / Login