I have a final project so i need some help for showing the temperature sensor with firebase, I am using Raspberry Pi B+ and a DS18B20 sensor, i wrote all the commands of firebase and it stays only the last step which is when i connect to firebase from the computer i must found the temperature. Anyone can help me with this? Thanks.
Copy from comment: I cant copy all the code here because its too long :
import os, glob, time, calendar, json
from urllib.request import urlopen
while True:
url = 'projetfindetude-4dae9.firebaseio.com/database.json'
postdata = { 'datetime': str(calendar.timegm(time.gmtime())), 'sensorId': "1", 'tempRecord': str(read_temp()) }
req = Request(url)
req.add_header('Content-Type','application/json')
data = json.dumps(postdata)
response = urlopen(req,data)
the error:
req = request(url) NameError: name 'request' is not defined
The statement from urllib.request import urlopen
imports only urlopen
. If you want to call Request
, then you need to either specifically import Request
, or import the whole urllib.request
module (and then call Request
as urllib.request.Request
).