The data collected from the sensors can be sent to the cloud (https://firebase.google.com/) via Raspberry Pi. A sample c
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
The data collected from the sensors can be sent to the cloud (https://firebase.google.com/) via Raspberry Pi. A sample c
https://firebase.google.com/) via Raspberry Pi. A sample code is provided as below: except TypeError: print("Type Error occurs") except IOError: print("IO Error occurs") from time import * from grovepi import * from grove_rgb_lcd import * from pyrebase import pyrebase (1) ( Describe the function of apikey. (4 marks) (ii) dhtsensor = 7 pinMode(dhtsensor,"INPUT") Describe the function of following lines dhtsensor = 7 pinMode(dhtsensor,"INPUT") (2 marks) (iii) Describe the function of the following lines set RGB(0,255,0) setText("Temp =" + t + "337' +"c Hum="+h+ "%") (3 marks) config = { "apiKey": "AIzaSyA8bxj8fXZAsiZ7DhPn3dd1XlyzdHWgmle", "authDomain": "bait-iot-4b0b0.firebaseapp.com", "databaseURL": "https://bait-iot-4b0b0.firebaseio.com", "storageBucket": "bait-iot-4b0b0.appspot.com" 3 firebase = pyrebase.initialize_app(config) auth = firebase.auth user = auth.sign_in_with_email_and_password("[email protected]","xxxx") db = firebase.database() (iv) Identify which lines of the code are responsible for sending the data to cloud. (4 marks) while True: try: time.sleep(5) [temp, hum] =dht(dhtsensor,0) print("Temp=", temp,"\u00b0c', "Hum=", hum,"%") t-str(temp) h =str(hum) setRGB(0,255,0) set Text("Temp =" +t+ "337' +"c Hum="+h+ "%") datal ={"temperature":t} data2 = {"humidity":h) results=db.child("PI_001").push(data l,user['id Token']) results= db.child("PI_001").push(data2 user['idToken']) break except KeyboardInterrupt: setText("Program Exited") break
The data collected from the sensors can be sent to the cloud (