-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e481e7c
Showing
49 changed files
with
8,486 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.pio | ||
.vscode/.browse.c_cpp.db* | ||
.vscode/c_cpp_properties.json | ||
.vscode/launch.json | ||
.vscode/ipch | ||
.vscode/extensions.json | ||
.vscode/settings.json | ||
extra.ini | ||
data/mqtt_root_ca.pem | ||
data/mqtt_server_cert.pem | ||
data/root_ca.pem | ||
docker/nodered/.npm | ||
docker/nodered/node_modules | ||
docker/nodered/*.backup | ||
docker/influxdb/engine | ||
docker/nodered/package-lock.json | ||
docker/influxdb/data | ||
docker/influxdb/config | ||
docker/grafana/alerting | ||
docker/grafana/grafana.db | ||
docker/nodered/.config.runtime.json | ||
docker/nodered/.config.users.json | ||
docker/nodered/flows_cred.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"build": { | ||
"arduino": { | ||
"ldscript": "esp32s3_out.ld" | ||
}, | ||
"core": "esp32", | ||
"extra_flags": [ | ||
"-DARDUINO_ESP32S3_DEV", | ||
"-DARDUINO_USB_MODE=1", | ||
"-DARDUINO_RUNNING_CORE=1", | ||
"-DARDUINO_EVENT_RUNNING_CORE=1" | ||
], | ||
"f_cpu": "240000000L", | ||
"f_flash": "80000000L", | ||
"flash_mode": "qio", | ||
"hwids": [["0X303A", "0x1001"]], | ||
"mcu": "esp32s3", | ||
"variant": "esp32s3" | ||
}, | ||
"connectivity": ["wifi"], | ||
"debug": { | ||
"default_tool": "esp-builtin", | ||
"onboard_tools": ["esp-builtin"], | ||
"openocd_target": "esp32s3.cfg" | ||
}, | ||
"frameworks": ["arduino", "espidf"], | ||
"name": "Espressif ESP32-S3-1-N4 (4 MB QD, No PSRAM)", | ||
"upload": { | ||
"flash_size": "4MB", | ||
"maximum_ram_size": 327680, | ||
"maximum_size": 4194304, | ||
"require_upload_port": true, | ||
"speed": 460800 | ||
}, | ||
"url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/user-guide-devkitc-1.html", | ||
"vendor": "Espressif" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"deviceId": 0, | ||
"mqttTopic": "aranetproxy", | ||
"mqttUsername": "aranetproxy", | ||
"mqttPassword": "aranetproxy", | ||
"mqttHost": "127.0.0.1", | ||
"mqttServerPort": 1883, | ||
"mqttUseTls": false, | ||
"mqttInsecure": false, | ||
"ssd1306Rows": 64, | ||
"scanInterval": 300 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
TZ=Pacific/Auckland |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
version: "3" | ||
services: | ||
mqtt: | ||
image: eclipse-mosquitto:openssl | ||
container_name: mosquitto | ||
volumes: | ||
- ./mosquitto/:/mosquitto/:rw | ||
ports: | ||
- "1883:1883" | ||
networks: | ||
- co2mon | ||
env_file: | ||
- .env | ||
- mosquitto.env | ||
restart: unless-stopped | ||
logging: | ||
driver: "json-file" | ||
options: | ||
max-size: "1m" | ||
max-file: "5" | ||
nodered: | ||
image: nodered/node-red | ||
container_name: nodered | ||
volumes: | ||
- ./nodered:/data | ||
ports: | ||
- "1880:1880" | ||
networks: | ||
- co2mon | ||
env_file: | ||
- .env | ||
- nodered.env | ||
restart: unless-stopped | ||
depends_on: | ||
- influxdb | ||
- mqtt | ||
logging: | ||
driver: "json-file" | ||
options: | ||
max-size: "1m" | ||
max-file: "5" | ||
influxdb: | ||
image: influxdb | ||
container_name: influxdb | ||
volumes: | ||
- ./influxdb/data:/var/lib/influxdb2 | ||
- ./influxdb/config:/etc/influxdb2 | ||
ports: | ||
- "8086:8086" | ||
networks: | ||
- co2mon | ||
env_file: | ||
- .env | ||
- influxdb.env | ||
restart: unless-stopped | ||
logging: | ||
driver: "json-file" | ||
options: | ||
max-size: "1m" | ||
max-file: "5" | ||
grafana: | ||
image: grafana/grafana | ||
container_name: grafana | ||
volumes: | ||
- ./grafana:/var/lib/grafana | ||
- ./grafana/provisioning:/etc/grafana/provisioning | ||
ports: | ||
- "3000:3000" | ||
networks: | ||
- co2mon | ||
env_file: | ||
- .env | ||
- grafana.env | ||
depends_on: | ||
- influxdb | ||
restart: unless-stopped | ||
logging: | ||
driver: "json-file" | ||
options: | ||
max-size: "1m" | ||
max-file: "5" | ||
networks: | ||
co2mon: | ||
driver: bridge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Docker backend running Mosquitto InfluxDB Node-Red Grafana | ||
|
||
## Preparation | ||
|
||
Before running the docker compose file have a look at the various \*.env files and change the provided default passwords. | ||
Make sure not to expose this directly to the internet without additional and read the following resources on further securing the various components | ||
|
||
- [Grafana](https://grafana.com/docs/grafana/next/setup-grafana/configure-security/) | ||
- [Node-Red](https://nodered.org/docs/user-guide/runtime/securing-node-red) | ||
- [Mosquitto](https://mosquitto.org/documentation/) | ||
- [InfluxDB](https://hub.docker.com/_/influxdb) | ||
- Set a `credentialSecret` in [Node Red's settings.js](./nodered/settings.js#L44) | ||
|
||
## Starting | ||
|
||
Run `docker-compose up` | ||
|
||
## Mosquitto | ||
|
||
- Mosquitto is pre-configured using the [mosquitto.acl](./mosquitto/config/mosquitto.acl) and [mosquitto.passwd](./mosquitto/config/mosquitto.passwd) files. The default users/passwords are | ||
- `admin` // `admin` | ||
- `aranetproxy` // `aranetproxy` | ||
- `nodered` // `nodered` | ||
- to change any of the above passwords use `docker exec mosquitto mosquitto_passwd -b /mosquitto/config/mosquitto.passwd {username} {password}`. Restart Mosquitto for the changes to become effective `docker restart mosquitto` | ||
|
||
## Configure InfluxDB | ||
|
||
### Using the UI | ||
|
||
- Open http://127.0.0.1:8086/ and log on using the admin user and password form the [influxdb.env](influxdb.env) file | ||
- Navigate to `Load data` -> `API tokens` and generate a `Read/Write API Token` for Node-red | ||
- Description `nodered` | ||
- Select scoped read and write access for the `co2monitors` bucket | ||
- the token will later be entered in a Node-red configuration node | ||
- Create another token for Grafana | ||
- Description `grafana` | ||
- Select scoped read access for the `co2monitors` bucket | ||
- the token will later be entered in Grafana | ||
|
||
### Using the CLI | ||
|
||
- Create and note API tokens | ||
- Node-red `docker exec influxdb bash -c "influx auth create -o CO2Monitors -d nodered --write-bucket $(influx bucket list | grep co2monitors | cut -f 1) --read-bucket $(influx bucket list | grep co2monitors | cut -f 1) | grep nodered | cut -f 4"` | ||
- Grafana `docker exec influxdb bash -c "influx auth create -o CO2Monitors -d grafana --read-bucket $(influx bucket list | grep co2monitors | cut -f 1) | grep grafana | cut -f 4"` | ||
- (optional) run `docker exec influxdb bash -c "influx auth list --user admin --hide-headers | cut -f 3"` to retrieve the admin API token | ||
|
||
## Configure Node-Red | ||
|
||
### Using the UI | ||
|
||
- Open http://127.0.0.1:1880/ | ||
- Open the `Manage palette` menu to add the missing plug-ins | ||
- Got to the `Install` tab and add the following plug-ins | ||
- node-red-contrib-influxdb | ||
- node-red-node-email | ||
- Open `Configuration nodes` in the menu and select open the `[v2.0] influxdb` node | ||
- Enter the `nodered` API token previously created in InfluxDB | ||
- Open the `Mosquitto` Docker configuration node and enter the Mosquitto username and password (default `nodered` // `nodered` ) | ||
- Deploy the changes using the top right Deploy menu. Deploying `Modified nodes` only is sufficient. The Mosquitto nodes should now show `connected` | ||
- to enable email alerts and status messages configure the email node and enable it. | ||
|
||
### Using the CLI | ||
|
||
- Install the missing plug-ins `docker exec nodered npm install node-red-contrib-influxdb node-red-node-email` | ||
- Restart Node-Red `docker restart nodered` | ||
- Follow the steps above to configure the `Configuration nodes` on hte UI | ||
|
||
### Finishing | ||
|
||
- Once you have a CO2 monitor connected check out the Node-Red Dashboard http://127.0.0.1:1880/ui/. You might need to trigger the `Refresh monitors` flow in the `CO2 Monitors UI` tab first, or wait until it runs every hour. | ||
- The `Get configuration` flow on the `CO2 monitors` tab runs daily and queries all monitors for their current configuration. This will show on the UI once a monitor is selected in the drop down and is also visible in the dedicated Grafana dashboard. | ||
|
||
## Configure Grafana | ||
|
||
- Open http://127.0.0.1:3000/ and log in using the user and password configured in [`grafana.env`](grafana.env) | ||
- Open the `Data sources` entry from the bottom left Configuration menu and click on `InfluxDB` | ||
- Enter the grafana token previously created in Influx | ||
- Confirm with `Save and test` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
GF_AUTH_ANONYMOUS_ENABLED=true | ||
GF_AUTH_ANONYMOUS_ORG_NAME=CO2Monitor | ||
GF_AUTH_ANONYMOUS_ORG_ROLE=Viewer | ||
GF_SECURITY_ADMIN_USER=admin | ||
GF_SECURITY_ADMIN_PASSWORD=*grafana-admin-password* | ||
GF_ANALYTICS_REPORTING_ENABLED=false | ||
GF_LIVE_ALLOWED_ORIGINS=* | ||
GF_PATHS_CONFIG=/var/lib/grafana/grafana.ini |
Oops, something went wrong.