This data logger writes measurements from a BME280 into a InfluxDB time-series database.
Deploy faasd to your Raspberry Pi 3 or 4 using these instructions
Customise the password, and update /var/lib/faasd/docker-compose.yaml
influxdb:
image: docker.io/library/influxdb:1.8
environment:
- INFLUXDB_DB=defaultdb
- INFLUXDB_ADMIN_USER=admin
- "INFLUXDB_ADMIN_PASSWORD=PASSWORD"
- INFLUXDB_USER=user
- "INFLUXDB_USER_PASSWORD=PASSWORD"
- INFLUXDB_REPORTING_DISABLED=true
- INFLUXDB_HTTP_AUTH_ENABLED=true
- INFLUXDB_HTTP_BIND_ADDRESS=0.0.0.0:8086
volumes:
# we assume cwd == /var/lib/faasd
- type: bind
source: ./influxdb/
target: /var/lib/influxdb
user: "1000"
cap_add:
- CAP_NET_RAW
ports:
- "0.0.0.0:8086:8086"Make a directory for InfluxDB:
mkdir -p /var/lib/faasd/influxdb
chown 1000:1000 /var/lib/faasd/influxdbThen reload and restart:
sudo systemctl daemon-reload \
&& sudo systemctl restart faasdCreate a secret for the InfluxDB user:
export PASSWORD=""
faas-cli secret create influx-password --from-literal $PASSWORD
faas-cli secret create influx-user --from-literal adminSet the influx_db env-var in stack.yml i.e. 192.168.0.21
Next, deploy the function:
faas-cli deployBuild if you like:
faas-cli publish -f stack.yml --platforms linux/arm/7Copy the sender folder to your Raspberry Pi and run:
FUNCTION_URL=http://192.168.0.21:8080/function/submit-sample \
SENSOR=my-shed \
python3 main.pyDeploy Grafana to faasd using the instructions in the eBook Serverless For Everyone Else
Then create yourself a simple dashboard for the measurements you see in the "readings" database.
Once you have it up and running, create a datasource, then import the dashboard.json file and open the dashboard to view your sensor readings.
My very cold shed - measured overnight!