Overview:
The automation of machines has been rapidly gaining momentum. With the advent of 5G there will be more machine to machine interaction than it had ever been. In addition to industrial applications and robotics, this development is making its way into the mobility sector and energy regeneration. In order to drive these developments decisively forward, however, there is a lack of a suitable underlying data structure today that enables both fast and cost-effective transactions. However, developments of the Distributed Ledger Technology IOTA are very promising in this regard. IOTA has paved the way for machine to machine interaction and payments regardless of the network via a decentralised approach. IOTA has no transaction costs and is built for ecosystems surrounding the M2M Economy enabling a future in which devices can securely communicate with and autonomously compensate each other.
My idea focuses on traffic congestion, smart charging and payment gateways for roads, renewable energy generation, civilians road activity, vehicle identification through hassle free apps and integrations.
The IoT definition says, "We all are surrounded by large amount of data.....", but we fail to extract them in meaningful forms because we try to use a single brain but "What if we use a network of brains?", that's what called blockchain. That is what I am going to build to solve above problem.The device performing tasks would be categorised in fourways:
1) recognise vehicle and store info. in firebase, if match found with app, prompt for charging or exit from traffic congestion
2) from the app to be installed on vehicle's computer take input of charging time, proceed to calculate charges show a QR code for the user to pay through his mobile app
3) if the user wishes to get out of traffic fast, start infinity exit protocols, once payments are received, vehicle comes down to isolated tunnel [ the same concept Elon Musk is using for his Tesla Cars, through Boring Company but mine not limited to only Tesla cars because IOTA makes it free].
4) I would also take care to log data for each vehicle to make police investigations easier and also in case of accidents sending the data(still trying to get work because of less knowledge in programming).
The roads would be capable of charging wirelessly and generating their own power through solar panels and other innovative concepts. IOTA has attracted me more than other because it's free and does not involve any miners for it's payment. Moreover, it has proved to be ideal for machine to machine interaction.
Cost: Argon devices are very cheap and reliable. The energy produced by the roads are through renewable sources of energy(sunlight, wind from high speed cars and surroundings).
Payment: App reduces all the hassles in paying IOTA token. The road maintaining authority can also get info about the real-time payments using Node.js. If a transaction is made and balance updated the node script sends "Success" on firebase database which Particle Argon will read and start charging for desired time from car app.
Scalability: This idea using IOTA is very scalable as IOTA transactions become more efficient if more nodes gets working together. Smart roads could not only reduce electricity wastages but also generate electricity with more efficiency.
Securityand reliability: IOTA protocols are very robust and to enhance security features I have added RFID mechanisms.
How I started ?Honestly, I am totally a beginner in programming but still, I managed to understand and simplify the process so you would not have any problem in understanding my idea and methods. The heart of this project is Particle Argon and its Integrations not to forget IOTA which introduced itself as a game changer in this project. I will explain my project in two parts:
1) Infinity Charge
2)Infinity Exit
Part 1 : Infinity Charge ∞Configure your Argon, using this tutorial:
Step1:Hardware Connections:
Step 2: Exploring the IDE and programming
After connecting all the electronics, now let's get our hands on coding our Argon. Particle IDE and devices are amazing, you feel that your work is automated with few steps and lines(especially integrations).
External libraries required are:
// This #include statement was automatically added by the Particle IDE.
#include <MFRC522.h>
#include <SparkJson.h>
The codes are very simple, thanks to particle libraries for good documentation.
// You need to make some global declarations
#define SS_PIN SS
#define RST_PIN D2
#define relay D5
I made a function to read RFID-ID and sending it to firebase. You should take care of your JSON strings while sending data to any webhooks. This is very important part because it will grant you access through app to charge if you are registered in app(for registering in app you need to provide your license no., name and tag which the state authority would give, then the app will check through firebase to give you a prompt for payment as soon as your ID gets read. It can be very useful for monitoring vehicles on that road for investigations).
// reading RFID using predefined functions
void readId()
{
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
// if found read the tag
String content= "";
byte letter;
for (byte i = 0; i < mfrc522.uid.size; i++)
{
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
content.concat(String(mfrc522.uid.uidByte[i], HEX));
}
content.toUpperCase();
String IDfound = content.substring(1) ;
// send the ID read to Firebase webhook and verify the correct user device to charge with
chargeFlag = true;
Serial.println("Valid ID found, you can start charging.");
sendId(IDfound);
}
// Sending ID to firebase so that the car app can check whether the user is registered or not
void sendId(String IDfound)
{
char buf[256];
snprintf(buf, sizeof(buf), "{\"id\":\"%s\"}", IDfound);
Serial.printlnf("publishing %s", buf);
Particle.publish("SEND_ID", buf, PRIVATE);
delay(3000);
}
This method is used to read payment status and time for charging set by user in car app and accordingly charge also it will reset the data for other users.
/**reading data from firebase and storing it in global variables for further use**/
void dataRead(const char *event, const char *data)
{
StaticJsonBuffer<255> jsonBuffer;
char *mutableCopy = strdup(data);
JsonObject& root = jsonBuffer.parseObject(mutableCopy);
free(mutableCopy);
chargeTime = atoi(root["tm"]);
status = root["status"];
if(strcmp(status,"Success")&&chargeTime>0&&chargeFlag==true)
{
resetData();
chargeFlag = false;
prevTime = millis();
digitalWrite(relay,HIGH);
Serial.println("Charging ON");
}
}
The
charge function handles charging of the car for desired time.
Step3:Car App for Payments
Thunkable classic for my car demo app. Thunkable is a very good platform like MIT app inventor to prototype your apps and it's easier and goes fast. All payment calculations based upon time are done in app and the final.
Step 4: Setting up Webhooks(Firebase and Particle)
Follow the images below. First of all you need to create a firebase project, there are lots of documentation on internet.
Step 4: Script to confirm payment
I used the IOTA check-balance example to modify it and send message to firebase. It was very tough to get my firebase configured for Node.js I got it configured by my friend so I couldn't upload those image but it's same given on firebase documentations.
This is Infinity Exit Wallet where all transaction would be sent.
const iotaLibrary = require('@iota/core')
var firebase = require("firebase-admin")
var database = firebase.database();
var firebaseConfig = {
apiKey: "AIzaSyBhsEDxDPwzjmcoEyjLH0g3_oSIRV_TILo",
authDomain: "smartroad-48be2.firebaseapp.com",
databaseURL: "https://smartroad-48be2.firebaseio.com",
projectId: "smartroad-48be2",
storageBucket: "ID-READ.appspot.com",
};
firebase.initializeApp(firebaseConfig);
var ref = database.ref("/ID-READ");
var usersRef = ref.child("Payment_Status");
const iota = iotaLibrary.composeAPI({
provider: 'https://nodes.devnet.thetangle.org:443'
})
var lastBalance = 2000;
var iotaPaid = 0;
const address = 'OUEVSOUGKSTMEFUMVLIXNUTKNNRHGAD9CXVBNJEBGFZYJYOHSELJDNWFYLUJNKZRHZMJLECNGIPFQ9CYCDFTNUZN9A'
setInterval(checkBalance, 3000)
function checkBalance() {
iota.getBalances([address], 100).then(({ balances }) => {
//console.log(balances)
if (lastBalance < balances) {
iotaPaid = balances - lastBalance
lastBalance = balances
console.log("iota Paid =" + iotaPaid)
usersRef.set('Success');
}
})
.catch(err => {
console.error(err)
})
}
What is your project about? Why did you decide to make it? How does it work? Show us with images and videos!e
ignore the colours in code editor here, it is not recognising my functions.
The script will keep on running and listen to incoming tokens also send Success message on firebase for the Particle Argon to start charging.
We are over with part one Infinity charge let's jump to Part 2 (Infinity Exit).
Part 2: Infinity Exit ∞I used a stepper motor from old cd drive as a lift to bring car down in underground tunnel. Looks bit untidy but it justifies my idea. I will establish serial communication between arduino and esp32 to use this feature. I took help from this project https://www.hackster.io/l3wi/pay-per-coffee-a6e55f. Please refer to this first and understand it, it took me several days to understand ;) I just modified the code as per my use. The code is at the end.
Wire your stepper motor, arduino uno, esp32 as shown. Here Arduino Uno is working as a Slave device. Here goes arduino code. Make sure that your RX, Tx pins are not connected to each other while uploading the program because the same pins are used while communication with USB.
// Arduino code for serial Read
#include <AFMotor.h>
// Connect a stepper motor with 48 steps per revolution (7.5 degree)
// to motor port #2 (M3 and M4)
AF_Stepper motor(48, 2);
void setup()
{
Serial.begin(115200);
Serial.println("Listening to ESP32 requests");
motor.setSpeed(10); // 10 rpm
while (!Serial)
{
; // wait for serial port to connect. Needed for native USB port only
}
}
void loop()
{
if (Serial.available()>0)
{
char c=Serial.read();
if(c=='D')
{
Serial.write("Yes there's a request");
// There's a request from user for infinity exit, the car is standing on base so time to bring it down
// you can use ultrasonic sensor instead for more better performance
motor.step(100, BACKWARD, SINGLE);
// bring up after 5 minutes
delay(1000*60*5);
motor.step(100, FORWARD, SINGLE);
}
else
{
Serial.write("no");
}
}
}
SDG Goal:My project comes under SDG's 7, 8, 9, 11.
SDG 7: As we all know that we have limited source of petroleum so we need to find other sources so my idea makes use of clean battery powered, solar and wind powered technology.
SDG 8: This project cannot be successful without proper maintenance of roads and vehicle device, so more employment for every individual in various departments leveraging from cleaning to programming the roads.
SDG 9: Investment in infrastructure and innovation are crucial drivers of economic growth and development. With over half the world population now living in cities, mass transport and renewable energy are becoming ever more important, as are the growth of new industries and information and communication technologies. Smart charging will surely lead to improve automobile industry as I have seen many block closures in automobile sector this year, even my father lost his job due to this, so my idea would improve the economy of automobile sectors.
SDG 11: Sustainable development cannot be achieved without significantly transforming the way we build and manage our urban spaces. We need to build a safe, reliable, eco-friendly urban atmosphere to progress further. With my plans I would not only bring blockchain payment everywhere also open many platforms for secure data managements with specialized urban town planning. Infinity Exit could be one of them.
Comments