A FastAPI service that monitors aquarium temperature readings from IoT devices.
- Accepts temperature readings in °F from IoT devices
- Stores readings in SQLite database
- Alerts when temperatures fall outside configured range
- RESTful API endpoints for submitting and querying readings
- Docker
- Docker Compose
-
Clone the repository:
git clone <repository-url> cd aquarium-monitor
-
Create the data directory:
mkdir data
-
Start the service:
docker-compose up -d
The API will be available at http://localhost:8001
- ESP32 development board
- DS18B20 waterproof temperature sensor
- 4.7kΩ pull-up resistor
- Jumper wires
DS18B20 → ESP32
VCC → 3.3V
GND → GND
DATA → GPIO 23 (with 4.7kΩ pull-up to 3.3V)
- Install MicroPython on your ESP32
- Copy these files to the ESP32:
boot.py(OTA loader)device_config.json(device configuration)esp_runtime.py(main application - downloaded via OTA)
Once running, visit http://localhost:8001/docs for interactive API documentation.
-
POST /temperature - Submit a new temperature reading
{ "device_id": "tank_sensor_1", "temperature_f": 78.1, "timestamp": "2024-03-14T16:00:00Z" // Optional } -
GET /temperature?limit=100 - List recent readings
-
GET /temperature/latest?device_id=... - Get latest reading for a device
Environment variables can be modified in docker-compose.yml:
DATABASE_URL: SQLite database pathTEMP_MIN_F: Minimum temperature threshold (°F)TEMP_MAX_F: Maximum temperature threshold (°F)
-
Build the image:
docker-compose build
-
Run with logs:
docker-compose up
-
Stop the service:
docker-compose down