Clone this repository to your edge device (Raspberry Pi, Ubuntu, Debian are supported)
git clone https://github.com/Itea-Lab/Weather-Edge.git
cd Weather-EdgeCreate a .env file in the project root to store all necessary credentials:
sudo nano .env# InfluxDB Configuration
INFLUXDB_USERNAME=<username>
INFLUXDB_PASSWORD=your_password
INFLUXDB_ORG=weather_org
INFLUXDB_BUCKET=weather_data
# For Docker containers, use service name
INFLUXDB_ROUTE=http://database:8086
# Token will be obtained after InfluxDB initialization (see step 6)
INFLUXDB_TOKEN=<your_token_here>
# Data Configuration
DATA_LOCATION=<your_location_name> (district1, district2, etc)
MEASUREMENT_NAME=weather_sensor
# MQTT Configuration
MQTT_PUB=espclient
SUB_USERNAME=raspiclient
MQTT_PASSWORD=your_mqtt_password
MQTT_TOPIC=weather/data
MQTT_PORT=1883
BROKER_ENDPOINT=mosquitto
# Dashboard Configuration
JWT_SECRET=your-super-secret-jwt-key-here-make-it-long-and-random
JWT_EXPIRES_IN=1d
ADMIN_USERNAME=admin
ADMIN_NAME=Administrator
ADMIN_PASSWORD_HASH=your_password_hash_here
ADMIN_EMAIL=admin@example.com
ADMIN_ROLE=admin
TEST_USERNAME=testuser
TEST_NAME=Test User
TEST_PASSWORD_HASH=your_password_hash_here
TEST_EMAIL=test@example.com
TEST_ROLE=userweather-edge-config/
├── .env # Main environment variables
├── docker-compose.yml # Docker services configuration
├── README.md
├── mosquitto-init/ # MQTT broker initialization
│ └── entrypoint.sh
├── mosquitto-config/ # MQTT broker config (auto-generated)
├── influxdb2-config/ # InfluxDB config (auto-generated)
├── influxdb2-data/ # InfluxDB data (auto-generated)
└── data-processor/
├── .env # Processor-specific env FOR LOCAL TESTING (copy of main .env)
├── credentials/ # Device certificates and keys (See step 4)
├── Dockerfile
├── requirements.txt
├── run.py # Application entry point
├── dataProcessor.py # Main processing controller
├── config/
│ ├── __init__.py
│ └── config.py # Centralized configuration
├── mqtt/
│ ├── mqttReceiver.py # MQTT message receiver
│ └── mqttPublisher.py # MQTT message publisher
└── db/
├── influxClient.py # InfluxDB connection management
└── influxWriter.py # Data writing operations
Before running the weather edge processor, you must register your device with the Weather Platform to obtain AWS IoT certificates:
-
Contact Weather Platform Administrator or access the device registration portal
-
Provide Device Information:
- Device name/identifier (e.g.,
raspi-1,weather-station-01) - Location/district assignment (e.g.,
district5,station_01) - Device type: Weather Edge Processor
- Device name/identifier (e.g.,
-
Receive Certificate Package: You will receive a package containing:
{device-name}_certificate.pem- Device certificate{device-name}_private_key.pem- Private key{device-name}_public_key.pem- Public key (optional){device-name}_connection_info.json- Connection configurationAmazonRootCA1.pem- Root CA certificate
-
Create credentials directory:
mkdir -p data-processor/credentials
-
Copy certificate files: Place all received certificate files in
data-processor/credentials/:data-processor/credentials/ ├── raspi-1_certificate.pem ├── raspi-1_private_key.pem ├── raspi-1_public_key.pem ├── raspi-1_connection_info.json └── AmazonRootCA1.pem -
Verify connection info format: The
connection_info.jsonshould contain:{ "endpoint": "your-iot-endpoint.iot.us-east-1.amazonaws.com", "port": 8883, "topics": { "publish": "weatherPlatform/telemetry" } } -
Set proper permissions:
chmod 600 data-processor/credentials/*_private_key.pem chmod 644 data-processor/credentials/*.pem chmod 644 data-processor/credentials/*.json
- Ensure
DATA_LOCATIONin your.envfile matches your registered location - The system will automatically discover certificate files based on naming patterns
- Dynamic topic routing will append your location to create:
weatherPlatform/telemetry/{DATA_LOCATION}
Enable execute permission for script file
chmod +x mosquitto-init/entrypoint.sh
Start the services for the first time:
docker compose up --build -dAfter the initial startup, you need to obtain the InfluxDB token:
-
Access InfluxDB Web Interface:
http://localhost:8086 -
Initial Setup:
- Username: Use
INFLUXDB_USERNAMEfrom your .env - Password: Use
INFLUXDB_PASSWORDfrom your .env - Organization: Use
INFLUXDB_ORGfrom your .env - Bucket: Use
INFLUXDB_BUCKETfrom your .env
- Username: Use
-
Get API Token:
- Navigate to "Data" → "API Tokens"
- Click "Generate API Token" → "All Access API Token"
- Copy the generated token
-
Update Environment Files: Update both
.envfiles with the token:INFLUXDB_TOKEN=your_copied_token_here
-
Restart Services:
docker compose down docker compose up -d
The MQTT broker supports two authentication modes:
Edit mosquitto-config/mosquitto.conf and set:
allow_anonymous true
The system automatically creates authentication files:
mosquitto-config/passwd- Stores username/password pairsmosquitto-config/mosquitto.acl- Access control list
Default Users Created:
espclient- Can publish (write) to all topicsraspiclient- Can subscribe (read) from all topics
Testing MQTT Connection:
Without authentication:
mosquitto_sub -h localhost -p 1883 -t weather/data
# Returns: Connection error: Connection Refused: not authorised.With authentication:
mosquitto_sub -h localhost -p 1883 -u raspiclient -P your_mqtt_password -t weather/dataThe data processor automatically:
- Connects to InfluxDB using the configured token
- Subscribes to MQTT topics for weather data
- Processes and stores incoming data
- Validates data format and handles errors
Manual Testing:
cd data-processor
python run.pyProduction (Docker): The processor runs automatically as part of the Docker Compose stack.
- InfluxDB UI: http://localhost:8086
- Dashboard: http://localhost:3000 (if enabled)
- MQTT Broker: localhost:1883
| Variable | Purpose | Example |
|---|---|---|
INFLUXDB_TOKEN |
Database API access | eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9... |
MQTT_PUB |
MQTT publisher username | espclient |
SUB_USERNAME |
MQTT subscriber username | raspiclient |
BROKER_ENDPOINT |
MQTT broker address | Raspi's IP address |
DATA_LOCATION |
Sensor location tag | district5, station_01 |
MEASUREMENT_NAME |
InfluxDB measurement name | weather_sensor |
-
AWS IoT Certificate Issues:
- Missing certificates: Ensure all certificate files are in
data-processor/credentials/ - Permission denied: Check file permissions (private keys should be 600)
- Connection refused: Verify device is registered and certificates are valid
- Topic permission denied: Ensure AWS IoT policy allows publishing to
weatherPlatform/telemetry/*
- Missing certificates: Ensure all certificate files are in
-
"Not authorized" MQTT error:
- Check username/password in .env
- Verify ACL permissions
- Ensure user exists in passwd file
-
InfluxDB connection failed:
- Verify INFLUXDB_TOKEN is correct
- Check if InfluxDB service is running
- Validate organization and bucket names
-
Environment variables not loading:
- Ensure .env file exists in correct location
- Check for typos in variable names
- Restart containers after changes
# Check container status
docker compose ps
# View logs
docker compose logs weather-edge-processor
docker compose logs database
docker compose logs mosquitto
# Test MQTT connectivity
docker exec -it mqtt-broker mosquitto_sub -h localhost -u raspiclient -P your_password -t weather/data
# Test AWS IoT certificate discovery
cd data-processor
python -c "from mqtt.mqttPublisher import AWSIoTPublisher; pub = AWSIoTPublisher(); print('Certificates discovered successfully')"
# Verify certificate files
ls -la data-processor/credentials/