Skip to content

Commit

Permalink
â✨ Project datagnome was born
Browse files Browse the repository at this point in the history
  • Loading branch information
romses committed Jul 11, 2023
0 parents commit a9253e3
Show file tree
Hide file tree
Showing 29 changed files with 2,757 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
site/
venv/
docker/grafana/*
docker/influx-data/*
docker/www-data/*
.env
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Datenzwerg

## Development

Install Python 3.11. Then

1. `python -m venv venv`
2. `source venv/bin/activate`
3. `pip install -r requirements.txt`

This will install all dependencies for firmware and documentation development into a virtual environment and activate it. To leave the virtual environment, run `deactivate`.

### Firmware

The Datenzwerg firmware is based on [esphome](https://esphome.io/) which gets installed as dependency when running the above setup command.

To flash your own Datenzwerg, navigate to the `firmware` directory, then

1. Copy `secrets-template.yaml` to `secrets.yaml` and fill in your WiFi and InfluxDB2 credentials.
2. Run `esphome -s name <gnome> firmware.yaml run` to compile and flash the firmware for your gnome named `<gnome>`.

### Models

The gnome model files are based on https://www.printables.com/model/260908-garden-gnome by [Sci3D](https://www.printables.com/@Sci3D), released under CC-BY.

In the `models` directory, you will find the following files:

- `datenzwerg_40p_1.2mm.blend`: Main design file, edit with [Blender](https://blender.org)
- `datenzwerg_40p_1.2mm_top.stl`: Upper body, electronics compartment
- `datenzwerg_40p_1.2mm_bottom.stl`: Lower body, feet, mount point
- `datenzwerg_40p_1.2mm_bottom_filled.stl`: Lower body, feet, mount point, fully filled

### Documentation

The documentation is built with [MkDocs](https://www.mkdocs.org/) which gets installed as dependency when running the above setup command. The documentation source files are located in the `docs` directory, the configuration in `mkdocs.yml` in the project root.

To run a live-reload server, run

```
mkdocs serve
```

To build the documentation, run

```
mkdocs build
```
23 changes: 23 additions & 0 deletions docker/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Config File for InfluxDB and Chronograf

# Docker Compose Project Name
# max length 11 characters
PROJECT_NAME=influxdb2

# InfluxDB Configuration
INFLUXDB_HTTP_PORT=8086
INFLUXDB_INIT_MODE=setup
INFLUXDB_INIT_USERNAME=influxuser
INFLUXDB_INIT_PASSWORD=influxpasswd
INFLUXDB_INIT_ORG=myorg
INFLUXDB_INIT_BUCKET=datenzwerg
INFLUXDB_INIT_ADMIN_TOKEN=mytoken
INFLUXD_LOG_LEVEL=warn

# Timezone
TZ=Europe/Berlin

# Grafana Env
GF_SECURITY_ADMIN_PASSWORD=grafanapasswd
GF_USERS_ALLOW_SIGN_UP=true
GF_SERVER_ROOT_URL=http://grafana.datagnome.de/
75 changes: 75 additions & 0 deletions docker/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
version: '3.9'
services:
traefik:
image: "traefik:v2.10"
container_name: "traefik"
command:
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
ports:
- "80:80"
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
networks:
- proxy

apache:
image: httpd:latest
container_name: frontend
networks:
- proxy
volumes:
- ./www-data:/usr/local/apache2/htdocs
labels:
- traefik.enable=true
- traefik.http.routers.datagnome.rule=Host(`datagnome.de`) # && Path=`/`
- traefik.http.routers.datagnome.entrypoints=web
networks:
- proxy

grafana:
image: grafana/grafana:latest
container_name: grafana
volumes:
- ./grafana/:/var/lib/grafana
- ./grafana.ini:/etc/grafana/grafana.ini
env_file: .env
restart: always
user: "1000"
networks:
- proxy
labels:
- traefik.enable=true
- traefik.docker.network=proxy
- traefik.http.routers.grafana.entrypoints=web
- traefik.http.routers.grafana.rule=Host(`grafana.datagnome.de`)
- traefik.http.routers.grafana.middlewares=grafana-strip
- traefik.http.middlewares.grafana-strip.stripprefix.prefixes=/grafana
- traefik.http.routers.grafana.service=grafana-service
- traefik.http.services.grafana-service.loadbalancer.server.port=3000

influxdb:
image: influxdb:2.6-alpine
volumes:
- ./influx-data:/var/lib/influxdb2:rw
env_file: .env
ports:
- "8086:8086"
networks:
- proxy
labels:
- traefik.enable=true
- traefik.docker.network=proxy
- traefik.http.routers.influxdb.entrypoints=web
- traefik.http.routers.influxdb.rule=Host(`influxdb.datagnome.de`)
- traefik.http.routers.influxdb.middlewares=influxdb-strip
- traefik.http.middlewares.influxdb-strip.stripprefix.prefixes=/influxdb
- traefik.http.routers.influxdb.service=influxdb-service
- traefik.http.services.influxdb-service.loadbalancer.server.port=8086

networks:
proxy:
external: true
5 changes: 5 additions & 0 deletions docker/grafana.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[security]
allow_embedding = true
[auth.anonymous]
# enable anonymous access
enabled = true
82 changes: 82 additions & 0 deletions docs/how_to_build.de.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Wie man einen Datenzwerg baut

!!! warning

Der Datenzwerg wurde für das [CCCamp23](https://events.ccc.de/camp/2023/infos/) entwickelt. Hardware, Firmware und Modelle wurden für einen bestimmten Zweck und eine bestimmte Nutzungsdauer entwickelt und sind möglicherweise nicht für andere Anwendungsfälle geeignet. Der Datenzwerg wird wie er ist ohne jegliche Garantie, Pläne zur Verbesserung oder Behebung oder andere Unterstützung bereitgestellt. Wenn du deinen eigenen Datenzwerg bauen möchtest, bist du auf dich allein gestellt.

## Voraussetzungen

Einen Datenzwerg zu bauen erfordert etwas Löterfahrung und 3D-Druckkenntnisse.

Die Firmware, die für den Datenzwerg zur Verfügung gestellt wird, erfordert, dass du ihr Zugangsdaten für ein vorhandenes WiFi-Netzwerk (SSID und Passwort) und auch Zugang zu einer [InfluxDB2](https://influxdb.com)-Instanz (Host, Port, Organisations-ID, Bucket-Name und schreibfähiges Zugriffstoken) zur Verfügung stellst. Du musst diese Zugangsdaten in einer Datei namens `secrets.yaml` im Verzeichnis `firmware` angeben. Eine Vorlage für diese Datei findest du in `firmware/secrets-template.yaml`.

## Teile

### Elektronik

Um deinen eigenen Datenzwerg zu bauen, benötigst du folgende Teile:

- 1x D1 mini mit Pinheadern
- 1x ADS1115 I2C 16-bit ADC auf Breakout-Board und Pinheadern
- 1x BME280 I2C Temperatur-, Luftfeuchtigkeits- und Luftdrucksensor auf Breakout-Board
- 1x UV sensitiver Photoresistor mit Opamp auf einem Breakout-Board
- 1x Mikrofonmodul (TBD, vermutlich MAX4466) auf Breakout-Board
- 1x 18650 LiPo mit Halter
- 1x TP4065 LiPo Lademodul
- 1x 5V Boost-Converter-Modul
- 3x männliche 3-pin JST Verbinder und weibliche Kabel
- 1x männlicher 4-pin JST Verbinder und weibliches Kabel
- Lochraster o.ä. um die Elektronik darauf zusammen zu löten

### Zwergenkörper

Wenn du den Datenzwerg in seinen Zwergenkörper stecken möchtest, benötigst du außerdem:

- 1x 3D gedrucktes Zwergenoberteil (siehe `models` Verzeichnis im GitHub Repository)
- 1x 3D gedrucktes Zwergenunterteil (siehe `models` Verzeichnis im GitHub Repository)
- 6x 6x1mm Neodymium Magnete
- Sekundenkleber

!!! note

Es ist sehr empfehlenswert, das Zwergenoberteil mit einer 0,6mm Düse und 0,4mm Schichthöhe zu drucken. Das Modell ist für diese Kombination ausgelegt und funktioniert möglicherweise nicht mit anderen Düsen- oder Schichthöhen.

## Zusammenbau

### Mainboard

TODO

### Sensoren

TODO

### Stromversorgung

TODO

### Zwergenkörper

Mit dem Sekundenkleber die Magnete in die Löcher in Zwergenunter- und -oberteil kleben. Achte darauf, dass die Polarität stimmt, d.h. die Magnete ziehen sich an, wenn das Zwergenoberteil auf das Zwergenunterteil gesetzt wird. Die Magnete sollten bündig mit der Oberfläche abschließen.

## Firmware flashen

Stelle sicher, dass der Datenzwerg vom Strom getrennt ist. Ziehe den D1 mini vom Mainboard ab und verbinde ihn mit deinem Computer via USB.

Installiere Python 3.11. Check das [GitHub Repository](https://github.com/romses/Datenzwerg) aus und führe darin die folgenden Befehle aus:

1. `python -m venv venv`
2. `source venv/bin/activate`
3. `pip install -r requirements.txt`

Das installiert alle Abhängigkeiten, die für den Bau der Firmware und der Dokumentation benötigt werden, in ein virtuelles Environment und aktiviert es.

Dann navigiere zum `firmware` Verzeichnis. Kopiere `secrets-template.yaml` nach `secrets.yaml` und fülle deine WiFi- und InfluxDB2-Zugangsdaten ein. Dann führe die folgenden Befehle aus:

```
esphome -s name <gnome> datenzwerg.yaml run
```

Damit wird die Firmware für deinen Zwerg mit dem Namen `<gnome>` kompiliert und geflasht (d.h. wenn du z.B. die Firmware für den Zwerg mit dem Namen `zwerg` flashen möchtest, führe `esphome -s name zwerg datenzwerg.yaml run` aus).

Steck den D1 mini wieder auf das Mainboard und verbinde den Datenzwerg mit Strom. Er sollte sich mit deinem WiFi verbinden und Daten an die konfigurierte InfluxDB senden.
82 changes: 82 additions & 0 deletions docs/how_to_build.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# How to build a Datenzwerg

!!! warning

The Datenzwerg was developed for the [CCCamp23](https://events.ccc.de/camp/2023/infos/). Hardware, firmware and models were designed for a specific purpose and a specific deployment duration and might not be suitable for other use cases. The Datenzwerg is provided as-is without any warranty, plans to improve or fix it or any other support. If you want to build your own Datenzwerg, you are on your own.

## Prerequisites

Building a Datenzwerg requires some soldering and 3D printing skills.

The firmware provided with the Datenzwerg requires you to provide it with credentials for an existing WiFi network (SSID and password) and also access to an [InfluxDB2](https://influxdb.com) instance (host, port, organization id, bucket name and write-enabled access token). You will need to provide these credentials in a file called `secrets.yaml` in the `firmware` directory. A template for this file is provided in `firmware/secrets-template.yaml`.

## Parts

### Electronics

To build your own Datenzwerg, you will need the following parts:

- 1x D1 mini or compatible ESP8266 board with pin headers
- 1x ADS1115 or compatible I2C 16-bit ADC on a breakout board and with pin headers
- 1x BME280 or compatible I2C temperature, humidity and pressure sensor on a breakout board
- 1x basic UV sensitive photoresistor with opamp on a breakout board
- 1x microphone module (TBD, possibly MAX4466) on a breakout board
- 1x 18650 LiPo battery with holder
- 1x TP4065 LiPo charger module
- 1x 5V boost converter module
- 3x male 3-pin JST connectors and female cables
- 1x male 4-pin JST connector and female cable
- some perfboard to solder everything together on

### Gnome body

If you want to put the Datenzwerg into its gnome body, you will also need:

- 1x 3D printed gnome body top (see `models` directory in the GitHub repository)
- 1x 3D printed gnome body bottom (see `models` directory in the GitHub repository)
- 6x 6x1mm neodymium magnets
- superglue

!!! note

It is strongly recommended to print the gnome body with a 0.6mm nozzle and 0.4mm layer height. The model is designed for this combination and might not work with other nozzle sizes or layer heights.

## Assembly

### Mainboard

TODO

### Sensors

TODO

### Power supply

TODO

### Gnome body

Using superglue, glue the magnets into the holes in the gnome body bottom. Make sure the polarity is correct, i.e. the magnets attract each other when the gnome body top is placed on the bottom. The magnets should be flush with the surface of the gnome body bottom.

## Flashing the firmware

Make sure the power is disconnected from the Datenzwerg's mainboard. Unplug the D1 mini from the mainboard and connect it to your computer via USB.

Install Python 3.11. Check out the [GitHub repository]() and therein run

1. `python -m venv venv`
2. `source venv/bin/activate`
3. `pip install -r requirements.txt`

This will install all dependencies needed to build the firmware and the documentation into a virtual environment and activate it.

Then, navigate to the `firmware` directory. Copy `secrets-template.yaml` to `secrets.yaml` and fill in your WiFi and InfluxDB2 credentials. Then run

```
esphome -s name <gnome> datenzwerg.yaml run
```

to compile and flash the firmware for your gnome named `<gnome>` (e.g. if you want to flash the firmware for the gnome named `zwerg`, run `esphome -s name zwerg datenzwerg.yaml run`).

Plug the D1 mini back into the mainboard and reconnect the power. It should connect to your WiFi and start sending data to the configured InfluxDB.
19 changes: 19 additions & 0 deletions docs/index.de.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Der Datenzwerg

TODO

## Eine kurze Geschichte des Datenzwergs

2023-06-11
: Die Idee des Datenzwergs wird gebohren am letzten Tag der [GPN21](https://entropia.de/GPN21), kurz vor der gemeinsamen Barschicht von [@romses](https://chaos.social/@romses)
und [@foosel](https://chaos.social/@foosel). Die ruhigeren Momente der Barschicht sowie die Rückfahrt ins Rhein-Main-Gebiet werden für die Diskussion der Idee genutzt. Romses
registriert eine Domain.

2023-06-30
: Romses und foosel treffen sich für eine gemeinsame Bastelsession. Die ersten zwei Mainboards werden gebaut. Der Datenzwerg lebt!

2023-07-08
: Eine weitere gemeinsame Bastelsession. Weitere 8 Mainboards werden gebaut. Die Datenzwerg-Armee wächst!

2023-08-15 - 2023-08-19
: Geplanter Datenzwerg Einsatz auf dem [CCCamp23](https://events.ccc.de/camp/2023/infos/).
18 changes: 18 additions & 0 deletions docs/index.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# The Datenzwerg

TODO

## A short history of the Datenzwerg

2023-06-11
: The idea of the Datenzwerg is born at the final day of [GPN21](https://entropia.de/GPN21), just before a joint bar shift by [@romses](https://chaos.social/@romses) and [@foosel](https://chaos.social/@foosel).
Slow parts of the shift as well as the drive back to the Rhein-Main-Area are spent discussing the idea. Romses registers a domain name.

2023-06-30
: romses and foosel meet up for a joint tinkering session. The first two mainboards are built. The Datenzwerg is alive!

2023-07-08
: Another joint tinkering session takes place. Another 8 mainboards are built. The Datenzwerg army is growing!

2023-08-15 - 2023-08-19
: Planned Datenzwerg deployment at [CCCamp23](https://events.ccc.de/camp/2023/infos/).
3 changes: 3 additions & 0 deletions firmware/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.esphome/
secrets.yaml

8 changes: 8 additions & 0 deletions firmware/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Datenzwerg Firmware

The Datenzwerg Firmware is based on [esphome](https://esphome.io/).

To flash your own Datenzwerg, first install esphome, then

1. Copy `secrets-template.yaml` to `secrets.yaml` and fill in your WiFi and InfluxDB2 credentials.
2. Run `esphome -s name <gnome> firmware.yaml run` to compile and flash the firmware for your gnome named `<gnome>`.
Loading

0 comments on commit a9253e3

Please sign in to comment.