Olli Graf
1 year ago
9 changed files with 0 additions and 239 deletions
@ -1,3 +0,0 @@ |
|||||
ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰&ˆ'‘&‰ |
|
||||
dtparam=spi=off |
|
||||
dtparam=i2c_arm=on |
|
@ -1,25 +0,0 @@ |
|||||
#!/usr/bin/env python |
|
||||
|
|
||||
import time |
|
||||
try: |
|
||||
from smbus2 import SMBus |
|
||||
except ImportError: |
|
||||
from smbus import SMBus |
|
||||
from bme280 import BME280 |
|
||||
|
|
||||
print("""all-values.py - Read temperature, pressure, and humidity |
|
||||
|
|
||||
Press Ctrl+C to exit! |
|
||||
|
|
||||
""") |
|
||||
|
|
||||
# Initialise the BME280 |
|
||||
bus = SMBus(1) |
|
||||
bme280 = BME280(i2c_dev=bus) |
|
||||
|
|
||||
while True: |
|
||||
temperature = bme280.get_temperature() |
|
||||
pressure = bme280.get_pressure() |
|
||||
humidity = bme280.get_humidity() |
|
||||
print('{:05.2f}*C {:05.2f}hPa {:05.2f}%'.format(temperature, pressure, humidity)) |
|
||||
time.sleep(1) |
|
@ -1,49 +0,0 @@ |
|||||
#!/usr/bin/env python |
|
||||
|
|
||||
import time |
|
||||
from bme280 import BME280 |
|
||||
from subprocess import PIPE, Popen |
|
||||
|
|
||||
try: |
|
||||
from smbus2 import SMBus |
|
||||
except ImportError: |
|
||||
from smbus import SMBus |
|
||||
|
|
||||
print("""compensated-temperature.py - Use the CPU temperature to compensate temperature |
|
||||
readings from the BME280 sensor. Method adapted from Initial State's Enviro pHAT |
|
||||
review: https://medium.com/@InitialState/tutorial-review-enviro-phat-for-raspberry-pi-4cd6d8c63441 |
|
||||
|
|
||||
Press Ctrl+C to exit! |
|
||||
|
|
||||
""") |
|
||||
|
|
||||
# Initialise the BME280 |
|
||||
bus = SMBus(1) |
|
||||
bme280 = BME280(i2c_dev=bus) |
|
||||
|
|
||||
# Gets the CPU temperature in degrees C |
|
||||
def get_cpu_temperature(): |
|
||||
process = Popen(['vcgencmd', 'measure_temp'], stdout=PIPE) |
|
||||
output, _error = process.communicate() |
|
||||
output = output.decode() |
|
||||
return float(output[output.index('=') + 1:output.rindex("'")]) |
|
||||
|
|
||||
factor = 0.6 # Smaller numbers adjust temp down, vice versa |
|
||||
smooth_size = 10 # Dampens jitter due to rapid CPU temp changes |
|
||||
|
|
||||
cpu_temps = [] |
|
||||
|
|
||||
while True: |
|
||||
cpu_temp = get_cpu_temperature() |
|
||||
cpu_temps.append(cpu_temp) |
|
||||
|
|
||||
if len(cpu_temps) > smooth_size: |
|
||||
cpu_temps = cpu_temps[1:] |
|
||||
|
|
||||
smoothed_cpu_temp = sum(cpu_temps) / float(len(cpu_temps)) |
|
||||
raw_temp = bme280.get_temperature() |
|
||||
comp_temp = raw_temp - ((smoothed_cpu_temp - raw_temp) / factor) |
|
||||
|
|
||||
print("Compensated temperature: {:05.2f} *C".format(comp_temp)) |
|
||||
|
|
||||
time.sleep(1.0) |
|
@ -1,22 +0,0 @@ |
|||||
#!/usr/bin/env python |
|
||||
|
|
||||
try: |
|
||||
from smbus2 import SMBus |
|
||||
except ImportError: |
|
||||
from smbus import SMBus |
|
||||
from bme280 import BME280 |
|
||||
|
|
||||
print("""dump-calibration.py - Dumps calibration data. |
|
||||
|
|
||||
Press Ctrl+C to exit! |
|
||||
|
|
||||
""") |
|
||||
|
|
||||
# Initialise the BME280 |
|
||||
bme280 = BME280(i2c_dev=SMBus(1)) |
|
||||
bme280.setup() |
|
||||
|
|
||||
for key in dir(bme280.calibration): |
|
||||
if key.startswith('dig_'): |
|
||||
value = getattr(bme280.calibration, key) |
|
||||
print('{} = {}'.format(key, value)) |
|
@ -1,39 +0,0 @@ |
|||||
#!/usr/bin/env python |
|
||||
|
|
||||
import time |
|
||||
|
|
||||
try: |
|
||||
from smbus2 import SMBus |
|
||||
except ImportError: |
|
||||
from smbus import SMBus |
|
||||
from bme280 import BME280 |
|
||||
|
|
||||
print("""local_altitude.py - |
|
||||
Allows you to correct the QNH for your local area. |
|
||||
Do not rely on this approximation for landing planes. |
|
||||
Press Ctrl+C to exit! |
|
||||
""") |
|
||||
|
|
||||
# Initialise the BME280 |
|
||||
bus = SMBus(1) |
|
||||
bme280 = BME280(i2c_dev=bus) |
|
||||
|
|
||||
# asks the user for their local QNH value and confirms it |
|
||||
local_qnh = input("""Please enter your local QNH value. |
|
||||
You can find this by searching for a local METAR on the internet. |
|
||||
>""") |
|
||||
print("You have told us the QNH is", local_qnh) |
|
||||
|
|
||||
# converts the input into a floating point number |
|
||||
local_qnh = float(local_qnh) |
|
||||
time.sleep(1) |
|
||||
|
|
||||
# workaround to get rid of the first reading |
|
||||
altitude = bme280.get_altitude() |
|
||||
print("Waiting a couple of seconds for the sensor to initialise...") |
|
||||
time.sleep(2) |
|
||||
|
|
||||
while True: |
|
||||
altitude = bme280.get_altitude(qnh=local_qnh) |
|
||||
print(round(altitude), "metres above sea level") |
|
||||
time.sleep(2) |
|
@ -1,38 +0,0 @@ |
|||||
#!/usr/bin/env python |
|
||||
|
|
||||
import time |
|
||||
|
|
||||
try: |
|
||||
from smbus2 import SMBus |
|
||||
except ImportError: |
|
||||
from smbus import SMBus |
|
||||
from bme280 import BME280 |
|
||||
|
|
||||
print("""relative-altitude.py - Calculates relative altitude from pressure. |
|
||||
|
|
||||
Press Ctrl+C to exit! |
|
||||
|
|
||||
""") |
|
||||
|
|
||||
# Initialise the BME280 |
|
||||
bus = SMBus(1) |
|
||||
bme280 = BME280(i2c_dev=bus) |
|
||||
|
|
||||
baseline_values = [] |
|
||||
baseline_size = 100 |
|
||||
|
|
||||
print("Collecting baseline values for {:d} seconds. Do not move the sensor!\n".format(baseline_size)) |
|
||||
|
|
||||
# Collect some values to calculate a baseline pressure |
|
||||
for i in range(baseline_size): |
|
||||
pressure = bme280.get_pressure() |
|
||||
baseline_values.append(pressure) |
|
||||
time.sleep(1) |
|
||||
|
|
||||
# Calculate average baseline |
|
||||
baseline = sum(baseline_values[:-25]) / len(baseline_values[:-25]) |
|
||||
|
|
||||
while True: |
|
||||
altitude = bme280.get_altitude(qnh=baseline) |
|
||||
print('Relative altitude: {:05.2f} metres'.format(altitude)) |
|
||||
time.sleep(1) |
|
@ -1,33 +0,0 @@ |
|||||
#!/usr/bin/env python |
|
||||
|
|
||||
import time |
|
||||
try: |
|
||||
from smbus2 import SMBus |
|
||||
except ImportError: |
|
||||
from smbus import SMBus |
|
||||
from bme280 import BME280 |
|
||||
|
|
||||
print("""temperature-compare.py - Compares oversampling levels |
|
||||
(requires two BME280s with different addresses). |
|
||||
|
|
||||
Press Ctrl+C to exit! |
|
||||
|
|
||||
""") |
|
||||
|
|
||||
# Initialise the BME280 |
|
||||
bus = SMBus(1) |
|
||||
bme280A = BME280(i2c_dev=bus) |
|
||||
bme280B = BME280(i2c_dev=bus, i2c_addr=0x77) |
|
||||
|
|
||||
# Set up in "forced" mode |
|
||||
# In this mode `get_temperature` and `get_pressure` will trigger |
|
||||
# a new reading and wait for the result. |
|
||||
# The chip will return to sleep mode when finished. |
|
||||
bme280A.setup(mode="normal", temperature_oversampling=1, pressure_oversampling=1) |
|
||||
bme280B.setup(mode="normal", temperature_oversampling=16, pressure_oversampling=16) |
|
||||
|
|
||||
while True: |
|
||||
temperatureA = bme280A.get_temperature() |
|
||||
temperatureB = bme280B.get_temperature() |
|
||||
print('Forced: {:05.2f}*C Normal: {:05.2f}*C D: {:05.2f}'.format(temperatureA, temperatureB, abs(temperatureA - temperatureB))) |
|
||||
time.sleep(1) |
|
@ -1,23 +0,0 @@ |
|||||
#!/usr/bin/env python |
|
||||
|
|
||||
import time |
|
||||
try: |
|
||||
from smbus2 import SMBus |
|
||||
except ImportError: |
|
||||
from smbus import SMBus |
|
||||
from bme280 import BME280 |
|
||||
|
|
||||
# Initialise the BME280 |
|
||||
bus = SMBus(1) |
|
||||
bme280 = BME280(i2c_dev=bus) |
|
||||
|
|
||||
# Set up in "forced" mode |
|
||||
# In this mode `get_temperature` and `get_pressure` will trigger |
|
||||
# a new reading and wait for the result. |
|
||||
# The chip will return to sleep mode when finished. |
|
||||
bme280.setup(mode="forced") |
|
||||
|
|
||||
while True: |
|
||||
temperature = bme280.get_temperature() |
|
||||
print('{:05.2f}*C'.format(temperature)) |
|
||||
time.sleep(1) |
|
@ -1,7 +0,0 @@ |
|||||
printf "It's recommended you run these steps manually.\n" |
|
||||
printf "If you want to run the full script, open it in\n" |
|
||||
printf "an editor and remove 'exit 1' from below.\n" |
|
||||
exit 1 |
|
||||
/usr/bin/python3 -m pip uninstall pimoroni-bme280 |
|
||||
cp /home/pi/Pimoroni/config-backups/config.preinstall-pimoroni-bme280-2022-07-22-06-35-49.txt /boot/config.txt |
|
||||
rm -r /home/pi/Pimoroni/pimoroni-bme280 |
|
Loading…
Reference in new issue