FAQ
Upload an image from a raspberryPi including GPS using PHP
This will show how to setup a raspberry pi to upload an image including GPS location to a server.
# 2 > REQUIRED: GPS HAT (version A)
This is the gps HAT that can be mounted directly on the raspberry pi
PURCHASE: Adafruit Ultimate GPS HAT for Raspberry Pi A+ or B+ - Mini Kit
NOTE: ensure you also purchase the GPS antenna connector (not the antenna, but the wire the WILL connect to your antenna
-> SMA to uFL/u.FL/IPX/IPEX RF Adapter Cable
You will also need an ANTENNA
GPS Antenna - External Active Antenna with SMA to u.FL Cable Assembly
# 3 > REQUIRED: GPS usb (version B)
Optionally you can use a USB gps device to connect to your raspberry PI
Stratux Vk-162 Remote Mount USB GPS
# 4 > Install raspberry PI
You should follow other in depth instructions to install a raspberry PI
-> Here are the step by step instructions
sudo apt-get update
sudo apt-get dist-upgrade
raspi-config
Configure wifi,etc
sudo reboot
ps axf
sudo raspi-config
ifconfig
sudo /sbin/shutdown -h now
deb http://mirrordirector.raspbian.org/raspbian/ jessie main contrib non-free rpi
sudo apt-get install php5
# 5 > Install software
Setting up the software is straight forward and easy
#Paste this into your command line
sudo apt-get install subversion && svn export https://github.com/sacha-lewis/offlineBox/trunk/raspberryPi/install.sh install.sh && chmod +x install.sh && ./install.sh
This will download all the files needed from github and run the install command
-> remove install if you want to read the source before proceeding
# 6 > Install GPS
Plug in your GPS device using USB OR connect your GPS hat to the Raspberry PI
to see if it is connected run the following commands
lsusb
Ensure you see the GPS module in the list
-> In our scenerio we have U-Blox AG
Bus 001 Device 006: ID 1546:01a7 U-Blox AG
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
#reset
sudo killall gpsd
#now to test
php testGps.php
#You should see lat/lng information in the output
# 7 > Setting up server
Create a PHP file on a server: raspberry.php
//VIEW the post information
$this->writeToLog('raspberryPi.log', 'Receiving a new packet...', TRUE);
//$this->writeToLog('raspberryPi.log', 'POST: '.json_encode($_POST), TRUE);
//lookup the IMEI
//write a new marker
$lat = $_POST['lat'];
$lng = $_POST['lng'];
$course = $_POST['course'];
$imei = $_POST['imei'];
$date = $_POST['date'];
$speed = $_POST['speed'];
$gps_valid = $_POST['gps_valid'];
$imageName = $imei.date('YmdHis').'.jpg';
$image = $_POST['picture'];
$image = base64_decode($image);
#save the image to the server
file_put_contents($imageName, $image);
$this->writeToLog('raspberryPi.log', 'lat: '.$lat, TRUE);
$this->writeToLog('raspberryPi.log', 'lng: '.$lng, TRUE);
$this->writeToLog('raspberryPi.log', 'imei: '.$imei, TRUE);
$this->writeToLog('raspberryPi.log', 'date: '.$date, TRUE);
..... do more work here that relate to your project .....