In the United States alone we waste $73 billions every year to look for parking slot. In Germany on an average one driver spends 48 hours every year searching for parking. This is just the waste of gasoline and diesel in terms of money. Now think about the CO2 produced by this extra usage of fuel.
According to ABI research, 8 millions self driving cars will hit the road by 2025.
Keeping Sustainable Development Growth (SDG) in mind and changing model of how tomorrow's auto industry will evolve, we need an efficient, faster and secured way to look for parking spot as well as a mechanism for the cars to make parking transactions without any human interaction. Yes, we need machine to machine money transfer!
Our SolutionWe have built a prototype on IOTA platform. IOTA is a distributed ledger based open source network, which is ideal fit for secured and trusted micro-payments. Unlike other blockchain networks such as Ethereum, there is no transaction fees (mining fees) in IOTA.
Parking spot will be equipped with IOTA wallet, an ultrasonic sensor and camera. Basically a Raspberry Pi with internet access. Each parking device will have a unique device ID which will configured in the code during provisioning of the device. The device will be registered by parking owner by a mobile app providing the unique device ID, desired parking fees in IOTA, geolocation and seed. This data will be stored securely in the cloud backend application. When the device is booted first time after registration process is completed, backend application will generate two IOTA addresses - receiving address and spending address. These two addresses and the seed will be sent to the device and stored.
On the other hand, cars will be equipped with wallet same as parking device. We have used a Raspberry Pi Zero for this because of smaller size. Each of this car devices will be assigned unique device ID as well. Car owner will register the device through a mobile app providing unique device ID, license plate number and seed. Same as parking device, during first boot after registration, backend application will generate two addresses and send to the car device.
Applications and ComponentsSo the entire system has five components or applications.
1. Parking device (A Raspberry Pi with Camera, ultrasonic sensor and traffic LEDs)
2. Car device (A Raspberry Pi Zero )
3. Parking owner mobile app
4. Car owner mobile app
5. Backend service for managing device registration and users
How the Entire System WorksA car owner is looking for a parking. He will open the car owner app on his mobile, find available parking near him and drive to the parking location.
Ultrasonic sensor will sense for any object and capture an image of front of the car including license plate. Device then extract the license plate number from the image. We have used cloud based license plate recognition API https://www.openalpr.com/cloud-api.html. Once license plate is recognized, device makes payment request to the backend service passing it's unique device ID and license plate number. At the same time device will publish a message to Marked Authenticated Messaging (MAM) network in restricted mode with side key as device ID. Device also publish a message to the MQTT server indicating parking is occupied which is updated in realtime on mobile app preventing other car owners to see that as available and waste their fuel.
Backend service validates the request and send a zero value with message transaction to the receiving address of the car device. The message contains the receiving address of the parking device and parking fees. This message is encrypted and can only be decrypted by the target car device ID.
Car device listens for any incoming transaction at the receiving address. Once it receives the transaction, it gets decrypted using the device ID and sends a valued transaction to IOTA tangle for the receiving address of the parking device. At the same time it published a restricted message to MAM for any future audit purpose.
Parking device also listens for any incoming valued transaction at the receiving address. When parking device receives the payment, it updates the balance.
How to Recreate This PrototypeIn addition to the hardware components we listed under "Things", you need to install NodeJS ( 8 or higher), Python3 on your Raspberry Pi.
You can run the backend service on your computer or deploy to any cloud such as AWS or Azure. If you are running your service on you local computer, you need to make sure Raspberry Pi can connect to the backend service. I have used Ngrok to tunnel local port 5000 to the internet. Setup of Ngrok is super simple. All you need to do is download the executable on your computer. Visit https://ngrok.com/ for instructions.
./ngrok http 5000
To keep it simple, you can run the mobile applications on your browser instead of deploying to your phone. You need to install latest version of IONIC framework on your computer. Installation is again super simple with one line npm command. Assuming you have nodejs and npm installed on your computer.
npm install -g ionic
For further study about ionic framework, visit https://ionicframework.com/getting-started
Here is what I have installed on my computer.
Once you have all the software installed on your computer, clone the github repository on your computer.
git clone https://github.com/just4give/smart-parking-iota.git && cd smart-parking-iota
You will see five folders as below.
First, you need to start the backend service. Go inside backend folder and execute below command to install node dependencies.
npm install
Then execute below command to start the nodejs server.
node server.js
Your backend service will start at port 5000.
Now open another terminal window, do not close the current one where your nodejs server is running. Then execute following command. I am assuming you have downloaded ngrok executable to ~/Downloads folder
~/Downloads/ngrok http 5000
You will see a screen like below. Copy the ngrok http url. You need that while running your device software on Raspberry Pi. Please note, this ngrok session will expire in 8 hours and you need to issue the command again. Your url will change. If you need a permanent solution you may consider paid ngrok service or deploy your backend service to cloud.
Now it's time to start the mobile applications. As I said before, I am going to use web version of the app running. Let's run parking owner app first. Open a new terminal window. Do not close first two. Then go inside parking-owner-app folder and execute below commands one after one.
npm install
ionic serve -p 8100
It should open the application on your default browser. Sign up to create new user profile. Then register the parking device. Use PARKING123 as unique device ID. Watch the video to understand the page navigations.
Now, let's start car owner app. Open another terminal window, go inside driver-app and execute below two commands.
npm install
ionic serve -p 8200
Car owner app be launched on your default browser. Create a new user, register the device and make sure to send some test IOTA tokens to the address. I have used https://faucet.devnet.iota.org/
Watch below video for further guidance.
3 down, 2 to go! Next we will deploy code to Raspberry Pis. I assume you already have pre-configured Raspberry Pi with nodejs, npm and python3 installed. If you are new to Raspberry Pi development, there are many great tutorial on internet. You may look at https://www.w3schools.com/nodejs/nodejs_raspberrypi.asp. Raspbian OS comes with both Python 2 and 3 pre-installed.
For parking device, we also need to install aws cli. You may skip step if you don't want to store the image in cloud. You may need to find a way to serve the images over internet or skip that use-case altogether.
If you decide to use AWS S3, then please follow below link to configure aws cli on your raspberry pi.
sudo pip install awscli
aws configure
https://iotbytes.wordpress.com/aws-iot-cli-on-raspberry-pi/
As we are talking about parking device, let's start deploying code there first. Copy entire parking-device folder to home directory of Raspberry Pi. You can use any SFTP software such as FileZilla. You can download from https://filezilla-project.org/download.php
Now SSH into Raspberry Pi and go inside parking-device folder which you just copied. Verify the deviceId in seed.json file. Make sure it's same as used during registration process. Now issue below command to install nodejs dependencies.
npm install
Next, install python dependencies. Execute below command.
pip3 install -r requirements.txt
Once that's done, we need to install OpenCV. This is a lengthy process. Follow this great tutorial https://www.pyimagesearch.com/2017/09/04/raspbian-stretch-install-opencv-3-python-on-your-raspberry-pi/
Btw, I recently found an easier way to install openCV on Raspberry Pi. You can give it a shot if you like
sudo apt-get update
sudo apt-get install python-opencv
Next you need to install RPi GPIO python library. Follow this article https://www.raspberrypi-spy.co.uk/2012/05/install-rpi-gpio-python-library/
If you have decided not to use Amazon S3 to host the images, open main.py file and look for method initiatePayment. Then comment out below line.
s3_client.upload_file('image2.jpg', 'xxx', key)
Next, you need to create free account in https://cloud.openalpr.com, generate API key and paste in main.py
ALPR_SECRET_KEY = 'sk_xxxx'
We are done with all the installation and configuration. Now open two terminal windows. Execute following command in first window
export BACKEND_URL=<ngrok url>
node mam-client.js
and below command in other window.
python3 main.py
Now it's time to deploy code to car device. This is fairly simple compare to parking device. Copy entire driver-device folder to your 2nd Raspberry Pi using FileZilla ( I have used a Pi zero as I put it on top of my toy car). Once copy is done, SSH into the Raspberry Pi, go inside driver-device folder. Verify seed.json file to make sure the deviceId is same as you registered. I have used CAR123. Then execute following commands.
npm install
node server.js
If all goes fine, you are done with your setup. Now test out the system. I have used a toy car with a license plate to simulate the system. Make sure if use same license plate number during registration of car device.
At the beginning, you should see GREEN light is on in your parking device. Bring the car close to the ultrasonic sensor. Light will turn to AMBER ( or YELLOW), parking place will be removed from the map. Keep the car there for sometime and eventually you will see RED light on and IOTA balance will change for both parking device and car device. Watch below demo video to get an idea how it will work.
Impact on Sustainable Development GoalsWe believe when this prototype will roll out in the market, it will have serious impact on 9th and 13th SDGs. This innovation will open up a door for today's self-driving ( event semi self-driving, auto parking featured cars) and electronic cars industry enabling cars to pay. This concept is not simply limited to parking payments, it can be leveraged for all sort of money transactions such as tolls, vehicle services, car wash are just few use cases.
Apart from impact on industrial innovation, this will reduce waste of fuel due to parking significantly. As the available parking spots will be updated in real time, drivers can quickly find nearby available parking spot saving lot of fuel and time. Less use of fuel = less CO2 = Greener Environment!
Comments