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

Add BME688 module with a framework for adding new QW/ST modules #188

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Improved custom data points docs
sjefferson99 committed May 10, 2024
commit a78db0c474559c6f9f33d6be4b57cef47ffb5560
23 changes: 23 additions & 0 deletions documentation/developer-guide.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@

## Tips if you want to modify the code
### Adding data points to the returned readings
#### Simple data mangling
Here you can customise the sensor readings to be saved and uploaded by adjusting the "reading" dictionary; Adding extra information or removing data points that you don't want, for example:
```
del reading["temperature"] # remove the temperature data

reading["custom"] = my_reading() # add my custom reading value
```

#### Custom module data points (BME688)
Add simple built in module calls here directly such as a BME688:

```
from breakout_bme68x import BreakoutBME68X
bme = BreakoutBME68X(enviro.i2c)
temperature, pressure, humidity, gas_resistance, status, gas_index, meas_index = bme.read()
reading["temperature2"] = temperature
```
Credit: @hfg-gmuend in [#178](https://github.com/pimoroni/enviro/issues/178)

Or add your own module to call or modify a function in the appropriate boards/*.py file

The above code will overwrite the returned data if you use the same key name e.g. "temperature", ensure this is what you want to do, or otherwise pick a unique name for your new data point e.g. "temperature2"

### Code structure

13 changes: 7 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
@@ -68,14 +68,15 @@
# TODO should the board auto take a reading when the timer has been set, or wait for the time?
# take a reading from the onboard sensors
enviro.logging.debug(f"> taking new reading")

# Take a reading from the configured boards sensors, returns a dictionary of
# reading name and value pairs
# e.g. reading = {"temperature" : 19.1, "humidity" : 64,...}
reading = enviro.get_sensor_readings()

# here you can customise the sensor readings by adding extra information
# or removing readings that you don't want, for example:
#
# del readings["temperature"] # remove the temperature reading
#
# readings["custom"] = my_reading() # add my custom reading value
# Here you can customise the returned date, adding or removing data points
# Refer to the documentation for more information:
# https://github.com/pimoroni/enviro/blob/main/documentation/developer-guide.md

# is an upload destination set?
if enviro.config.destination: