https://github.com/bbartling/bacnet-web-weather-linux
This is a Python based BACnet app on embedded for giving the BAS web weather data...
https://github.com/bbartling/bacnet-web-weather-linux
Last synced: about 1 year ago
JSON representation
This is a Python based BACnet app on embedded for giving the BAS web weather data...
- Host: GitHub
- URL: https://github.com/bbartling/bacnet-web-weather-linux
- Owner: bbartling
- License: mit
- Created: 2025-03-14T16:19:15.000Z (about 1 year ago)
- Default Branch: develop
- Last Pushed: 2025-03-18T13:52:54.000Z (about 1 year ago)
- Last Synced: 2025-03-18T14:42:57.984Z (about 1 year ago)
- Language: Python
- Size: 78.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ๐ **BACnet Weather Station Setup Guide**
This is a Python-based BACnet app optimized for embedded systems to provide BAS web weather data using OpenWeatherMap API.
---
## ๐ ๏ธ **Prerequisites**
- Raspberry Pi with Armbian Minimal / IoT image
- Python 3, `pip`, and virtual environment support
- SSH access
---
๐ **Skip right to the Docker Documentation:**
[๐ณ Docker README](https://github.com/bbartling/bacnet-web-weather-linux/blob/develop/docker_readme.md)
---
## ๐ **Step 1: Download and Install Armbian**
1. Download the latest Armbian Minimal / IoT image:
- [Armbian Raspberry Pi 4B](https://www.armbian.com/rpi4b/)
2. Burn the image to an SD card using Raspberry Pi Imager.
---
## โ๏ธ **Step 2: Initial Setup**
1. Insert the SD card into the Raspberry Pi and power it up.
2. Connect to the Pi via SSH:
```bash
ssh root@192.168.1.224
```
- Default username: `root`
- Default password: `1234`
3. Complete the Armbian setup and create a new user (e.g., `ben`).
---
### ๐ฆ **Step 3: Install Required Packages**
```bash
sudo apt update
sudo apt install vim git python3 python3-venv python3-pip -y
```
---
### ๐ **Step 4: Setup Secure SSH Access**
1. On your Windows machine, generate an SSH key:
```powershell
ssh-keygen -t rsa -b 4096 -C "ben.bartling@gmail.com"
```
2. Retrieve and copy the public key:
```powershell
Get-Content ~\.ssh\id_rsa.pub
```
3. On the Raspberry Pi, set up the SSH keys:
```bash
mkdir -p ~/.ssh
nano ~/.ssh/authorized_keys
```
4. Paste the public key, save, and set permissions:
```bash
chmod 600 ~/.ssh/authorized_keys
chmod 700 ~/.ssh
```
5. Disable root SSH login:
```bash
sudo nano /etc/ssh/sshd_config
```
- Set `PermitRootLogin no`.
- Restart SSH:
```bash
sudo systemctl restart sshd
```
---
### ๐งช **Step 5: Test SSH Login**
```bash
ssh ben@192.168.1.224
```
Ensure root login is disabled by attempting:
```bash
ssh root@192.168.1.224
```
You should receive a "permission denied" message.
---
### ๐ ๏ธ **Step 6: Clone the Repository & Set Up Python Environment**
#### ๐ฅ **Clone the Repository**
```bash
git clone https://github.com/your-repo/bacnet-weather-station.git
cd bacnet-weather-station
```
#### ๐ **Create & Activate a Virtual Environment**
```bash
python3 -m venv env
source env/bin/activate
```
#### ๐ฆ **Install Required Dependencies**
```bash
pip install -r requirements.txt
```
๐น *This ensures the BACnet weather app runs in an isolated environment with all necessary dependencies installed.*
#### ๐ณ **Prefer Docker?**
If you'd rather run this in a container, check out the **[Docker Setup Guide](https://github.com/bbartling/bacnet-web-weather-linux/blob/develop/docker_readme.md)**. ๐
---
### โ๏ธ **Step 7: Create `.env` File for API Key**
```bash
nano .env
```
Add the following:
```env
OPENWEATHER_API_KEY=your_api_key_here
```
### โ๏ธ **Step 7.1: Configure `config.py` for API Settings**
After setting up your `.env` file, you need to configure the **weather API settings** inside `config.py`.
#### โ๏ธ **Edit the Configuration File**
```bash
nano config.py
```
#### ๐ **Update the Following Variables**
Make sure the following settings are set inside `config.py`:
```python
LAT = 38.6246
LON = -76.9391
API_URL = "https://api.openweathermap.org/data/2.5/weather"
# Weather Data Update interval in seconds (20 minutes)
INTERVAL = 1200
# OpenWeather API Configurations
UNITS = "imperial" # Options: 'standard', 'metric', 'imperial'
LANG = "en" # Language code for API responses
```
#### ๐ **What Each Setting Does**
- `LAT` / `LON` โ Set the **latitude** and **longitude** for your weather data.
- `API_URL` โ The **endpoint** for fetching weather data from OpenWeather.
- `INTERVAL` โ How often (in **seconds**) the app fetches weather data (default: **20 minutes**).
- `UNITS` โ Choose between `'standard'`, `'metric'`, or `'imperial'` for temperature units.
- `LANG` โ Set the **language** for API responses (e.g., `"en"` for English).
After updating, **save and exit**:
- **For Nano**: Press `CTRL + X`, then `Y`, then `Enter`.
---
### โ๏ธ **Step 8: Running the BACnet Weather App**
```bash
python main.py --name BacnetWeatherStation --instance 3456789 --debug
```
* If you need to assign a static IP or unique port number, **bacpypes3** also supports assigning hard-coded [addresses](https://bacpypes3.readthedocs.io/en/stable/gettingstarted/addresses.html) which would be useful if your BACnet network is running on a unique port number.
```bash
python main.py --name BacnetWeatherStation --address 192.168.0.21/24:47809 --instance 3456789 --debug
```
---
### ๐ผ๏ธ **Step 9: BACnet Weather Station Screenshot**
Here's a sample screenshot of the BACnet Weather Station in action:
[](https://github.com/bbartling/bacnet-weather-station/blob/develop/images/snip.png)
---
### โก **Step 10: Accessing the Microdot REST API**
The BACnet Weather Station also provides a **REST API endpoint** using **Microdot**.
This allows external applications to retrieve **real-time weather data** in JSON format.
#### ๐ **API Endpoint**
```http
GET http://:8080/status
```
#### ๐ก **Example Request**
Change `localhost` to the IP address of your Pi...
```bash
curl http://localhost:8080/status
```
#### ๐ **Example JSON Response**
```json
{
"temperature": 40.78,
"humidity": 32,
"dew_point": 13.23,
"error": "inactive",
"wet_bulb": 31.13,
"timestamp": "2025-03-22T18:49:14.725541",
"lat": 43.555,
"lon": -89.927
}
```
#### ๐ ๏ธ **How It Works**
- The API continuously updates weather data from OpenWeather.
- You can **fetch current temperature, humidity, and dew point**.
- The `error` field indicates if there were **issues fetching the data**.
- The `timestamp` is updated every **INTERVAL** (default: 20 minutes).
---
### โ
**You're All Set!**
The BACnet Weather Station now **broadcasts data** over BACnet **and** provides an easy-to-use REST API! ๐๐ฅ