-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Months of trouble.. but this is a stable release without anymore bugs!
- Loading branch information
1 parent
5bb63a6
commit 081984d
Showing
19 changed files
with
922 additions
and
975 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,6 @@ __pycache__/ | |
*.py[cod] | ||
*$py.class | ||
|
||
pymakr.conf | ||
pymakr.conf | ||
|
||
**secret.py |
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
Binary file renamed
BIN
+44.5 KB
...matic_Meet_je_leefomgeving_2022-01-26.pdf → ...matic_Meet_je_leefomgeving_2022-08-15.pdf
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import machine | ||
import time | ||
|
||
def run_gps(timeout = 120): | ||
from lib.micropyGPS import MicropyGPS | ||
|
||
values = {} | ||
|
||
gps_en = machine.Pin('P22', mode = machine.Pin.OUT) # 2N2907 (PNP) gate pin | ||
gps_en.hold(False) # disable hold from deepsleep | ||
gps_en.value(0) # enable GPS power | ||
gps = MicropyGPS() # create GPS object | ||
|
||
com = machine.UART(2, pins = ('P3', 'P4'), baudrate = 9600) # GPS communication | ||
|
||
t1 = time.time() | ||
while gps.latitude == gps.longitude == 0 and time.time() - t1 < timeout: # timeout if no fix after .. | ||
while com.any(): # wait for incoming communication | ||
my_sentence = com.readline() # read NMEA sentence | ||
for x in my_sentence: | ||
gps.update(chr(x)) # decode it through micropyGPS | ||
|
||
gps_en.value(1) | ||
gps_en.hold(True) | ||
|
||
values["lat"] = gps.latitude | ||
values["long"] = gps.longitude | ||
values["alt"] = gps.alt | ||
return values |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import machine | ||
import time | ||
|
||
from lib.VEML6070 import VEML6070 | ||
from lib.TSL2591 import TSL2591 | ||
from lib.BME680 import BME680 | ||
from lib.MAX4466 import MAX4466 | ||
from lib.KP26650 import KP26650 | ||
|
||
def run_collection(i2c_bus, all_sensors, t_wake = 30): | ||
|
||
values = {} # collection of all values, to be returned | ||
|
||
bme680 = BME680(i2c = i2c_bus, address = 0x77) | ||
bme680.set_gas_heater_temperature(400, nb_profile = 1) # set VOC plate heating temperature | ||
bme680.set_gas_heater_duration(50, nb_profile = 1) # set VOC plate heating duration | ||
bme680.select_gas_heater_profile(1) # select those settings | ||
while not bme680.get_sensor_data(): | ||
time.sleep_ms(10) | ||
values['temp'] = bme680.temperature | ||
values['pres'] = bme680.pressure | ||
values['humi'] = bme680.humidity | ||
values['voc'] = bme680.gas | ||
bme680.set_power_mode(0) | ||
|
||
veml6070 = VEML6070(i2c = i2c_bus, address = 56) # UV sensor (0.4 / 0.0 mA) (0x38) | ||
veml6070.wake() | ||
time.sleep(0.2) # sensor stabilization time (required!!) | ||
values['uv'] = veml6070.uv_raw | ||
values['uv'] = veml6070.uv_raw # first poll may fail so do it twice | ||
veml6070.sleep() | ||
|
||
tsl2591 = TSL2591(i2c = i2c_bus, address = 41) # lux sensor (0.4 / 0.0 mA) (0x29) | ||
tsl2591.wake() | ||
time.sleep(0.2) # sensor stabilization time (required!!) | ||
values['lx'] = tsl2591.lux | ||
tsl2591.sleep() | ||
|
||
max4466 = MAX4466('P15', duration = 200) # analog loudness sensor (200ms measurement) | ||
values['volu'] = max4466.get_volume() # active: 0.3 mA, sleep: 0.3 mA (always on) | ||
|
||
battery = KP26650('P16', duration = 50, ratio = 2) # battery voltage (50ms measurement, 1:1 voltage divider) | ||
values['volt'] = battery.get_voltage() | ||
values['perc'] = battery.get_percentage(values['volt'], lb = 2.9, ub = 4.1) # map voltage from 2.9..4.1 V to 0..100% | ||
|
||
if all_sensors == True: | ||
from lib.SDS011 import SDS011 | ||
from lib.MQ135 import MQ135 | ||
|
||
regulator = machine.Pin('P21', mode = machine.Pin.OUT) # voltage regulator SHDN pin | ||
regulator.hold(False) # disable hold from deepsleep | ||
regulator.value(1) # start SDS011 and MQ135 | ||
|
||
com = machine.UART(1, pins=('P20', 'P19'), baudrate = 9600) # UART communication to SDS011 | ||
sds011 = SDS011(com) # fine particle sensor (70 / 0.0 mA) | ||
|
||
mq135 = MQ135('P17', duration = 50) # CO2 sensor (200 / 0.0 mA) | ||
|
||
machine.sleep(t_wake * 1000) # wait for ~30 seconds | ||
|
||
values['co2'] = mq135.get_corrected_ppm(values['temp'], values['humi']) | ||
|
||
t1 = time.ticks_ms() | ||
while (not sds011.read() and time.ticks_ms() - t1 < 5000): # try to get a response from SDS011 within 5 seconds | ||
time.sleep_ms(10) | ||
|
||
values['pm25'] = sds011.pm25 | ||
values['pm10'] = sds011.pm10 | ||
regulator.value(0) # disable voltage regulator | ||
regulator.hold(True) # hold pin low during deepsleep | ||
|
||
return values |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0 |
Oops, something went wrong.