我正在发送一个由 Raspberry Pi 和 BMP085 传感器控制的气象气球,并且我正在通过 I2C 使用一些 Python 代码来运行它。我想修改每半小时运行一次的 Adafruit BMP085 示例代码:
#!/usr/bin/python
from Adafruit_BMP085 import BMP085
# ===========================================================================
# Example Code
# ===========================================================================
# Initialise the BMP085 and use STANDARD mode (default value)
# bmp = BMP085(0x77, debug=True)
bmp = BMP085(0x77)
# To specify a different operating mode, uncomment one of the following:
# bmp = BMP085(0x77, 0) # ULTRALOWPOWER Mode
# bmp = BMP085(0x77, 1) # STANDARD Mode
# bmp = BMP085(0x77, 2) # HIRES Mode
# bmp = BMP085(0x77, 3) # ULTRAHIRES Mode
temp = bmp.readTemperature()
pressure = bmp.readPressure()
altitude = bmp.readAltitude()
print "Temperature: %.2f C" % temp
print "Pressure: %.2f hPa" % (pressure / 100.0)
print "Altitude: %.2f" % altitude
我本来打算用一个shell脚本来运行它,但是感觉shell的功率太大了,
#!/bin/bash
while true; do
/gryphon7i/alt/altitude_ai >> measurements.log
sleep 1800
done
我该怎么做才能修改代码以每半小时记录一次?我应该坚持shell脚本吗?感谢您提前提供任何帮助。