Mechanism

Objective:

The smart shopping trolley is designed to make the shopping much easier. The Smart trolley is equipped with a range of functions to create an interactive shopping experience between the user and the trolley. Supermarket owners have faced problems regarding the trolley. The trolleys are often taken outside the supermarket premises or are not returned to the trolley stack. This project will help trolleys to return back to the stack and also be monitored by the administrative staff. This will reduce the rate of trolley theft and damage. 

There have been continuous advancements in the previous years to make supermarkets more user-friendly. A customer can now check all the available products in the market at the trolley. In this project, IoT is utilized to assist the trolley to guide itself and monitor its location. The main focus of this project is to reduce the waiting time of the customers at the billing area and also to keep track of the position of the trolley. The trolley will act like a robot and will be programmed to return back to the stack of trolley whenever the weight sensor senses the trolley is empty. Customer will initiate the process of shopping by starting the trolley simply by pushing a button. The weight sensor operates only when the shopping is completed which is again marked by the customers by pushing the stop button. The data of the sensors are transferred to the cloud. The trolley web-app will fetch data from the cloud and will run necessary programs. Our system will make the administration aware of the number of trolleys available to customers for shopping, the number of trolleys in use, the location of trolleys and also will help in their arrangement without any additional staff. 

Platform:

Adafruit IO

Adafruit IO is a cloud platform that allows you to connect your prototype to the internet. This also allows you to store data in the cloud and was initially meant for storing and retrieving data. Adafruit IO can handle and visualize multiple feeds of data. Adafruit IO also allows to display data online in real time, make the project internet connected, connected motors, read sensor data, connect devices to web services like Twitter, RSS feeds etc. Adafruit has a dashboard that allows you to chart, graph and display the data. Moreover, data from dashboards can be viewed from anywhere in the world. 


MQTT protocol

The protocol uses a publish/ subscribe architecture in contrast to HTTP with its request/ response paradigm. The central communication point in the MQTT broker, it is in charge of dispatching all messages between the receiver and sender. The clients do not know each other but they communicate over a topic. The architecture enables highly scalable solutions without dependencies between data producers and data consumers.

Arduino coding

Arduino code is written in C++ with a special addition of functions and methods, which is also a human readable programming language. The codes that are uploaded in Arduino and ESP8266 are written in C++.


Create data feeds:

Create an account in Adafruit IO. The current dashboard will be visible to you. Click the feed's link on the left-hand side of the screen to navigate the feed list. Click on the actions menu on the left-hand side of the screen. next. Select the create a new feed option from the menu. Enter the name and description on the dialog box that appears and then click the create feed button. The feed channel is created.
Fig 1: Feed showing the load cell output.

Fig 2: I/O dashboard showing all the feeds.

IFTTT:

IFTTT stands for If This Then That, is a free web-based service which can be used to create connections or conditional statements called as Applets. In addition to the web-based service, IFTTT also works in an iOS and Android. This function can be used to send emails or text based on the condition on the coding.
IFTTT is used in this project to notify, through an email, when the trolley is empty or when it is returning back to its stack. This function will help to know if a trolley is available to be used or is busy. This will also help to know the activity the trolley is undergoing, in real time.
Fig 3: Applet for notifying weight through email.


System Architecture:


Fig 4: System architecture for the entire project.

Material used


1.  Robot car

2.  ESP8266
3.  INA125P
4.  Arduino UNO
5.  IR sensors
6.  DC motors
7.  Servo motor
8.  Load cell
9.  Wheels
10. Two 3.7V batteries
11. Connecting wires


Circuit connections:

Motor wire Connecting:
UNO R3 Board A0 Connect to Robot Car Baseboard M6;
UNO R3 Board A1 Connect to Robot Car Baseboard M5;
UNO R3 Board A2 Connect to Robot Car Baseboard M4;
UNO R3 Board A3 Connect to Robot Car Baseboard M3;
UNO R3 Board A4 Connect to Robot Car Baseboard M2;
UNO R3 Board A5 Connect to Robot Car Baseboard M1.

Power wire connecting:
UNO R3 Board 5V Connect to Robot Car Baseboard 5V;
UNO R3 Board GND Connect to Robot Car Baseboard GND.
Tracking signal wire connecting:
UNO R3 Board Pin 6 Connect to Robot Car Baseboard H1;
UNO R3 Board Pin 7 Connect to Robot Car Baseboard H2.

Load cell with INA12P:


Fig 5: Circuit connection between load cell and INA12P amplifier.


Line following robot:


Video 1: Line following robot tracking on a circular path.


Video: 



Video 2: Demonstration of smart trolley



Video 3: Demonstrating working of smart trolley


Cloud Data: 


The data from the sensors were updated to the cloud storage at real time. IFTTT was used to recieve notification stating the weight and status of the trolley. the dashboard in the Adafruit I/O showed the weight of troleey on real time. status of the trolley was marked by circular color segment. green represented trolley in use and red represented trolley vacant.



Fig 6: Mail notification about trolley update from IFTTT.

Fig 7: Data from Adaruit I/O cloud displaying the weight readings and the status of the trolley.


Encountered Problems:

Although the project was successful, we encountered several problems during the development of the project. One of them was selecting a suitable cloud platforms. At first, Microsoft Azure was selected and a website was created to collect the data from the sensors and store in the cloud. However Microsoft Azure couldn't recognize the library files used in the codes. Then we changed our cloud platform to IBM cloud and the library files for HX711 amplifier was not recognized by the IBM dashboard. Finally, we chose Adafruit I/O cloud platform to run the codes, and the codes successfully compiled.
Secondly, there was a problem regarding the weight amplifier HX711 that was used along with the sensor. After several trials, we were unable to receive the weight sensors data, so we changed the amplifier and chose INA12P instead. We compiled different codes compatible with INA125P and we received the weight sensors data successfully. 

Future Scope:

The smart shopping trolley has a high beneficiary future aspect. The project can be modified for better performance in several categories. The trolley can communicate with the cloud platform and mention the activity it is performing, like moving to the stack, or stooped due to the presence of an obstacle. This will enable the administrative staff to know about the function of the trolley. The trolley can be modified so that it can detect obstacles and behave accordingly with the presence of obstacles without disturbing them. 
The smart shopping trolley can be equipped with RFID  sensors so that the trolley can be tracked more efficiently by the administrative staff. RFID sensors and tags can be used to detect the product chosen by the customer. This will help to analyze the shopping activities of customers and gather data about people thoughts on various products. RFID sensors will also enable the trolley to calculate the bill itself. this will save customers time from standing in the queue while checking out. 

Furthermore, the trolley can be controlled from the dashboard by the administrative staff by using two-way communication of the cloud platform. In this project only one-way communication, which means the dashboard could receive information from the sensors through ESP8266.


Codes:

Weight sensor code::

THE CODE IS HERE:

#include "config.h"
int weightPin = 4; #define loadCell A0 // Arduino analog pin to read #define LoadSamples 20 //define the samples to average readings int samples[LoadSamples]; // LOAD CELL CALIBRATION static long loadLow = 0; // measured low end load in grammes from good scales static int analogLow = 10; // [82] analog reading from load cell for low end test load // High end of the test load values static long loadHigh = 900; // [5091] measured high end load in grammes from good scales static int analogHigh = 5000; // [1022] analog reading from load cell for high end test load AdafruitIO_Feed *TrolleyWeight_feed = io.feed("TrolleyWeight"); void setup() { Serial.begin(115200); pinMode(weightPin, OUTPUT); // wait for serial monitor to open while(! Serial); // connect to io.adafruit.com Serial.print("Connecting to Adafruit IO"); io.connect(); // set up message handlers // wait for a connection while(io.status() < AIO_CONNECTED) { Serial.print("."); delay(500); } // we are connected Serial.println(); Serial.println(io.statusText()); // attach the servo object to pin 16 } void loop() { int i; float LoadAverage; for(i=0;i<LoadSamples;i++) { samples[i] = analogRead(loadCell); } LoadAverage=0; for(i=0;i<LoadSamples;i++) { LoadAverage += samples[i]; } LoadAverage/=LoadSamples; // Convert analog value to load in grams int loadGrams = map(LoadAverage, analogLow, analogHigh, loadLow, loadHigh); int xy = loadGrams;//-(loadGrams*0.5/100); /* //debug option Serial.print("Analog pin value: "); Serial.println(analogValue); Serial.print("Smoothed analog value: "); Serial.println(analogSamplesLoadAverage);*/ Serial.print("Scale load: "); Serial.print(xy); Serial.println(" grammes "); if (xy>=5){ digitalWrite(weightPin,LOW); } else{ digitalWrite(weightPin,HIGH); } TrolleyWeight_feed->save(xy); delay(2000); }



Line following robot
YOUR CODE IS HERE______
#include <elapsedMillis.h>







/******** Smart Car tracking_black_trail experiment *********  
*  Hardware platform: Arduino UNO R3 Development Board, Smart Robot Car
*  Development environment: Arduino 1.6.5



Connect wries for this experiment (connect by DuPont line):
Motor drive signal line: UNO R3 Development Board Pin A0 connect Smart Robot Car M6
                         UNO R3 Development Board Pin A1 connect Smart Robot Car M5
                         UNO R3 Development Board Pin A2 connect Smart Robot Car M4
                         UNO R3 Development Board Pin A3 connect Smart Robot Car M3
                         UNO R3 Development Board Pin A4 connect Smart Robot Car M2
                         UNO R3 Development Board Pin A5 connect Smart Robot Car M1   
                        
Buzzer Signal line: UNO R3 development board pin 13 connect Smart Robot Car Buzzer Control interface.


tracking singal lineUNO R3 development board pin 6 connect Smart Robot Car H1;
                      UNO R3 development board pin 7 connect Smart Robot Car H2;

Power Cord and Ground: UNO R3 development board 5V connect Smart Robot Car 5V
                       UNO R3 development board GND connect Smart Robot Car GND     
***********************/
#include <MsTimer2.h>




/*********************** Smart Car tracking_black_trail experiment **********************
* Hardware platform: Arduino UNO R3 Development Board, Smart Robot Car
* Development environment: Arduino 1.6.5



Connect wries for this experiment (connect by DuPont line):
Motor drive signal line: UNO R3 Development Board Pin A0 connect Smart Robot Car M6
UNO R3 Development Board Pin A1 connect Smart Robot Car M5
UNO R3 Development Board Pin A2 connect Smart Robot Car M4
UNO R3 Development Board Pin A3 connect Smart Robot Car M3
UNO R3 Development Board Pin A4 connect Smart Robot Car M2
UNO R3 Development Board Pin A5 connect Smart Robot Car M1

Buzzer Signal line: UNO R3 development board pin 13 connect Smart Robot Car Buzzer Control interface.


tracking singal line:UNO R3 development board pin 6 connect Smart Robot Car H1;
UNO R3 development board pin 7 connect Smart Robot Car H2;

Power Cord and Ground: UNO R3 development board 5V connect Smart Robot Car 5V
UNO R3 development board GND connect Smart Robot Car GND
*******************************************************************/
#include <MsTimer2.h> //Need to use MsTimer2 library files

//引脚定义:
int En1 = A0; //L293D EN1 Correspond Development Board R3 pin A0
int In1 = A1; //L293D IN1 Correspond Development Board R3 pin A1
int In2 = A2; //L293D IN2 Correspond Development Board R3 pin A2

int In4 = A3; //L293D IN4 Correspond Development Board R3 pin A3
int In3 = A4; //L293D IN3 Correspond Development Board R3 pin A4
int En2 = A5; //L293D EN2 Correspond Development Board R3 pin A5

int Beep = 13; //Buzzer Signal line Correspond Development Board R3 pin 13

int Left = 6; //Left sensor
int Right = 7; //Right sensor
int buttonState=0;

unsigned char pwmval_left = 0; //Variable definitions
unsigned char pwmval_right = 0;

unsigned char pwmval_left_init = 20; //Left Electric Motor Duty Ratio Adjustment, adjust between 0 to 20
unsigned char pwmval_right_init = 20; //Right Electric Motor Duty Ratio Adjustment, adjust between 0 to 20

unsigned char right_pwm = 1; //Right Electric Motor PWM switch, when value is 1, turn on
unsigned char left_pwm = 1; //left Electric Motor PWM switch, when value is 1, turn on



void forward(void) //Car forward control function
{
digitalWrite(In1,LOW); //Control left wheel forward
digitalWrite(In2,HIGH);

digitalWrite(In4,LOW); //Control right wheel forward
digitalWrite(In3,HIGH);
}

void left_turn(void) //Smart Robot Car turn left
{
digitalWrite(In1,LOW);
digitalWrite(In2,HIGH);

digitalWrite(In3,LOW);
digitalWrite(In4,LOW);
}

void right_turn(void) //Smart Robot Car turn right
{
digitalWrite(In1,LOW);
digitalWrite(In2,LOW);

digitalWrite(In3,HIGH);
digitalWrite(In4,LOW);
}

void stop_car(void) //Stop
{
digitalWrite(In1,LOW);
digitalWrite(In2,LOW);

digitalWrite(In3,LOW);
digitalWrite(In4,LOW);
}

void back(void) //Backwards
{
MsTimer2::stop(); //times off
pwmval_right = 0;
pwmval_left = 0;
pwmval_left_init = 20;
pwmval_right_init = 20;
MsTimer2::start(); //times start

digitalWrite(In1,HIGH);
digitalWrite(In2,LOW);

digitalWrite(In3,LOW);
digitalWrite(In4,HIGH);
}



void left_moto(void) //The speed of left wheel control function
{
if(left_pwm)
{
if(pwmval_left <= pwmval_left_init)
{digitalWrite(En1,HIGH);}
else
{digitalWrite(En1,LOW);}
if(pwmval_left >= 20)
{pwmval_left = 0;}
}
else
{digitalWrite(En1,LOW);}
}

void right_moto(void) //The speed of right wheel control function
{
if(right_pwm)
{
if(pwmval_right <= pwmval_right_init)
{digitalWrite(En2,HIGH);}
else if(pwmval_right > pwmval_right_init)
{digitalWrite(En2,LOW);}
if(pwmval_right >= 20)
{pwmval_right = 0;}
}
else
{digitalWrite(En2,LOW);}
}

void T2Int_Process(void) //T2 interrupt process function
{
pwmval_left = pwmval_left + 1;
pwmval_right = pwmval_right + 1;

left_moto();
right_moto();
}

void Tracking_Process(void) //tracking process function
{
if((digitalRead(Left)==LOW)&&(digitalRead(Right)==LOW))
{forward();}
else if((digitalRead(Left)==HIGH)&&(digitalRead(Right)==HIGH))
{forward();}
else
{
if((digitalRead(Left)==HIGH)&&(digitalRead(Right)==LOW))
{
delay(2);
if((digitalRead(Left)==HIGH)&&(digitalRead(Right)==LOW))
{left_turn();}
}
if((digitalRead(Right)==HIGH)&&(digitalRead(Left)==LOW))
{
delay(2);
if((digitalRead(Right)==HIGH)&&(digitalRead(Left)==LOW))
{right_turn();}
}
}
}
void Obstacle_Avoidance_Process(void) // Infrared obstruction process function
{
if((digitalRead(Left)==HIGH)&&(digitalRead(Right)==HIGH))
{stop_car();}
if((digitalRead(Left)==HIGH)&&(digitalRead(Right)==LOW))
{left_turn();}
if((digitalRead(Right)==HIGH)&&(digitalRead(Left)==LOW))
{right_turn();}
if((digitalRead(Right)==LOW)&&(digitalRead(Left)==LOW))
{forward();}
}


void loop() {
// put your main code here, to run repeatedly:
buttonState=digitalRead(Beep);
if(buttonState==HIGH){
Tracking_Process();
}
else

stop_car();
}

void setup() {
// put your setup code here, to run once:

pinMode(En1,OUTPUT); //Set the pin to output
pinMode(In1,OUTPUT); //Set the pin to output
pinMode(In2,OUTPUT); //Set the pin to output
pinMode(En2,OUTPUT); //Set the pin to output
pinMode(In3,OUTPUT); //Set the pin to output
pinMode(In4,OUTPUT); //Set the pin to output

pinMode(Beep,INPUT); //Set the pin to output

pinMode(Left,INPUT_PULLUP); //Set the pin to input and set be internal pull-up
pinMode(Right,INPUT_PULLUP); //Set the pin to input and set be internal pull-up

//control the buzzer OFF
forward(); //Smart Robot Car move forward


MsTimer2::set(1,T2Int_Process); //Timer 2 library functions,transfer T0Int_Process() function once in every millisecond
MsTimer2::start();
}

No comments:

Post a Comment

Future scope

The smart shopping trolley has a high beneficiary future aspect. the project can be modified for better performance in several categorie...