Open boschLining opened 10 months ago
Forced mode is a continuous update mode, so Forced Mode is probably not the best place to start. The function to set ULP is :- set_sample_rate(BSEC_SAMPLE_RATE_ULP) ULP is 300sec and the documentation suggests 298 sec for a timer. I chose 10sec just to see it looping until a valid return, and it did 30 loops. I used the 2.4 version of BSEC and the PI3G python wrapper.
# This example tests and demonstrates the BME68X_PARALLEL_MODE with ULP (300 sec low power)
# With use of BSEC
from bme68x import BME68X
import bme69xConstants as cnst
import bsecConstants as bsec
from time import sleep
temp_prof = [320, 100, 100, 100, 200, 200, 200, 320, 320, 320]
dur_prof = [5, 2, 10, 30, 5, 5, 5, 5, 5, 5]
print('\n\nPARALLEL MODE WITH BSEC')
sensor = BME68X(cnst.BME68X_I2C_ADDR_HIGH, 0)
# Set the heater up
print(sensor.set_heatr_conf(cnst.BME68X_ENABLE,
temp_prof, dur_prof, cnst.BME68X_PARALLEL_MODE))
# set ULP sample rate
sensor.set_sample_rate(bsec.BSEC_SAMPLE_RATE_ULP)
def get_data(sensor):
data = {}
try:
data = sensor.get_bsec_data()
except Exception as e:
print(e)
sleep(1)
return None
if data == {} or data == None:
sleep(10)
return None
else:
return data
bsec_data = get_data(sensor)
while bsec_data == None:
print("Looping zero data")
bsec_data = get_data(sensor)
print(bsec_data)
I changed the code a little to run in a loop and altered the sleep from 10 to 300. I has been running for 3 hours and is up to Sample No 62. It runs in 3.5MB of memory and is stable.
Below is the sleep change:
if data == {} or data == None:
sleep(300)
return None
And the while true loop change is below:
while True:
bsec_data = get_data(sensor)
while bsec_data == None:
print("Looping zero data")
bsec_data = get_data(sensor)
print(bsec_data)
Hope this has helped
Hi, I am using your codes on my BME688, and many power mode can work normally, that's great. But when I try to use ULP mode by changing 3s of forced_mode.py to 300s, which output as unexpected. So do you have any solutions about it, or do you test it again, thanks.