Commit faca48c 1 parent 832162c commit faca48c Copy full SHA for faca48c
File tree 3 files changed +41
-4
lines changed
3 files changed +41
-4
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,13 @@ def get_board():
30
30
if model == "urban" :
31
31
import enviro .boards .urban as board
32
32
return board
33
-
33
+
34
+ # return any additional sensors connected with Qw/ST
35
+ def get_additional_sensors ():
36
+ if 98 in i2c_devices :
37
+ import enviro .sensors .scd41 as scd41
38
+ yield scd41
39
+
34
40
# set up the activity led
35
41
# ===========================================================================
36
42
from machine import PWM , Timer
@@ -304,9 +310,14 @@ def get_sensor_readings():
304
310
readings = get_board ().get_sensor_readings (seconds_since_last )
305
311
readings ["voltage" ] = 0.0 # battery_voltage #Temporarily removed until issue is fixed
306
312
313
+ # Add any additional sensor readings
314
+ for sensor in get_additional_sensors ():
315
+ for key , value in sensor .get_sensor_readings (seconds_since_last ).items ():
316
+ readings [key ] = value
317
+
307
318
# write out the last time log
308
319
with open ("last_time.txt" , "w" ) as timefile :
309
- timefile .write (now_str )
320
+ timefile .write (now_str )
310
321
311
322
return readings
312
323
Original file line number Diff line number Diff line change
1
+ import time
2
+
3
+ import breakout_scd41
4
+
5
+ from enviro import i2c
6
+
7
+ breakout_scd41 .init (i2c )
8
+ breakout_scd41 .start ()
9
+
10
+ def get_sensor_readings (seconds_since_last ):
11
+ retries = 25
12
+ while retries > 0 and not breakout_scd41 .ready ():
13
+ time .sleep (0.2 )
14
+ retries -= 1
15
+
16
+ if retries == 0 :
17
+ return {}
18
+
19
+ scd_co2 , scd_temp , scd_humidity = breakout_scd41 .measure ()
20
+
21
+ from ucollections import OrderedDict
22
+ return OrderedDict ({
23
+ "scd_co2" : scd_co2 ,
24
+ "scd_temperature" : scd_temp ,
25
+ "scd_humidity" : scd_humidity
26
+ })
Original file line number Diff line number Diff line change 73
73
# here you can customise the sensor readings by adding extra information
74
74
# or removing readings that you don't want, for example:
75
75
#
76
- # del readings ["temperature"] # remove the temperature reading
76
+ # del reading ["temperature"] # remove the temperature reading
77
77
#
78
- # readings ["custom"] = my_reading() # add my custom reading value
78
+ # reading ["custom"] = my_reading() # add my custom reading value
79
79
80
80
# is an upload destination set?
81
81
if enviro .config .destination :
You can’t perform that action at this time.
0 commit comments