# 5 Feb 2022
This is the picorder Python script I wrote for the "SciFi your Pi" challenge in 2015
Now 6 years later, I still retain the Picorder along with other projects I've developed and worked on over the years.
Being recognized as one of the "Final Four" in the international contest, let alone being selected
as a contestant is a great honor and privelege. Since then I've used the Raspberry Pi microcumper
for many of my home projects including and internet radio, surveilliance camera,
touch screen pc browser, and more. Thanks again Element14 for the opportunity.
#
#######################################################################
#!/usr/bin/env python
#######################################################################
## Michael Hahn - Final Version 8-27-2015
## Sci_Fi_Your_Pi element14 contestant.
## The Picorder: A Star Trek style Tricorder
#######################################################################
## Flame Sensor_Temperature_Humidity_Motion_Distance Sensing routine
#######################################################################
import os
import sys
import RPi.GPIO as GPIO
import time
import Adafruit_DHT
from time import sleep
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(13, GPIO.IN)# Flame detector
GPIO.setup(17, GPIO.IN) # PIR motion detector
temp = Adafruit_DHT.DHT11
pin = 4
os.system('omxplayer --no-osd -o local Picordersound.mp3 &')
###############################################
##### Flame Detection SENSOR
###############################################
if (GPIO.input(13)):
print
print
print("Flame detected, take ACTION")
os.system('omxplayer --no-osd -o local Autodefense.mp3 &')
print
print
else:
print
print
print("No Flame detected, safe to proceed")
print
print
###############################################
##### DISTANCE MEASURING SENSOR
###############################################
TRIG=26
ECHO=6
GPIO.setup(TRIG,GPIO.OUT)
GPIO.setup(ECHO,GPIO.IN)
print "Waiting For Sensor To Settle"
time.sleep(1)
GPIO.output(TRIG, True)
time.sleep(0.00001)
GPIO.output(TRIG, False)
print
print "Distance Measurement In Progress"
print
pulse_start = time.time()
time.sleep(0.00005)
pulse_end = time.time()
os.system('omxplayer --no-osd -o local Queue.mp3 &')
pulse_duration = pulse_end - pulse_start
distance = pulse_duration * 17150
distance = round(distance, 5)
print
print "Distance:",distance,"cm"
##print " Distance :%5.1f cm" % distance
print
print
####################################################
humidity, temperature = Adafruit_DHT.read_retry(temp, pin)
if humidity is not None and temperature is not None:
print
print 'Temp={0:0.1f}*C Humidity={1:0.1f}%'.format(temperature, humidity)
print
else:
print
print 'Failed to obtain reading. SCANNING!'
os.system('omxplayer --no-osd -o local nosignal.mp3 &')
print
sleep(1);
####################################################
###### PIR MOTION SENSOR
####################################################
input = GPIO.input(17)
if (GPIO.input(17) == True ):
print
print "DANGER - DANGER - MOTION has been detected"
os.system('omxplayer --no-osd -o local IntruderAlert.mp3 ')
print
else:
print
print "SCANNING AREA for signs of MOTION"
print
sleep(1);
##################################################################
def restart_program():
"""Restarts the current program.
Note: this function does not return. Any cleanup action (like
saving data) must be done before calling this function."""
python = sys.executable
os.execl(python, python, * sys.argv)
if __name__ == "__main__":
answer = "y" #raw_input("Do you want to restart this program ? ")
if answer.lower().strip() in "y yes".split():
restart_program()
Top Comments