Exemple #1
0
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)

app = Flask(__name__)
CORS(app)
socketio = SocketIO(app)
hallsensor = 4

f = 0
r = 0

eindpoint = '/api/vi/'

conn = Database(app=app,
                host='192.168.4.1',
                port=3306,
                user='******',
                password='******',
                db='projectdb')


@app.route('/')
def hallo():
    return "Server is running"


def start():
    serialPort.send("Start")
    threading.Timer(1, start).start()
    data = conn.set_data(
        "INSERT INTO historiek(GebruikersID, ActionID, waarde) VALUES (%s, %s, %s)",
        [102, 1, 1])
Exemple #2
0
from datetime import datetime
import random

try:

    # App settings
    # sleep(90)

    app = Flask(__name__)
    CORS(app)
    socketio = SocketIO(app)

    # Making connection with the database
    conn = Database(app=app,
                    user='******',
                    password='******',
                    db='smartpost',
                    host='localhost',
                    port=3306)

    # Initializing variables

    buttons = [[1, 2, 3, 'A'], [4, 5, 6, 'B'], [7, 8, 9, 'C'],
               ['*', 0, '#', 'D']]
    rows = [17, 27, 22, 5]
    columns = [6, 13, 19, 26]

    ips = str(check_output(['hostname', '--all-ip-addresses'])).split(' ')

    # Initializing classes

    lcddisplay = LCDDisplay(24, 23, 2, 3, 0)
Exemple #3
0
from RPi import GPIO
import time

led1 = 21
knop1 = Button(20)
knop1_value = False

GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(led1, GPIO.OUT)

app = Flask(__name__)
CORS(app)
socketio = SocketIO(app)

conn = Database(app, 'mct', 'mct', 'ledKnop')


@app.route('/')
def hallo():
    return "Server is running"


@socketio.on("connect")
def connecting():
    socketio.emit("connected", {'value': knop1_value})
    print("Connection with client established")


@socketio.on('knop')
def toggle(data):
Exemple #4
0
IP = check_output(['hostname', '--all-ip-addresses'])
if len(str(IP).split(" ")[1]) < 16:
    draw.text((x, top), "IP: " + str(IP).split(" ")[1], font=font, fill=255)
else:
    draw.text((x, top), "IP: " + str(IP).split(" ")[0], font=font, fill=255)
disp.image(image)
disp.display()
time.sleep(.1)

# INIT THE APP
app = Flask(__name__)

# SETTINGS
endpoint = '/api/v1'
CORS(app)
conn = Database(app=app, user='******', password='******', db='koffer')
disabled = 0

socket = SocketIO(app)
nfc = 0
in_devilstick = 1

btn = [26, 19, 13, 6]
nfcbtn = 5
slot = 22
led = 27
closed = 1
bal_in = 1
GPIO.setmode(GPIO.BCM)
GPIO.setup(btn, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(nfcbtn, GPIO.IN, pull_up_down=GPIO.PUD_UP)
Exemple #5
0
roodpwm = GPIO.PWM(rood, 100)
roodpwm.start(0)
groenpwm = GPIO.PWM(groen, 100)
groenpwm.start(0)
blauwpwm = GPIO.PWM(blauw, 100)
blauwpwm.start(0)
vorigeLucht = 50

sensor = '/sys/bus/w1/devices/28-011850f04eff/w1_slave'
temp = Ds1820(sensor)

app = Flask(__name__)
CORS(app)
socketio = SocketIO(app)

conn = Database(app, 'gilles', 'gilles', 'Projectdb')


@socketio.on("beweging")
def connecting():
    if GPIO.input(pir) == True:
        print("Refreshed!")
        socketio.emit("temperatuur", {'value': temp.temperature()})
        socketio.emit("luchtvochtigheid", {'value': humidity()})
        socketio.emit("ip", {'value': get_ip_address()})
        print("Connection with client established")
        time.sleep(2)


def get_ip_address():
    ip_address = ''
# https://pypi.org/project/schedule/
import json
from flask import Flask, jsonify, request
# https://flask-socketio.readthedocs.io/en/latest/
from flask_socketio import SocketIO
from flask_cors import CORS
import datetime
import pytz
from helpers.Database import Database

# INIT THE APP
app = Flask(__name__)

# SETTINGS
endpoint = '/api/v1'
conn = Database(app, 'funergydev', 'notAChance', 'water', '10.8.0.1')

CORS(app)
app.config['SECRET_KEY'] = 'Secret!'

socketio = SocketIO(app)


# HELPERS
# Generic error showing / handling

# SOCKET.IO EVENTS
@socketio.on('connect')
def connect():
    amount = conn.get_data('select sum(amount) as "amount" from logging where DATE(date) = CURRENT_DATE')
    progress = amount[0]['amount'] if amount[0]['amount'] else 0
Exemple #7
0
from model.accelerometer import Accelerometer
import pynmea2
import serial
import threading
import socket
import fcntl
import struct

# server
app = Flask(__name__)
CORS(app)
socketio = SocketIO(app)

# modules / classes
conn = Database(app=app,
                user='******',
                password='******',
                db='smartbike_db')
lcd = lcd()
adc = mcp3008()

# acc = Accelerometer(0x53, 0x2D, 0x31, 0x32)

# extra
time.sleep(30)
ips = check_output(['hostname', '--all-ip-addresses'])
if str(ips).split(' ')[0].lstrip("\\b\'") == "169.254.10.1":
    lcd.send_message(str(ips).split(' ')[1])
else:
    lcd.send_message(str(ips).split(' ')[0].lstrip("\\b\'"))

# print(str(ips).split(' ')[0].lstrip("\\b\'"))
led = charger()
lcd = shiftRLCD()

# global variabels
alarm = '07:30'
on = False
sleeping = False
checkbox = True
timeNow = datetime.datetime.now().strftime("%H:%M")
# evrything for socketIO and Flask
app = Flask(__name__)
CORS(app)
app.config['SECRET_KEY'] = 'secret!'
socketio = SocketIO(app)

conn = Database(app=app, user='******', password='******', db='project')

endpoint = '/api/v1'


def wekker():
    global alarm
    global ledst
    global sleeping
    global checkbox
    now = datetime.datetime.now()
    alarm_now = now.replace(hour=int(alarm[0:2]),
                            minute=int(alarm[3:5]),
                            second=0)
    alarm_time = datetime.datetime.strptime(alarm, '%H:%M')
    if datetime.datetime.now().strftime("%H:%M") == (