1717 level = logging .INFO ,
1818 datefmt = "%Y-%m-%d %H:%M:%S" )
1919
20- logging .info ("""luftdaten .py - Reads temperature, pressure, humidity,
21- PM2.5, and PM10 from Enviro plus and sends data to Luftdaten ,
20+ logging .info ("""sensorcommunity .py - Reads temperature, pressure, humidity,
21+ PM2.5, and PM10 from Enviro plus and sends data to Sensor.Community ,
2222the citizen science air quality project.
2323
24- Note: you'll need to register with Luftdaten at:
25- https://meine.luftdaten.info / and enter your Raspberry Pi
24+ Note: you'll need to register with Sensor.Community at:
25+ https://devices.sensor.community / and enter your Raspberry Pi
2626serial number that's displayed on the Enviro plus LCD along
2727with the other details before the data appears on the
28- Luftdaten map.
28+ Sensor.Community map.
2929
3030Press Ctrl+C to exit!
3131
@@ -118,7 +118,7 @@ def display_status():
118118 disp .display (img )
119119
120120
121- def send_to_luftdaten (values , id ):
121+ def send_to_sensorcommunity (values , id ):
122122 pm_values = dict (i for i in values .items () if i [0 ].startswith ("P" ))
123123 temp_values = dict (i for i in values .items () if not i [0 ].startswith ("P" ))
124124
@@ -132,7 +132,7 @@ def send_to_luftdaten(values, id):
132132 resp_pm = requests .post (
133133 "https://api.sensor.community/v1/push-sensor-data/" ,
134134 json = {
135- "software_version" : "enviro-plus 0 .0.1 " ,
135+ "software_version" : "enviro-plus 1 .0.0 " ,
136136 "sensordatavalues" : pm_values_json
137137 },
138138 headers = {
@@ -144,17 +144,17 @@ def send_to_luftdaten(values, id):
144144 timeout = 5
145145 )
146146 except requests .exceptions .ConnectionError as e :
147- logging .warning (f"Sensor.Community (Luftdaten) PM Connection Error: { e } " )
147+ logging .warning (f"Sensor.Community PM Connection Error: { e } " )
148148 except requests .exceptions .Timeout as e :
149- logging .warning (f"Sensor.Community (Luftdaten) PM Timeout Error: { e } " )
149+ logging .warning (f"Sensor.Community PM Timeout Error: { e } " )
150150 except requests .exceptions .RequestException as e :
151- logging .warning (f"Sensor.Community (Luftdaten) PM Request Error: { e } " )
151+ logging .warning (f"Sensor.Community PM Request Error: { e } " )
152152
153153 try :
154154 resp_bmp = requests .post (
155155 "https://api.sensor.community/v1/push-sensor-data/" ,
156156 json = {
157- "software_version" : "enviro-plus 0 .0.1 " ,
157+ "software_version" : "enviro-plus 1 .0.0 " ,
158158 "sensordatavalues" : temp_values_json
159159 },
160160 headers = {
@@ -166,17 +166,17 @@ def send_to_luftdaten(values, id):
166166 timeout = 5
167167 )
168168 except requests .exceptions .ConnectionError as e :
169- logging .warning (f"Sensor.Community (Luftdaten) Climate Connection Error: { e } " )
169+ logging .warning (f"Sensor.Community Climate Connection Error: { e } " )
170170 except requests .exceptions .Timeout as e :
171- logging .warning (f"Sensor.Community (Luftdaten) Climate Timeout Error: { e } " )
171+ logging .warning (f"Sensor.Community Climate Timeout Error: { e } " )
172172 except requests .exceptions .RequestException as e :
173- logging .warning (f"Sensor.Community (Luftdaten) Climate Request Error: { e } " )
173+ logging .warning (f"Sensor.Community Climate Request Error: { e } " )
174174
175175 if resp_pm is not None and resp_bmp is not None :
176176 if resp_pm .ok and resp_bmp .ok :
177177 return True
178178 else :
179- logging .warning (f"Luftdaten Error. PM: { resp_pm .reason } , Climate: { resp_bmp .reason } " )
179+ logging .warning (f"Sensor.Community Error. PM: { resp_pm .reason } , Climate: { resp_bmp .reason } " )
180180 return False
181181 else :
182182 return False
@@ -185,7 +185,7 @@ def send_to_luftdaten(values, id):
185185# Compensation factor for temperature
186186comp_factor = 2.25
187187
188- # Raspberry Pi ID to send to Luftdaten
188+ # Raspberry Pi ID to send to Sensor.Community
189189id = "raspi-" + get_serial_number ()
190190
191191# Width and height to calculate text position
@@ -204,18 +204,18 @@ def send_to_luftdaten(values, id):
204204time_since_update = 0
205205update_time = time .time ()
206206
207- # Main loop to read data, display, and send to Luftdaten
207+ # Main loop to read data, display, and send to Sensor.Community
208208while True :
209209 try :
210210 values = read_values ()
211211 time_since_update = time .time () - update_time
212212 if time_since_update > 145 :
213213 logging .info (values )
214214 update_time = time .time ()
215- if send_to_luftdaten (values , id ):
216- logging .info ("Luftdaten Response: OK" )
215+ if send_to_sensorcommunity (values , id ):
216+ logging .info ("Sensor.Community Response: OK" )
217217 else :
218- logging .warning ("Luftdaten Response: Failed" )
218+ logging .warning ("Sensor.Community Response: Failed" )
219219 display_status ()
220220 except Exception as e :
221221 logging .warning (f"Main Loop Exception: { e } " )
0 commit comments