Read sensor data directly from the terminal (requires hardware):
python bme280.pyChip ID : 96
Version : 0
Temperature : 21.55 °C
Pressure : 1005.16 hPa
Humidity : 44.57 %RH
Use an alternate I²C address:
BME280_I2C_ADDRESS=0x76 python bme280.pyStart the API server:
python sensor_api.py
# Listening on http://0.0.0.0:5000# Health check
curl http://rpi.local:5000/health
# Read sensor data
curl http://rpi.local:5000/bme280 | python -m json.tool
# Publish to MQTT
curl http://rpi.local:5000/bme280/publishSee API Reference for the full endpoint documentation.
Publish sensor data every minute:
crontab -e* * * * * curl -s http://localhost:5000/bme280/publish >> /var/log/bme280.log 2>&1# Build the app image
docker build --target app -t bme280-app .
# Run with I²C device passthrough and env file
docker run -d \
--name bme280 \
--device /dev/i2c-1:/dev/i2c-1 \
--env-file .env \
-p 5000:5000 \
bme280-appOr with docker compose (uncomment devices in docker-compose.yml first):
docker compose up appdocker compose run --rm test
# or
docker build --target test -t bme280-test . && docker run --rm bme280-test