De Funct
Published © CC BY-SA

Alarms And Lights On The WWW

This item can show you when you door has been opened, closed, and if the door has stayed open for an allotted amount of time.

BeginnerWork in progress1 hour787
Alarms And Lights On The WWW

Things used in this project

Hardware components

BeagleBone Black Wireless
BeagleBoard.org BeagleBone Black Wireless
×1
LED (generic)
LED (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Resistor 10k ohm
Resistor 10k ohm
×1
Resistor 475 ohm
Resistor 475 ohm
×1
Magnetic Switch
×1

Software apps and online services

Flask

Hand tools and fabrication machines

screw driver

Story

Read more

Code

The HTML Software...free to be changed.

HTML
Okay!
<!DOCTYPE html>
<head>
<title>The Establishment is Known</title>
</head>

<body>
<h1>The Establishment is Known</h1>
<h2>That dang door is {{ doorStatus }}.</h2>
</body>
</html> 

This is the App for Flask and Python

Python
Yea!
from flask import Flask, render_template
app = Flask(__name__)
import Adafruit_BBIO.GPIO as GPIO
import Adafruit_BBIO.PWM as PWM

GPIO.setup("P8_19", GPIO.OUT)
PWM.start("P8_11", 0.0)

@app.route("/")
def hello():
    if GPIO.input("P8_19"):
        doorStatus = "open"
    else:
        doorStatus = "closed"
    templateData = {
        'doorStatus': doorStatus,
    }
    return render_template('main-door.html', **templateData)
    
@app.route('/ledLevel/<level>')
def pin_state(level):
    PWM.set_duty_cycle("P8_11", float(level))
    return "LED level set to " + "."
    
if __name__ == "__main__":
    app.run(host='192.168.7.2', port=5000, debug=True) 

Credits

De Funct

De Funct

11 projects • 14 followers
Stay there and someone will find you...

Comments