Add temp sensor.

This commit is contained in:
2026-06-28 13:25:14 -05:00
parent 0f2a03044c
commit e188930755
6 changed files with 35 additions and 17 deletions

View File

@@ -116,7 +116,7 @@ The firmware in `src/main.cpp` implements the boilerplate as a compact Arduino E
- Configurable API access control where each route can be `PUBLIC` or require one role.
- Public boilerplate APIs: ping, add, and LED brightness.
- LED brightness is persisted in non-volatile memory, applied on boot, and loaded into the Admin UI slider.
- DS18B20 temperature sensor readings are exposed through the live Admin UI card and `/api/uptime` compatibility endpoint.
- DS18B20 temperature sensor readings are exposed in Celsius and Fahrenheit through the live Admin UI card and `/api/temperature` endpoint.
- User management with the standard roles `Sysadmin`, `UserAdmin`, `WebUIConnect`, and `Debugger`.
- Custom role management. System roles are protected and cannot be deleted.
- Active/inactive user accounts with role checkboxes in the Admin UI.
@@ -204,7 +204,7 @@ The defaults can be changed at compile time:
### DS18B20 temperature sensor
The live Admin UI card reads a DS18B20 one-wire temperature sensor. The default data pin is GPIO3, which is exposed as `D1` on the Seeed Studio XIAO ESP32C3.
The live Admin UI card reads a DS18B20 one-wire temperature sensor and displays both Celsius and Fahrenheit. The default data pin is GPIO3, which is exposed as `D1` on the Seeed Studio XIAO ESP32C3.
Connect the 3-wire sensor as follows:
@@ -222,6 +222,20 @@ Keep the sensor powered from `3V3`, not `5V`, so the data line stays safe for th
#define DS18B20_PIN 3
```
Read the current temperature with:
```http
GET /api/temperature
Authorization: Bearer <token>
```
The response includes `temperatureC`, `temperatureF`, `sensorConnected`, and `pin`. The live dashboard subscribes to:
```http
GET /api/temperature/events
Authorization: Bearer <token>
```
### Authentication
Login:
@@ -326,6 +340,8 @@ Protected APIs and their default roles:
| --- | --- |
| `POST /api/logout` | `WebUIConnect` |
| `GET /api/me` | `WebUIConnect` |
| `GET /api/temperature` | `WebUIConnect` |
| `GET /api/temperature/events` | `WebUIConnect` |
| `GET /api/apis` | `Sysadmin` |
| `POST /api/apis` | `Sysadmin` |
| `GET /api/users` | `UserAdmin` |