Skip to content

RonnyCHL/emsn2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

691 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EMSN 2.0

DOI License

Ecologisch Monitoring Systeem Nijverdal

"Je beschermt wat je kent"

Een gedistribueerd biodiversiteitsmonitoring systeem voor real-time detectie en analyse van vogels, weer, atmosferische condities en nestkast monitoring.


Overzicht

EMSN 2.0 is een netwerk van Raspberry Pi's dat continu de lokale biodiversiteit monitort in Nijverdal, Overijssel:

  • Vogeldetectie via BirdNET-Pi op 2 vaste + 1 mobiel station
  • Akoestische lokalisatie via stereo microfoons (Noord/Zuid richtingsdetectie)
  • Vocalisatieanalyse via CNN modellen (zang vs. roep classificatie)
  • Weermonitoring via Davis Vantage Pro 2
  • Hemelmonitoring via HQ Camera IMX477 (AtmosBird - ISS, maan, meteoren, sterren)
  • Nestkast cameras via 3 Tuya cameras met go2rtc streaming
  • Vogeltrekradar via KNMI FlySafe integratie
  • Real-time displays op Ulanzi TC001 LED matrix + CYD touchscreen
  • AI-gegenereerde rapporten via Claude API
  • Centrale database op Synology NAS met PostgreSQL
  • 27 Grafana dashboards voor data visualisatie
  • Mobiel veldstation met GPS, 4G en Witty Pi 5 energiebeheer

Stations

Station IP Hardware Functie
emsn2-zolder 192.168.1.178 RPi 5, Steinberg UR22mkII BirdNET-Pi, MQTT broker, API server, stereo lokalisatie
emsn2-berging 192.168.1.87 RPi 5, Steinberg UR44 BirdNET-Pi, AtmosBird HQ Camera, CYD display
emsn2-meteo 192.168.1.156 RPi Zero 2W Davis Vantage Pro 2 weerstation
emsn2-mobiel 192.168.1.80 RPi 5, WP5, 4G, GPS Mobiel veldstation
Synology NAS 192.168.1.25 DS224+ PostgreSQL, Grafana, go2rtc, Docker
Ulanzi TC001 192.168.1.11 ESP32, AWTRIX Light Real-time LED matrix display
CYD Berging DHCP ESP32-2432S028 320x240 touchscreen dashboard

Architectuur

┌──────────────────────────────────────────────────────────────────────┐
│                         EMSN 2.0 Network                            │
├──────────────────────────────────────────────────────────────────────┤
│                                                                      │
│  ┌──────────┐  ┌──────────┐  ┌──────────┐  ┌──────────┐            │
│  │  Zolder  │  │ Berging  │  │  Meteo   │  │  Mobiel  │            │
│  │BirdNET-Pi│  │BirdNET-Pi│  │Davis VP2 │  │BirdNET-Pi│            │
│  │ Stereo   │  │AtmosBird │  │          │  │GPS + 4G  │            │
│  │Lokalisatie│ │CYD Display│ │          │  │WittyPi 5 │            │
│  └────┬─────┘  └────┬─────┘  └────┬─────┘  └────┬─────┘            │
│       │              │              │              │                  │
│       └──────────────┼──────────────┼──────────────┘                  │
│                      │              │                                 │
│                      ▼              │                                 │
│             ┌──────────────┐        │                                 │
│             │ MQTT Broker  │◄───────┘                                 │
│             │(192.168.1.178)│                                         │
│             └──────┬───────┘                                          │
│                    │                                                  │
│       ┌────────────┼────────────┬──────────────┐                     │
│       ▼            ▼            ▼              ▼                     │
│  ┌─────────┐ ┌──────────┐ ┌─────────┐  ┌──────────┐                │
│  │PostgreSQL│ │  Ulanzi  │ │  CYD    │  │Nestkast  │                │
│  │  (NAS)  │ │  TC001   │ │Berging  │  │ Cameras  │                │
│  │  :5433  │ │LED Matrix│ │320x240  │  │  go2rtc  │                │
│  └────┬────┘ └──────────┘ └─────────┘  └──────────┘                │
│       │                                                              │
│  ┌────┴────┐                                                         │
│  │ Grafana │                                                         │
│  │  27x    │                                                         │
│  │Dashboard│                                                         │
│  └─────────┘                                                         │
│                                                                      │
└──────────────────────────────────────────────────────────────────────┘

Modules

Core (scripts/core/)

Gedeeld fundament voor alle EMSN scripts.

Module Functie
config.py Centrale configuratie, paden, station detectie
database.py PostgreSQL connection pooling
logging.py Gestructureerde logging met MQTT
exception_handler.py Error handling met alerts
email_alerts.py Rate-limited email alerting
health.py Health checks en dependency verificatie
migrations.py Database schema versioning

Sync (scripts/sync/)

Synchronisatie tussen lokale SQLite en centrale PostgreSQL.

Script Functie Timer
lifetime_sync.py Detecties → PostgreSQL Elk uur
hardware_monitor.py System metrics 5 min
dual_detection_sync.py Match dual-station detecties 5 min

Audio Analyse (scripts/audio/)

Geavanceerde analyse van vogelgeluiden.

Script Functie
direction_analyzer.py Stereo richtingsdetectie (Noord/Zuid)
direction_enricher.py Continue verrijking van detecties

Vocalisatie (scripts/vocalization/)

CNN-gebaseerde classificatie van vocalisatietypes.

Script Functie
vocalization_enricher.py Database integratie
vocalization_classifier.py CNN inference (197 soortmodellen)

Display (scripts/display/)

Real-time visualisatie op hardware displays.

Script Functie
cyd_stats_publisher.py Stats naar MQTT voor CYD display
atmosbird_image_server.py Sky foto server voor CYD (port 5000)
lcd_display.py 1602 LCD display service

CYD Display (cyd-berging/)

ESP32 touchscreen dashboard met 14 auto-roterende schermen.

Scherm Inhoud
Live Laatste detectie met confidence, station, tijdstip
Dagoverzicht Top 5 soorten met horizontale staven
Hardware 4 arc gauges (CPU + Disk, beide stations)
Soorten per uur Lijngrafiek Zolder/Berging met uurmarkering
Weer Temperatuur, wind, RH, neerslag
Berging/Zolder Station Lifetime stats per station
Soortenlijst Scrollende lijst alle soorten vandaag
Weekoverzicht Staafgrafiek deze week vs vorige week
AtmosBird Live hemelfoto van HQ camera
AtmosBird Hardware Temperatuur, luchtvochtigheid, heater
CPU Temp Weekgrafiek CPU temperaturen beide stations
Logo EMSN branding en motto

Ulanzi (scripts/ulanzi/)

Real-time notificaties op Ulanzi TC001 LED matrix.

Script Functie
ulanzi_bridge.py MQTT → Display notificaties
rarity_cache_refresh.py Zeldzaamheid tier berekening

Features:

  • 5-tier zeldzaamheidssysteem
  • RTTTL melodieen per tier
  • Nederlandse vogelnamen met richting
  • Anti-spam cooldowns
  • Milestone notificaties

AtmosBird (scripts/atmosbird/)

24/7 hemelmonitoring met HQ Camera IMX477 (140 graden FOV).

Script Functie Timer
atmosbird_capture.py Foto's elke 10 min 10 min
atmosbird_analysis.py ISS, maan, meteoor detectie 15 min
atmosbird_timelapse.py Dagelijkse timelapse video Dagelijks
atmosbird_archive_sync.py Sync naar NAS + cleanup Elk uur

Nestkast Cameras (scripts/nestbox/)

Monitoring van 3 nestkast cameras via Tuya + go2rtc.

Script Functie
nestbox_api.py REST API voor events, media, captures
nestbox_screenshot.py Automatische screenshots (6x/dag)

FlySafe (scripts/flysafe/)

KNMI vogeltrekradar integratie.

Script Functie
flysafe_scraper.py Download radar images
color_analyzer.py Analyseer migratie intensiteit
migration_alerts.py Alerts bij hoge migratie

Monitoring (scripts/monitoring/)

Systeemgezondheid en alerting.

Script Functie
timer_watchdog.py Monitor timers + services, auto-fix
deep_health_check.py Uitgebreide gezondheidscheck
reboot_alert.py Detecteer onverwachte reboots

Backup (scripts/backup/)

Gelaagd backup systeem naar NAS + HiDrive cloud.

Script Functie Timer
sd_backup_rsync.py Rsync naar NAS + HiDrive Dagelijks 02:00
sd_backup_weekly.py Raw SD image naar NAS Maandelijks
pg_cloud_backup.py PostgreSQL dump → HiDrive Dagelijks 03:00

Reports (scripts/reports/)

AI-gegenereerde rapporten via Claude API.

Script Functie Schedule
weekly_report.py Weekrapport in Markdown Maandag 07:00
monthly_report.py Maandrapport 1e van maand

Projectstructuur

emsn2/
├── assets/                 # Logo's en afbeeldingen
├── config/                 # Configuratie bestanden
├── cyd-berging/            # ESP32 CYD display firmware (PlatformIO)
│   └── src/                # C++ broncode (14 schermen)
├── database/               # SQL schema & migraties
│   └── migrations/         # Versie-beheerde schema wijzigingen
├── docs/                   # Documentatie
│   └── samenvattingen/     # Sessie samenvattingen
├── grafana/                # Dashboard JSON exports
├── scripts/                # Alle Python scripts
│   ├── analysis/           # Data analyse
│   ├── anomaly/            # Anomalie detectie
│   ├── api/                # REST API servers
│   ├── archive/            # Audio/spectrogram archief
│   ├── atmosbird/          # Hemelmonitoring
│   ├── audio/              # Stereo richtingsdetectie
│   ├── backup/             # Backup systeem
│   ├── core/               # Gedeeld fundament
│   ├── display/            # CYD + LCD display
│   ├── flysafe/            # Vogeltrekradar
│   ├── monitoring/         # Health checks & watchdogs
│   ├── mqtt/               # MQTT bridge & tools
│   ├── nestbox/            # Nestkast cameras
│   ├── reports/            # AI rapporten
│   ├── sync/               # Database synchronisatie
│   ├── ulanzi/             # LED matrix display
│   └── vocalization/       # CNN vocalisatie analyse
├── systemd/                # Service & timer bestanden
└── tests/                  # Pytest tests

MQTT Topics

Topic Beschrijving Formaat
birdnet/{station}/detection Live detectie JSON
emsn2/{station}/health/metrics Hardware status JSON
emsn2/meteo/weather/current Weerdata JSON
emsn2/dual/detection Dual-station detectie JSON
emsn2/alerts/rare_species Zeldzame soort alert JSON
emsn2/stats/today/* Dagstatistieken JSON/int
emsn2/stats/week/* Weekstatistieken JSON
emsn2/stats/lifetime/* Lifetime totalen int
emsn2/stats/hardware/cpu_temp_week CPU temp historie JSON
emsn2/{station}/reboot Reboot informatie JSON (retained)
emsn2/{station}/unit_watchdog Service status JSON

Database Schema

Belangrijkste tabellen in PostgreSQL (NAS, port 5433):

Tabel Beschrijving
bird_detections Alle vogeldetecties met richting + vocalisatie
system_health Hardware metrics per station
weather_data Weermetingen Davis VP2
sky_observations AtmosBird metingen
nestbox_events Nestkast observaties
nestbox_media Screenshots en video's
species_rarity_cache Zeldzaamheid per soort
vocalization_training CNN model training status
backup_status Backup status per station

Installatie

Prerequisites

  • Raspberry Pi OS (64-bit, Bookworm)
  • Python 3.13+
  • PostgreSQL 15+ (op NAS)
  • Mosquitto MQTT broker
  • PlatformIO (voor CYD display, op Berging Pi)

Setup

# Clone repository
git clone https://github.com/RonnyCHL/emsn2.git
cd emsn2

# Maak virtual environment
python3 -m venv venv
source venv/bin/activate

# Installeer dependencies
pip install -r requirements.txt

# Credentials configureren
cp .secrets.example .secrets
nano .secrets  # Vul credentials in

# Kopieer systemd services
sudo cp systemd/*.service systemd/*.timer /etc/systemd/system/
sudo systemctl daemon-reload

Statistieken

Metric Waarde
Python scripts 270
Regels Python code ~100.000
Systemd services 110
Systemd timers 73
Grafana dashboards 27
Git commits 634+
CYD schermen 14
CNN modellen 197
Nestkast cameras 3
BirdNET stations 3 (2 vast + 1 mobiel)

Credits

Ontwikkeld door Ronny Hullegie met assistentie van Claude AI (Anthropic).


Een liefdesbrief aan de natuur, geschreven in Python

About

EcoMonitoring Systeem Nijverdal 2.0

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors