claude garrett
Published © GPL3+

Simple Asset Tracking

A simple, light-weight asset tracking solution with minimal parts. Intended for general use or model rocketry/balloons. Easy to build.

BeginnerFull instructions provided4 hours2,513
Simple Asset Tracking

Things used in this project

Hardware components

Hologram Nova
Hologram Nova
×1
Hologram Global IoT SIM Card
Hologram Global IoT SIM Card
×1
Ublox NEO-6M GPS Module
×1

Software apps and online services

Hologram Data Router
Hologram Data Router

Hand tools and fabrication machines

Jumper wires
Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Schematic

Connections to Neo-6M GPS module

Code

gmail.py

Python
This code gets the longitude and latitude from a NEO-6M GPS unit, parses it and sends a google maps link in an email
import serial
import pynmea2

from Hologram.HologramCloud import HologramCloud

str = ''
#Get GPS Location
serialPort = serial.Serial("/dev/ttyAMA0", 9600, timeout=5)

#Wait until we have a valid location
while str.find('GGA') == -1:
    str = serialPort.readline()

#parse the string for latitude and longitude
msg = pynmea2.parse(str)
#print msg
#print msg.lat
#print msg.lon

latitude = msg.lat
longitude = msg.lon

#Set the sign of the latitude based on the direction (N/S)
if msg.lat_dir == 'S':
    latitude = '-' + latitude

#Set the sign of the longitude based on the direction (E/W)
if msg.lon_dir == 'W':
    longitude = '-' + longitude

#Get a hologram instance and connect
credentials = {'devicekey':'<your device key>'}
hologram = HologramCloud(credentials, network='cellular')

#Attempt to connect
result = hologram.network.connect()

if result == False:
    print ' Failed to connect to cell network'

#Our message will be a google maps link that will show the current location
message = "https://www.google.com/maps/?q="+latitude+","+longitude

#print message

#Send the message
response_code = hologram.sendMessage(message,topics=["gmail"])

print hologram.getResultString(response_code)

#Disconnect
hologram.network.disconnect()

sleeploop.py

Python
This code calls gmail.py every five minutes
import time

while True:
    execfile("gmail.py")
    time.sleep(300)

sms_ping.py

Python
This code calls gmail.py when an SMS message is received
import time
import sys
sys.path.append(".")
sys.path.append("..")
sys.path.append("../..")

from Hologram.HologramCloud import HologramCloud

if __name__ == '__main__':

    hologram = HologramCloud(None, network='cellular')

    while True:

        hologram.enableSMS()

        print 'waiting for 60 seconds...'
        time.sleep(60)

        hologram.disableSMS()

        sms_obj = hologram.popReceivedSMS()

        if sms_obj is None:
            print 'No messages yet...'
        else:
            print 'sender:', sms_obj.sender
            print sms_obj.timestamp.strftime('%c')
            print u'message:', sms_obj.message
            execfile("gmail.py")

Credits

claude garrett

claude garrett

11 projects • 10 followers

Comments