2. Previously on…
- Obtain data from multiple cars
- Process locally the data and send
them to a remote server
- Provide meaningful infographics
thanks to the aggregation of the
data received
The idea: Technologies & services:
- OBD connector
- Android SDK
- Apache Edgent
- IBM Watson IOT
Platform
- Kibana
3. OBD connector
- Provide a bluetooth interface to the
car’s on-board computer
- Wide range of information: fuel, oil,
distance, throttle, brake and error
codes…
- Available information may change
depending on the car, the OEM and
the revision of the OBD module.
4. The Android Application
- Written in Kotlin using AndroidX support
libraries
- Modular design
- Supports smartphones with Android 8+
- Painful spartan UI
- Handle Bluetooth connection (and setup).
- Join together OBD’s info and the GPS
location
- Send a stream data to IBM Watson IOT
Role:
5. App’s modules
- OBD Java API, a community-developed
set of APIs to write queries for the
OBD2/ELM327 module
- Car-Monitoring-Edgent, our library to
pack data and create a stream to a
remote service
6. Code snippet - Setup OBD connection
Before killing the connection remember it is important to remember to reset the
OBD state using the “Close” command, otherwise you may fail connecting later
on.
8. - Written in Java with Android in mind
- Uses Apache Edgent to create a stream of
data and send it over IBM Watson IOT
- Uses a lightweight connectivity protocol
(MQTT)
- Provides a set of interfaces to read from the
car’s sensors
- Takes care of joining the data into a single
JSON Object
Car Monitoring Edgent library
10. Code snippet - Sensors as objects (Edgent-side)
We expect object that sensors that implement those interfaces in order to get
the data with a fixed-interval schedule
11. Code snippet - Sensors as objects (Android side)
On the Android side I will
override interfaces’
methods
12. Technical difficulties:
- No reliable a priori knowledge of
the available sensors
- Bluetooth interface may fail from
time to time
- Writing and testing code in the car
is not a pleasant experience
- I don’t have a driving license… yet
Solution: OBDSim
15. Cloudant Database
- NoSQL structure
- 1 GB free data storage
- JSON documents
- Monthly bucket
- Binding with Watson IOT
Platform requires very few steps
- Create an alias of your Cloudant
instance into your Cloud
Foundry project space through
IBM CLI.
- Then bind that through Watson
dashboard.
16. - Message Hub Server
- 200 MB IN/OUT traffic per month (free plan)
- Role: Receives payloads from Apache Edgent
devices and automatically stores data in
Cloudant DB
17. Code snippet - Mirroring data to Elastic DB
- DB feed fires the
trigger.
- Trigger is mapped to
a chain (sequence) of
actions through a
rule.
- Our first actionis to
read last insertion
and to pass it to a
custom Python
function.
- The function will
actually send a PUT
request to Elastic DB.
19. - Hard to find what you are looking for in IBM and Apache Edgent
documentation (e.g. broken links, discrepancies, outdated docs)
- IBM Documentation assumes you know things you couldn’t know
about their services. (It gave to me headaches because i had no idea
of what was missing)
Technical difficulties:
20. - Powerful and open source search engine
- Allows plain-text or structured queries
over collections of JSON documents
- Built on top of Elastic
- Console to interact with Elastic
- Wide choice of tools for visualizing data
Managing data
21. Elastic Indices
- Documents are organized in
Indices
- The definition includes the name
of each field and its type
- Allows complex type and nested
fields
- JSON format
22. Visualizing with Kibana- Visualizations in
Kibana can shows
either the result of a
query or the entire
database
- Allow filtering
- Aggregators group
documents by a given
attribute applying an
aggregation function
(Count, AVG . . . )
23. Infographics
- Colormap to show real time
traffic
- Refresh rate each 5 seconds
- Time range of 15 minutes
- Speed ranges adapting to
the current viewing area
24. Infographics II
- Bar chart showing how many
vehicles have engine
temperature in a given range
- This kind of diagnostic
information could be used by
car producer to improve their
products