sighmon / balena-enviro-plus

Enviro-plus environment sensor deployment to Raspberry Pi via Balena IoT platform
9 stars 7 forks source link

Balena enviro+

Deploy an Enviro+ environment sensor (with PMS5003 particle sensor) using Balena and export the data for Prometheus.

Getting Started

To try this on your Raspberry Pi using Docker:

Install Docker.

Clone this repo, and initialise the submodule.

Build and run the Docker image in the background.

CPU temperature compensation

The CPU of the Raspberry Pi will influence the Enviro+ temperature & humidity sensor a little, so there are some options for compensating for that.

Use COMPENSATION_FACTOR OR the two below:

Post to InfluxDB as well as exporting to Prometheus

If you'd like to also post your data to InfluxDB, enable this by adding your InfluxDB-Cloud environment variables to the Dockerfile:

ENV INFLUXDB_URL="https://your_server_location.gcp.cloud2.influxdata.com"
ENV INFLUXDB_TOKEN="your_token"
ENV INFLUXDB_ORG_ID="your_organisation_id"
ENV INFLUXDB_BUCKET="your_bucket_name"
ENV INFLUXDB_SENSOR_LOCATION="your_sensor_location"
ENV INFLUXDB_TIME_BETWEEN_POSTS="5"
# To see all debug messages
ENV DEBUG="true"

Post to Luftdaten as well as exporting to Prometheus

If you'd like to also post your data to Luftdaten, set the time between posts in the Dockerfile:

ENV LUFTDATEN_TIME_BETWEEN_POSTS="30"
# To see all debug messages
ENV DEBUG="true"

Enabling Particulates on RPi 3, 4, & ZeroW

If you're using Enviro+ on a RPi3, 4 or Zero W you'll need to set "pi3-miniuart-bt" in your Balena Dashboard / Device/Fleet Settings / "Define DT overlays" section for it to read from the serial interface for the PMS5003 particulate monitor.

You'll also need to disable the Serial port on the Balena Host by masking the serial getty service.

# SSH to Balena Host
mount -o remount,rw /
systemctl mask serial-getty@serial0.service
reboot

Post to Safecast as well as exporting to Prometheus

If you'd like to also post your data to Safecast.org, set these environment variables in the Dockerfile:

ENV SAFECAST_TIME_BETWEEN_POSTS="300"
ENV SAFECAST_DEV_MODE="false"
ENV SAFECAST_API_KEY="your_api_key"
ENV SAFECAST_API_KEY_DEV="your_dev_api_key"
ENV SAFECAST_LATITUDE="your_sensor_latitude"
ENV SAFECAST_LONGITUDE="your_sensor_longitude"
ENV SAFECAST_DEVICE_ID="226"
ENV SAFECAST_LOCATION_NAME="your_sensor_location"

Post to Notehub over mobile LTE

If you'd like to also post your data over mobile LTE using a Blues Notecard, set these environment variables in the Dockerfile:

ENV NOTECARD_TIME_BETWEEN_POSTS="600"

Add LC709023F battery monitor

Connect the Adafruit LC709023F to the SDA, SCL, 3V3 and GND pins on the Enviro+

Read errors

If you come across the error: RuntimeError: CRC failure on reading word, you might need to set the I2C clock to 10,000Hz.

To do this in Balena, add i2c_arm_baudrate=10000 to the Device Configuration tab, Define DT parameters, so the full entry is: "i2c_arm=on","spi=on","audio=on","i2c_arm_baudrate=10000"

Deploy with Balena

Once you're happy that it works on your Pi, use the Balena CLI to push it to a Balena app.

Build your own base image

If you'd prefer to build your own base image, follow these instructions:

Acknowledgments

Thanks to Zane Williamson for his work.