Skip to content

Latest commit

 

History

History
382 lines (280 loc) · 9.53 KB

README.md

File metadata and controls

382 lines (280 loc) · 9.53 KB

wera-logo

Wera

Cities are heating up during the summer, and deaths related to this are on the rise. To mitigate this ever-increasing risk, we have prototyped, built, and user-tested an entirely open-source, personalized city climate warning system called Wera. Wera can access the high-density temperature sensor network in Zurich, along with meteorological data and the user's location, to formulate a weather and risk potential report with Llama3, which is then synthesized into either German or English for the end user. Wera primarily targets seniors, as they are the most affected by the city's hotspots. It features a very intuitive and accessible interface, making it a reliable weather risk informer and a helpful weather assistant. Wera comes in two form factors: the Kub, its strengths being its constant visibility, personal feeling, and accessibility, and the Fong, which is widely deployable and offers the option to ask back questions directly on your phone.

Youtube Video

Table of Contents


Hardware

Kub

kub-schematics

  • Raspberry Pi (we used the Pi 4 model b)
  • 1x GPS Module
  • 2x Status LED's (1x Green 1x Red)
  • 1x Rotary encoder
  • 1x Speaker, easiest if it has it's own amplifier built in

API's

Server Quickstart:

Be sure to get all API Keys, .env is formatted like this in the /server directory

METEO_API_KEY=key
TTS_API_KEY=key // -> VoiceRSS API (backup TTS), package can be removed also
GROQ_API_KEY=key
UNREAL_SPEECH_API_KEY=key // -> Unreal TTS (backup TTS), package can be removed also
GOOGLE_APPLICATION_CREDENTIALS=key.json-file

Build the server (with docker):

cd server
docker build -t wera-server .
docker run -d -p 8080:8080 wera-server

Build and run the the server (without Docker):

cd server
go mod tidy
go build cmd/server/main.go
./main

Radio (Raspberry PI 4) Quickstart

Fetch dependencies and build:

  1. Navigate to the kub directory:
cd kub
  1. Initialize the Go module (if not already done):
go mod tidy
  1. Fetch dependencies:
go get github.com/stianeikeland/go-rpio/v4 go.bug.st/serial.v1
  1. Build the kub application:
go build kub.go
  1. Run the built application:
./kub
  1. Create a Service for the Kub
sudo nano /etc/systemd/system/kub.service
  1. Add the following content to the service file. Adjust the ExecStart path to point to your executable and modify other settings as necessary:
[Unit]
Description=Kub Service
After=network.target

[Service]
ExecStart=/home/user/wera/kub/kub
WorkingDirectory=/home/user/wera/kub
StandardOutput=inherit
StandardError=inherit
Restart=always
User=root
RestartSec=10
StartLimitIntervalSec=500
StartLimitBurst=5


[Install]
WantedBy=multi-user.target
  1. Reload the systemd manager configuration to read the newly created service file:
sudo systemctl daemon-reload
  1. Enable the service to start on boot:
sudo systemctl enable goradio.service
  1. Start the service immediately to test it:
sudo systemctl start goradio.service
  1. Check the status of the service to ensure it is active and running:
sudo systemctl status goradio.service

Docs

Render Hosted Service (2min startup time): https://spatial-interaction.onrender.com

Endpoints

GET /ok

Responds with OK status 200.

GET /cityclimate

Responds with the sensor dataset of the ZHAW Grid, currently only has access to about 50 sensors and the temperature data only.

POST /cityclimategps

Responds with the sensor dataset of the ZHAW Grid, sorted by distance (closest to furthest).

Sample Request Body:

{
"device_id": "username",
"Latitude": 47.3653466,
"Longitude": 8.5282651,
"Language": "english"
}

Sample Response Body:

[
  {
    "id": "03400120",
    "name": "Sihlhölzlistrasse",
    "timestamp": "1716555600",
    "values": 22.8375,
    "colors": "#9baf33",
    "active": 1,
    "Distance": 0.3995830946586305,
    "geometry": {
      "type": "point",
      "coordinates": {
        "lon": 8.528826,
        "lat": 47.36892
      }
    }
  }
]

GET /meteoblue

Responds with a 3-hour forecast from Meteoblue data, also provides a 24-hour overview. Data contains temperature, wind, rain, and some more. Each request takes 8000 tokens and our free API is limited to 10M, so please make only as many requests as needed.

POST /weathergps

Fetches and combines data from both the MeteoBlue and CityClimate APIs, processes it to compute different data points, to create a current weather analysis and forecast. It uses the GPS data of the kub to deliver data for the current location of the radio, constructs a nice response, and generates a speech file (.wav) which is returned as an audio stream.

Sample Request Body:

{
  "device_id": "Device_1",
  "Latitude": 47.3653466,
  "Longitude": 8.5282651,
  "Language": "english"
}

Sample text it generates and speaks:

"Good morning! It's a lovely day outside! The temperature has been quite pleasant, a gentle breeze is blowing and the temperature is just right - not too hot, not too cold. Just perfect. Make sure to stay hydrated and take a break if you're spending time outdoors. And remember, on especially warm days, please be extra careful to avoid heat exhaustion. Stay cool and comfortable!"

POST /weather

Fetches and combines data from both the MeteoBlue and CityClimate APIs, processes it to compute different data points, to create a current weather analysis and forecast, constructs a descriptive sentence, and generates a speech file (.wav) which is returned as an audio stream. This endpoint is used as a relay in case weathergps fails.

Sample Request Body:

{
"device_id": "username",
"Language": "english"
}

The response contains:

  • The current average temperature of the sensor grid.
  • The temperature and wind speed according to MeteoBlue.

Sample text it generates and speaks:

The current average temperature of the Sensor Grid is 22.50 degrees Celsius. According to MeteoBlue, the temperature is 20.10 degrees Celsius with a windspeed of 3.5 meters per second.

GET /hotareas

Resonds with an array of sensors that are over a certain set threshold, on default it is set to 28 degrees celsius.

Sample Response Body:

[
  {
    "id": "0340011C",
    "name": "Zollikerstrasse",
    "timestamp": "1716555600",
    "values": 28.8025,
    "colors": "#743933",
    "active": 1,
    "geometry": {
      "type": "point",
      "coordinates": {
        "lon": 8.556188,
        "lat": 47.3617
      }
    }
  }
]

POST /hotareasgps

Resonds with an array of sensors that are over a certain set threshold, on default it is set to 28 degrees celsius, sorted by distance to the post location.

Sample Request Body:

{
  "device_id": "Device_1",
  "Latitude": 47.3653466,
  "Longitude": 8.5282651
}

Sample Response Body:

[
  {
    "id": "0340011C",
    "name": "Zollikerstrasse",
    "timestamp": "1716555600",
    "values": 28.8025,
    "colors": "#743933",
    "active": 1,
    "geometry": {
      "type": "point",
      "coordinates": {
        "lon": 8.556188,
        "lat": 47.3617
      }
    }
  }
]

POST /speak

Text to speech endpoint. (Unreal speech)

Sample Request Body:

{
  "text": "Note: As soon as the green light comes on, I can provide more detailed information, this normally takes 15 minutes. The kub can be used nevertheless ",
  "language": "english"
}

Sample Response Body:

{
  "file": "output.wav",
  "message": "Speech generated successfully"
}

Dependencies

Server

  • github.com/jackc/pgx/v4 for PostgreSQL database interaction.
  • github.com/gorilla/mux for routing.
  • google.golang.org/genproto/googleapis/cloud/texttospeech/v1 & cloud.google.com/go/texttospeech/apiv1 for Google Text to Speech integration

Kub (Raspberry Pi 4)

  • github.com/stianeikeland/go-rpio/v4for GPIO pin support.
  • go.bug.st/serial.v1for Serial Support.

License

This Project lies under the MIT License.