Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update main.py #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
sys.path.append(os.path.join(sys.path[0],"bme280"))

import time
import datetime
import json
import requests
import numpy as np
Expand Down Expand Up @@ -99,7 +100,38 @@ def sendLuftdaten(self):
"pressure": self.pressure,
"humidity": self.humidity,
})

push2opensense()

def push2opensense():
senseBox_ID = "" # your senseBox ID
pm10_ID = "" # your senseBox PM10 sensor ID
pm25_ID = "" # your senseBox PM25 sensor ID
temperature_ID = "" # your senseBox temperature sensor ID
humidity_ID = "" # your senseBox humidity sensor ID
pressure_ID = "" # your senseBox pressure sensor ID
ts = datetime.datetime.utcnow().isoformat("T")+"Z" # RFC 3339 Timestamp # optional # requires import datetime
loc = {"lat": , "lng": , "height": } # location object # optional # insert your lat lng and height (optional)
try:
requests.post("https://api.opensensemap.org/boxes/"+senseBox_ID+"/data",
json={
#SDS011 P10
pm10_ID: [self.pm10_value, ts, loc],
# SDS011 P25
pm25_ID: [self.pm25_value, ts, loc],
#BME Temp
temperature_ID: [self.temperature, ts, loc],
#BME Hum
humidity_ID: [self.humidity, ts, loc],
#BME Press
pressure_ID: [self.pressure/100, ts, loc], # Pressure in hPA, remove "\100" if you want the value in Pa
},
headers={
"content-type": "application/json"
},
timeout=10 # optional
)
except:
pass

def __pushLuftdaten(self, url, pin, values):
requests.post(url,
Expand Down