"Alexa Where is my car" or may be "Alexa what is location of my car" as title it self suggest that you are asking about the latest location of your car. So here I am sharing build guide of the IoT solution around Amazon Alexa Voice skill kit integrated with AWS Lambda as well as EC2 as software and Arduino MEGA with GSM+GPS as Hardware. Propose solution have a capabilities to track the thing which you are using most of the time in a day and for that I am choosing car to start with and will move forward with many other thing which will/is used by human in their daily life.
"Alexa Where is my car" project will help you to track the latest location of your car with full address by just asking it without any human to machine physical interaction. "Alexa Where is my car" is also help you to track your car if it is stole and you can track it in real time with out touching any device.
"Alexa Where is my car" is having Arduino MEGA as its main hardware controller which use GPS as its location collector and GSM as communication medium, AWS EC2 as Web-server+Database and inter-mediator for AWS Lambda + Alexa Skill kit.
Block Diagram:As you can see from block diagram that we have various thing which runs on cloud as well as we have a 2 devices. From which one of the device i.e. Alexa which will be with any person who are using this system. And another one which is the device which i made is GSM -> GPS tracker which will be place do different vehicle. So lets have a look into the system and on later part will go through its setup steps.
So we have a Tracker device which have mainly three main thing which are GSM module, GPS module and the controller (in our case it is Arduino Mega 2560) so arduino have a code which will fetch the data from the GPS and save its Latitude and Longitude value into local variable and after that will turn on gsm after that will turn on its GPRS (i.e. we are using 2G module) and make a URL in which the data of the latitude and longitude will be putted and it will call so those data will go into web server where PHP script will collect it and using those latitude & longitude data it will collect the formatted address from Google maps API and save those data into MySQL database. (Note: Device will push data into data base every 10 Second using above mention flow) Now user can ask Alexa any time about its location using "Alexa, What is location of my car" sentence and will get answare in complete address form Alexa enable Device in Speech form. And still if user will not able to identify location of his/her car from address user will get its last location point in google map so he/can see it in his/her mobile or laptop.
You can check mine using http://alexavehicletracker.tk/ link.
- Open https://aws.amazon.com/ and do signis/signup.
- Search Lambda and select it.
- Select US East (N. Virginia) form upper right corner.
- Press the create function button from right upper side.
- Press the blueprints and search alexa.
- Select the alexa-skills-kit-color-expert-python from search result.
- Give a function name and select the "Create s new custom role" under role and new window will open.
- In that new window select create a new IAM role with tag name IAM role.
- and give a name to it and press allow button.
- now under role section it will automatically change to choose an existing role and under than you get a drop down menu select the name which you give under IAM role name.
- open https://developer.amazon.com/home.html and sing in from your account.
- Select Alexa from a menu.
- Press Get started under Alexa skills kit.
- Go to Add a new skill.
- Give a name to your skill which will be displayed further.
- Give name under Invocation Name which will be use to activate the skill and for that user need to speak like "Alexa, open your_invocation name here" and hit save button and you will get next button on your right to move further.
{
"intents": [
{
"intent": "yourvariablename1",
"slots": [
"name": "yourvariablename2",
"type": "yourvariablename3"
}
},
{
"intent": "yourvariablename4"
},
{
"intent": "AMAZON.HelpIntent"
}
]
}
- Give name to Custom slot types -> Enter Type under this section which you define at "type" (i.e.
yourvariablename3
)
on above code and give the phrases under Custom slot types -> Enter Values.
- Now press add button just under Custom slot types -> Enter Values.
- Under Sample utterance give the sentence which user may speak to get answare of your question or thing. and make sure you put the
yourvariablename4
name before each and every sentence.
- Hit the next button so you will get info on page and from that page select and copy your skill id which is written under your skill name.
- Paste it to the Lambda management console under Alexa Skill kit -> skill id.
- Press create function on Lambda Management Console page.
- Once it is created you will get new information on page and from which you need to copy the arn no. from top right corner from of the lambda console page.
- Go to Amazon Developer console and select the AWS Lambda arn at end point type.
- Paste the arn no. at default.
- Select yes into the geographical end point under that north america and past the arn no. under that also.
- Press the next button.
- Find Service Simulator and enter any one of the utterance you fill during Sample utterance. this time only the sentence.
- Now on lambda console press on function on left upper corner and you will get a list of your function now press on the name and you will get the function code.
- by doing change on this code you can modify the thing and other thing. This code is in python and if you want to write it down in other lenguage you can use any one from the give list on top of coding area.
Note: I use node.js code insted of python. and make sure your file name must be index.your_lenguage_extenstion.
You can test your code from to of the simulator which are on alexa skill kit page console or from echosim.io or from alexa devices.
AWS EC2 Setup & Route 53:- Open AWS console.
- Search EC2 and select it.
- Press Launch Instance.
- Find the server of your choice and press the select . "Here for this guide we are going with Ubuntu Server 16.04 LTS".
- Select the configuration according to your project requirement and here i use free one for this competition.
- Press the review and launch button.
- press launch button.
- Select a new key pare and give name of its file.
- Press on download key pair.
- download it and keep it with you on secure location.
- And press the launch instance button.
- go to view instance.
- wait upto five minute to setting it up. once you will get 2 green colored correct arrow on status checks column it will ready to use also note down the IPv4 public ip.
- Once done go to last column i.e. "Security Groups" and press on launch-wizard-some_number or launch_wixard.
- New info page will appear and from that go to inbound.
- under that you will get a edit button press on it.
- press add a rule button.
- select HTTP under type, enter 80 on port range and hit save button.
- Go to Elastic IPs and from that page hit allocate new address.
- Hit the allocate button.
- add hurrah you got a new public IP from which you will access your web page. Note down this IP address.
- hit the close button.
- select the newly given IP and from top go to actions and select the associate address.
- Select your instance from the drop down.
- press the associate button after processing get a close button press it
- go to AWS home page and search Route 53.
- click on hosted zone or create hosted zone.
- get new info page on right side enter domain name and press create.
- press on create record set and you will get info on your right.
- enter the elastic IP which you noted down on the value field and press crate button.
- press on create record set and you will get info on your right.
- enter www on name field and on value field enter the elastic IP and press the create button.
- Now note down the name server from column having value name and the type column have NS.
- now go to domain name provier and enter those foure name server data and save it so that domain name will point to your AWS EC2 server.
now see this video on how to ssh to EC2 server using mobaxterm software. you can use any of the ssh software but make sure you know how to use it. Make sure username is ubuntu.
Setup step for Apache 2, MySQL, PHP and phpmyadmin:Enter the below command one by one and your server setup is done
when ever you find vim command make sure before editing the file you need to press i so you will get into insert mode which will be shown on your ssh screen left bottom corner and once done and to save it and get exit press the esc button the write :wq for save and exit and press enter.
Apache 2
$ sudo apt-get update -y
$ sudo apt-get upgrade -y
$ sudo spt-get install apache2
$ sudo vim /etc/apache2/apache2.conf (enter ServerName server_domain_or_IP at bottom of your file)
$ sudo apache2ctl configtest (output must be ok)
$ sudo systemctl restart apache2
to check apache is working or not just open your browser and type your elastic IP address or your domain name.
MySQL
$ sudo apt-get install mysql-server
It will ask you the password 2 time enter it and press enter and wait until process end.
PHP
$ sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql
phpmyadmin
$ sudo apt-get install phpmyadmin
once you hit enter it do some process and will give one color screen. once it will appear on your screen press space bar and after that press enter. it will ask for password and this will help you to login to MySQL data base GUI.
open your browser and enter yourdomainname.com/phpmyadmin or ipaddress/pphpmyadmin
Please refer this if you found any trouble or need in details steps to set it up.
Once you done with setup one the the browser and enter
yourdomainname.com/phpmyadmin or yourip/phpmyadmin
now make a database with choice of your name and inside that create a table using below code
CREATE TABLE name of name_of_your_table
(
id INT AUTO_INCREMENT PRIMARY KEY,
lat TEXT,
lng TEXT,
address TEXT
)
Note You need to enter your table name at name_of_your_table in each php script and modify it.
Library for Arduino:TInyGSM: https://github.com/vshymanskyy/TinyGSM.git
TinyGPS: https://github.com/mikalhart/TinyGPS.git
Note:
- On each .php file, .js file and in .ino file you need to modify few thing as per your setup once you change it it will your for your project.
- upload all .php file into aws ec2 server under mention directory $ /var/www/html to go into this location open ssh and type $ cd /var/www/html
- Upload .ino file into your arduino mega2560 board.
{
"intents": [
{
"intent": "Location",
"slots": [
{
"name": "Type",
"type": "TYPE_OF_VEHICLE"
}
]
},
{
"intent": "GetLocation"
},
{
"intent": "AMAZON.HelpIntent"
}
]
}
Custom Slot TypesTYPE_OF_VEHICLE in Enter Type
car
bike
scooter
bicycle
truck
boat
Sample Utterances (used by me)Location what is location of my {Type}
GetLocation what is location of my
GetLocation what's location of my
GetLocation location of my
GetLocation location of
GetLocation locate my
GetLocation locate
GetLocation trace my
GetLocation trace
GetLocation get the location of my
GetLocation get location of my
GetLocation get location of
GetLocation where is my
Future Plan:As a project to product life cycle will need to take this project to the next level by making it more compact and more efficient . Also will make it more better so this will setup into any of the vehicle and you can track it from your home office?
Also want to fit it into public transport like city bus, train, office bus, school bus (i.e. any public transport) so that any one who are using amazon Alexa can ask to it by its type or number so he/she will get its exact location and will arrange the thing properly so he/she can drop their child to pickup point or can get the location of his/her bus without touching the phone which will save their time so that they can catch it. Also when child's drop time is there he/she can track the bus so he/she can arrange the pickup schedule of his/her child. Also the advantage of this system is you can track it without touching any mobile it doesn't mean that you can't get the location on map. you can track it current location (currently available) but he she can apply filter so that they will get the ping point on map on the route where his/her vehicle or other public transport. This is also work as anti theft tracker system so you do not worry about your car you can trace it any time.
Goal: Will reduce the size of hardware, Make hardware user friendly so that global as well as regional sim card can be use to give a world wide connectivity, make different filter for personal vehicle as well as public vehicle, a separate app with Alexa simulator so any one can access it without physical device, Single platform to integrate tracker hardware as well as Alexa so that the use case can be expend as much as you can. Also capture other important data like car fuel status, engine life and many more so that you can prevent some important damage before it happens and those all will get through Alexa also.
Comments