R. Scott Coppersmith
Published © GPL3+

Remote Equipment Monitor

Remote monitoring of deployed field experiment equipment with IR detection and image capture.

IntermediateFull instructions provided20 hours707
Remote Equipment Monitor

Things used in this project

Hardware components

Raspberry Pi Zero Wireless
Raspberry Pi Zero Wireless
×1
Hologram Nova
Hologram Nova
×1

Software apps and online services

Hologram Data Router
Hologram Data Router

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)

Story

Read more

Schematics

Schematic

Code

Python code for Remote Monitor System

Python
import RPi.GPIO as GPIO
import serial
from serial import SerialException
import time
import os
from picamera import PiCamera
from shutil import copyfile
from Hologram.HologramCloud import HologramCloud
def readGPS(port):
    rv=""
    ch=''
    i=0
    while True:
        try:
            ch = port.read()
            if ch=='$':
                ch = port.read()
                ch = port.read()
                ch = port.read()
                rv += ch
                ch = port.read()
                rv += ch
                ch = port.read()
                rv += ch
                if rv=='GGA':
                    while i<36:
                        ch = port.read()
                        rv += ch
                        i+=1
                    return rv
        except SerialException:
            print 'GPS read error'
            
        return 'NA'
port = serial.Serial("/dev/ttyS0", baudrate=9600, timeout=3.0)
hologram = HologramCloud(dict(), network='cellular')
IRinputPin = 17
RelayPin = 18
GPIO.setmode(GPIO.BCM)
GPIO.setup(IRinputPin,GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(RelayPin, GPIO.OUT)
print('System Armed')
camera = PiCamera()
while True:
    
    if (GPIO.input(IRinputPin)):
        time.sleep(10)
    else:
        print('IR input detected')
        GPIO.output(RelayPin,1)
        camera.capture('/home/pi/webcam.jpg')
        timestr = time.strftime("%Y%m%d-%H%M%S")
        filename2 = ('/home/pi/'+timestr+'.jpg')
        copyfile('/home/pi/webcam.jpg', filename2)
        print('Saving Picture')
        os.system("python /home/pi/sendnotify.py")
        print('Sending email')
        GPIO.output(RelayPin,0)
        result = hologram.network.connect()
        if result == False:
            print 'Failedto connect to Hologram network'
        else:
            print 'Hologram Network Connected!'
            response_code = hologram.sendMessage("Motion Detected at: "+timestr)
            print hologram.getResultString(response_code)
            response_code = hologram.sendMessage("Cell Tower GPS Location: Lat:"+
            hologram.network.modem.location.latitude+" Lon: "+
            hologram.network.modem.location.longitude)
            print hologram.getResultString(response_code)
            rcv = readGPS(port)
            if rcv != 'NA':
                print(rcv)
                response_code = hologram.sendMessage("Equipment GPS Location:"
                +rcv)
                print hologram.getResultString(response_code)
            hologram.network.disconnect()

 

Credits

R. Scott Coppersmith

R. Scott Coppersmith

8 projects • 8 followers
Research Engineer, Embedded systems designer

Comments

Add projectSign up / Login