Last active
February 14, 2021 11:25
-
-
Save terrychan999/d50bec87b1ec9f3ff61858f24bc31a07 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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