Skip to content

Instantly share code, notes, and snippets.

@terrychan999
Last active February 14, 2021 11:25
Show Gist options
  • Save terrychan999/d50bec87b1ec9f3ff61858f24bc31a07 to your computer and use it in GitHub Desktop.
Save terrychan999/d50bec87b1ec9f3ff61858f24bc31a07 to your computer and use it in GitHub Desktop.
import bme280
import time
import requests
import json
import datetime
firebase_url = 'https:/change_your_project_name.firebaseio.com/'
while True:
temperature,pressure,humidity = bme280.readBME280All()
print "temp = %.02f C pressure = %.02f humidity =%.02f%%"%(temperature,pressure,humidity)
t = time.time();
date = datetime.datetime.fromtimestamp(t).strftime('%Y%m%d%H%M%S')
data = {'date':date,'temperature':temperature,'pressure':pressure,'humidity':humidity}
result = requests.post(firebase_url + '/temperaturepressurehumidity.json', data=json.dumps(data))
time.sleep(10)
print "10sec"
time.sleep(10)
print "20sec"
time.sleep(10)
print "30sec"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment