Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Raspberry Pi Android Projects

You're reading from   Raspberry Pi Android Projects Create exciting projects by connecting the Raspberry Pi to your Android phone

Arrow left icon
Product type Paperback
Published in Sep 2015
Publisher
ISBN-13 9781785887024
Length 138 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Gökhan Kurt Gökhan Kurt
Author Profile Icon Gökhan Kurt
Gökhan Kurt
Arrow right icon
View More author details
Toc

Putting it all together


In the next two sections, we will put together what we have done so far. First, we'll begin by sending data to the Google Docs sheet. Then, we will build an Android app to show the data on a map.

Sending measurements

We will use a Python script to access GPS data on the Pi that we'll need to run on system reboot. For this purpose, add the following code at the end of the /etc/rc.local file:

sudo killall gpsd
sudo gpsd /dev/ttyUSB0 -F /var/run/gpsd.sock
sudo rfcomm connect hci0 00:1D:A5:15:A0:DC &
sleep 1m
current_time=$(date "+%Y.%m.%d-%H.%M.%S")
file_name=/home/pi/log_sender.txt
new_filename=$file_name.$current_time
sudo /home/pi/pyobd-pi/sender.py > $new_filename 2>&1 &

Here, we can restart the GPS services, connect to the OBD Bluetooth dongle, create a log file, and start the sender.py script that we will implement next:

#!/usr/bin/env python

import obd_io
from datetime import datetime
import time
import threading
import commands
import time
from...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image