This Project aims to collect sensor data from a Raspberry PI to visualize them on a webpage.
Find a file
2025-06-18 10:15:06 +02:00
.direnv added websocket. The file sensors/sender.py can be usede to send data to 2025-06-17 09:54:36 +02:00
_trash Die Sensoren sind fertig. Der Python Code müsste passen. 2025-06-17 09:53:16 +02:00
images updated readme 2025-06-11 20:29:38 +02:00
sensors added websocktet support. 2025-06-17 22:57:01 +02:00
webserver added websocket. The file sensors/sender.py can be usede to send data to 2025-06-17 09:54:36 +02:00
.envrc added websocket. The file sensors/sender.py can be usede to send data to 2025-06-17 09:54:36 +02:00
.gitignore Merge branch 'main' of https://git.miaig.dev/mia/abschlussarbeit 2025-06-17 19:46:42 +02:00
LICENSE The webserver is now using flask instead of python http server. This is 2025-05-27 11:25:37 +02:00
main.py added main.py, updated readme 2025-06-18 10:13:05 +02:00
README.md added main.py, updated readme 2025-06-18 10:13:05 +02:00
shell.nix Updated readme and development environments 2025-06-16 12:22:56 +02:00

PiWebSense

Git

This Repo gets pushed to three git hosts in the following order:

Tech Stack / Hardware Requirements

  • Raspberry Pi Model 4 for the sensors

  • A Second Pc/Laptop/Server/Pi that'll host the Webserver

  • Programming languages used: Python, jinja, HTML, CSS, JavaScript

  • Frameworks/tools/Libraries:

    • Webserver:
      • flask
      • json
      • matplotlib
      • hashlib
      • socket
      • threading
      • os
      • datetime
    • Sensors:
      • datetime
      • time
      • json
      • os
      • board
      • adafruit_dht
      • digitalio
      • RPI.GPIO
  • Exxmple Sensors:

    • LDR (Lightsensor)
    • Sound Detector
    • Temperature and humidity

Docs

This Program aims to receive Data from a dynamic amount of Sensors and Display the data on the Webserver. This can be done using the example Sensors in the sensor folder or by just writing your own ones using the further down documented Json file. The server and port get defined in sensors/sender.py. That file can be imported as shown in the examples.

The Webserver distiguishes between two update formats: live and history. The data needs to be providet in the following format to be considered a history update. To be considered a live update the fielts type and unit have to be removed from the transmission.

    {
    "location": "Building A - Lab 3",
    "sensors": [
      {
        "id": "sensor_001",
        "type": "temperature",
        "unit": "°C",
        "readings": [
          { "ts": 1747814400, "value": 22.5 },
          { "ts": 1747818000, "value": 23.0 },
          { "ts": 1747821600, "value": 23.7 }
        ]
      },
      {
        "id": "sensor_002",
        "type": "humidity",
        "unit": "%",
        "readings": [
          { "ts": 1747814400, "value": 45.2 },
          { "ts": 1747818000, "value": 47.1 },
          { "ts": 1747821600, "value": 46.8 }
        ]
      },
      {
        "id": "sensor_003",
        "type": "pressure",
        "unit": "hPa",
        "readings": [
          { "ts": 1747814400, "value": 1012.4 },
          { "ts": 1747818000, "value": 1012.8 },
          { "ts": 1747821600, "value": 1013.0 }
        ]
      }
    ]
  }
  • shell.nix This file is only used for the nix packagemananger to set up a development environment for the Webserver only
  • .envrc This is also a bit of linux nixos magic to automatically set up the development environment using direnv
  • main.py This file starts all sensors at once for easy deployment at a site.

Instalation

Sensors

To Install the exmple Sensors, simply install all the Requiered packages mentioned further above

Acknowledgments

Chiara Mia

License

PiWebSense Copyright (C) 2025 Mia, Chiara

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License Version 3.0 as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.