element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Sci Fi Your Pi
  • Challenges & Projects
  • Design Challenges
  • Sci Fi Your Pi
  • More
  • Cancel
Sci Fi Your Pi
Blog Picorder SCRIPT
  • Blog
  • Forum
  • Documents
  • Files
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: saturnv
  • Date Created: 28 Aug 2015 11:40 PM Date Created
  • Views 1004 views
  • Likes 3 likes
  • Comments 4 comments
  • star_trek
  • handheld_sensor
  • sci_fi_your_pi
  • tricorder
Related
Recommended

Picorder SCRIPT

saturnv
saturnv
28 Aug 2015
Picorder SCRIPT

# 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()

  • Sign in to reply

Top Comments

  • clem57
    clem57 over 10 years ago +1
    Very clean well written code. Thanks. C
  • balearicdynamics
    balearicdynamics over 10 years ago +1
    I agree with Clem, very well and clean code. Enrico
  • saturnv
    saturnv over 10 years ago in reply to balearicdynamics +1
    Echoing my comment on Clem's comment. Thank you very much Enrico. Your comment is greatly appreciated. Gives confidence to continue with projects, challenges and learning and developing code. Now a brief…
  • saturnv
    saturnv over 10 years ago in reply to balearicdynamics

    Echoing my comment on Clem's comment. Thank you very much Enrico. Your comment is greatly appreciated. Gives confidence to continue with projects, challenges and learning and developing code. Now a brief regeneration period, and then back to the drawing board with new projects to conquer!

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • saturnv
    saturnv over 10 years ago in reply to clem57

    Thank you very much Clem. Your comment is greatly appreciated. Gives confidence to continue with projects, challenges and learning and developing code.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • balearicdynamics
    balearicdynamics over 10 years ago

    I agree with Clem, very well and clean code.

     

    Enrico

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • clem57
    clem57 over 10 years ago

    Very clean well written code.

    Thanks.

    C

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube