There are lots of accidents occurring in national highways especially during cold and foggy climate and there are some services available that help prevent such accidents but what if the accident has occurred late night or there is heavy snow. "Lastleaf" will address the solution using cloud services and IoT technology that will alert nearby police stations, hospitals and even relatives of such emergency situation. There shall not be any manual triggering required since the service will sense accidents and hazards.
How does this work?While boarding a vehicle, we turn on the Lastleaf android application that transmits GPS data using beacons. Due to impact during an accident, the HCSR04 moves closer to the wall of the setup box via rails recording a lower distance which triggers SORACOM AIR messaging and logging in server with the GPS co-ordinates captured from the nearby android device.
Building up the serviceWe have three modules for Lastleaf:
1. The software that runs on Lastleaf setup. (Lastleaf iBeacon Transponder)
2. An Android application. (Lastleaf Application)
3. A cloud service utility. (Lastleaf Harvest)
Let's build them one by one:
1. The software that runs on Lastleaf setup (Lastleaf iBeacon Transponder)Set up your Raspberry pi Zero W with Raspbian OS and a configured WLAN. Now, install Putty (if on Windows), Linux users may use the native sshutility to login to Raspberry Pi. Keep it ready, we'll need that soon.
On your machine, make sure to have a proper Golang and Git installation:
git clone
the repository.
In your go project directory, execute:
env GOOS=linux GOARCH=arm GOARM=5 go build
- Copy the binary executable to your Raspberry Pi, probably using
ssh
:
scp ./name-of-binary-file pi@raspberrypi.local:~/
- Copy
Majimak.py
to Raspberry pi. - Rename the fragment to your executable at line 34 of
Majimak.py
:
subprocess.call(["sudo","./your_lastleaf"])
- Run the go executable in
sudo
mode to check if everything's okay.
Setting up Soracom account:
- Head over here to create your Soracom Account. For international, head here.
- Register your SIM card and record your
API_KEY
andAPI_TOKEN
. - Plug the
Soracom
SIM card to your mobile phone.
Configuring Majimak.py:
- Give your device a specific
CONST_DEVICE_ID
as constant. - Plug in your API_KEY and API_TOKEN in the program.
- Plug in your
HC-SR04
sensor with the Raspberry Pi GPIO pins as declared inMajimak.py
or customize them. - Copy the
Lastleaf.service
file into your directory. - Now, run the following commands inside your Raspberry Pi shell:
sudo cp Lastleaf.service /lib/systemd/system
sudo chmod 644 /lib/systemd/system/Lastleaf.service
sudo systemctl daemon-reload
sudo systemctl enable Lastleaf.service
- Now, sudo reboot your Raspberry Pi.
- Perform
sudo systemctl status Lastleaf.service
to check if the service is running !
Now, we need to head to rest of the modules of Lastleaf.
2. An Android application (Lastleaf Application)git clone
the repository.- Start Android Studio to compile the project.
About the module
Lastleaf (moblie client) is a mobile client application that produces iBeacons
and sends GPS data as payload using the Bluetooth LE
technology.
Supported devices
Please visit these links to check if your device supports iBeacons
:
- https://en.wikipedia.org/wiki/IBeacon#Compatible_devices
- https://altbeacon.github.io/android-beacon-library/beacon-transmitter-devices.html
About the application
Lastleaf (moblie client) is an android application that requests for current GPS location from user and generates beacons to broadcast the GPS data
(current latitude and longitude) as payload. The beacons released maintains iBeacon
standards. More here. Please note that this application does not involve capturing existing beacons in space. The produced iBeacon
gets captured by a Raspberry pi zero W
hardware and triggers events declared in repository here.
Libraries and dependencies
Please make sure to have the following library and dependency before compiling.
dependencies {implementation 'org.altbeacon:android-beacon-library:2.16.1'}
Screenshots
About the module
Harvest
is a firebase project that works on server side for Lastleaf IOT Service
. Harvest
is responsible for logging Lastleaf
hardware's health, determining application crashes and failures, logging missing hardware information and developing standards for updated versions.
Prerequisites
- Node.js
- Firebase CLI
- Firebase Project
Up and running
git clone
the repository.- Set up your
firebase
project and deploy the application using :firebase deploy
.
Let's see Lastleaf in operation:
Comments