├── LED.py ├── firebase.json └── muhammed.py /LED.py: -------------------------------------------------------------------------------- 1 | import RPi.GPIO as GPIO 2 | import time 3 | 4 | import firebase_admin 5 | from firebase_admin import credentials 6 | from firebase_admin import db 7 | 8 | cred = credentials.Certificate('firebase.json') 9 | 10 | firebase_admin.initialize_app(cred,{ 11 | 'databaseURL': "https://raspberrypi-84de0.firebaseio.com/" 12 | }) 13 | 14 | ref = db.reference('status') 15 | 16 | 17 | while True: 18 | GPIO.setmode(GPIO.BCM) 19 | GPIO.setwarnings(False) 20 | GPIO.setup(18,GPIO.OUT) 21 | print "LED on" 22 | ref.push({ 23 | "status":"LED on" 24 | }) 25 | 26 | GPIO.output(18,GPIO.HIGH) 27 | time.sleep(4) 28 | print "LED off" 29 | ref.push({ 30 | "status":"LED off" 31 | }) 32 | GPIO.output(18,GPIO.LOW) 33 | time.sleep(3) 34 | -------------------------------------------------------------------------------- /firebase.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "service_account", 3 | "project_id": "", 4 | "private_key_id": "", 5 | "private_key": "", 6 | "client_email": "", 7 | "client_id": "", 8 | "auth_uri": "", 9 | "token_uri": "", 10 | "auth_provider_x509_cert_url": "", 11 | "client_x509_cert_url": "" 12 | } 13 | -------------------------------------------------------------------------------- /muhammed.py: -------------------------------------------------------------------------------- 1 | import firebase_admin 2 | from firebase_admin import credentials 3 | from firebase_admin import db 4 | 5 | cred = credentials.Certificate('firebase.json') 6 | 7 | firebase_admin.initialize_app(cred,{ 8 | 'databaseURL': "https://raspberrypi-84de0.firebaseio.com/" 9 | }) 10 | 11 | ref = db.reference('status') 12 | ref.push({ 13 | "student":{ 14 | 'emp1':{"firstName":"John", "lastName":"Doe"}, 15 | 'emp2':{"firstName":"Anna", "lastName":"Smith"}, 16 | 'emp3':{"firstName":"Peter", "lastName":"Jones"} 17 | } 18 | }) 19 | --------------------------------------------------------------------------------