The overall product discussed here is the collaborative functioning of the Smart Shopping Cart, Mobile/Web App and the Desktop App .
When building the connection between these three entities(i.e. inside the super-market), different protocols were used in order to suit different scenarios.
Below sections will be detailed out on this page.
Briefing of the protocols used
How those protocols are used ?
How it all function ?
- How to connect with the cart?
-What happens during shopping?
-Payment/Exit.
Given below is a summary of the communication requirements between the entities and the protocols used for them.
Communication requirements:-
A registered user (an app user) connecting with the cart using the app
Notifying the main system if a bill error occurred (about the state of the cart)
Sending the calculated bill from the cart,
a) to the super-market server (Desktop App)
b) to the app database (i.e. to be added under recent activities of a shopper registered with the app, to Firestore database)
Protocols used :-
MQTT protocol - Communications between the smart cart, supermarket server and if needed the shopper(app user).
HTTPS protocol - Communications between the smart cart and Firestore.
As mentioned earlier, the smart cart, the mobile app and the desktop app communicate with each other via a broker based on the MQTT protocol. Accordingly, when implementing the software related to those, the following libraries can be used.
Smart Cart:
NodeMCU ESP8266 in it can be programmed with the use of the following libraries/headers (with Arduino) .
For MQTT : WiFiMQTTManager
For HTTPS : ESP8266WiFi.h, WiFiClientSecure.h, ESP8266HTTPClient.h, ESP8266WebServer.h
(See the reference article here)
Mobile/Web App:
This is a Flutter app and the following dependencies can be used.
dependencies : mqtt_client : <version>
(Specifically, by importing mqtt_client/mqtt_client.dart ).
Desktop App:
The following js libraries can be used .
The combinational functionality once a shopper enters the shopping area until they leave after payment can be described under 3 sections.
a)How to connect with the cart?
b)What happens during shopping?
c)Payment/Exit.
The Mobile/Web App carries the feature of connecting with the shopping cart by logging on to the app. By connecting with the cart, the bill payments will be added to the cloud database as the user's shopping activities and also user can pay for multiple carts at one go.
To update the cloud database, it is necessary to know the firebase authentication id (uid) of the shopper. (Refer backend & cloud deployment here)
The following diagram displays how this process happens.
Each of the carts contains a QR code pasted on it which contains the cart Id.
The shopper can log into the Mobile/Web app and use the 'connect with cart ' feature to scan the QR code of the cart ( reads the cart Id ).
Then the App publishes a message which contains firebase authentication id (uid) of the shopper to the broker under the topic of cart Id (eg:- Publish to topic , easycart/brnchx/cart_idx/connect)
The smart cart keeps the uid until the end of the shopping session while the app keeps the cart Id.
The control unit of each of the carts carries a SD card in which a database consisting of product details is stored. When calculating the bill , data from this database is used .
Other than handling stocks, the other major use of the Desktop App is keeping track of the Smart Carts. When a shopper uses a Smart Cart there are possibilities where the bill calculated would be wrong (as concluded by the sensor data) . Also a shopper may have done the payment via the App and such kind of changes would be constantly tracked by the main system.
The Desktop App carries the facility to listen to changes of the states of the cart. To implement this MQTT protocol is used.
Accordingly, the complete communication among the Desktop App and the Smart Carts are carried out using MQTT protocol.
(Diagram depicts Smart Carts inside the shopping area)
Smart Carts would publish messages to the MQTT broker in case of,
-Bill inaccurate according to sensor data (Error)
-Payment done by the user
The shopper can view the bill via the App ( The Cart would publish the current bill on request).
The Desktop App can be used to publish messages to the MQTT broker in case of,
-Product details needed to be updated in the local database of each cart
Payment by the Mobile/Web App:
-When the shopper uses Pay Now feature of the App , a message will be published by the app under a topic related to the cart Id , requesting the bill calculated by the cart.
-Once the payment is accurately done, the bill details would be posted to Firebase Firestore under the shopper's uid, by a HTTPS POST request. and also published to MQTT broker to send the bill to the Desktop App (to keep records) . Now the shopper can/may disconnect from the cart.
-If a cart with an error( eg: inaccurate bill, inadequate payment/unpaid ) tries to exit, the RFID detectors would notify it.( Additional to the QR code, each of the cards comprises of RFID Id)
-Once exited, the cart automatically disconnects from the shopper.(Reset)
Payment without the Mobile/Web App :
-The bill data will be published by the cart and the desktop app would be listening to obtain the bill (Cashier person can scan the cart's QR and request the bill).
-Cashier person can manually set the cart's state to releasable once the payment is done accurately.
-Once exited, the cart automatically disconnects from the shopper.(Reset)