Multi‑tenant IoT starter kit that turns a single Particle Photon + DHT11 sensor into a real‑time web dashboard with per‑user access control, built entirely on Firebase and React.
ownerUid
; custom claims for an admin role primary‑50 … 900
) for a clean, lightweight lookphoton-firebase-dashboard/
├─ firmware/
│ └─ dht11_firebase.ino
├─ functions/
│ ├─ index.js
│ ├─ package.json
│ └─ setClaims.js
├─ frontend/
│ ├─ src/
│ │ ├─ App.jsx
│ │ ├─ main.jsx
│ │ ├─ firebase.js
│ │ └─ components/
│ │ ├─ Login.jsx
│ │ ├─ Dashboard.jsx
│ │ └─ DeviceCard.jsx
│ ├─ index.html
│ ├─ package.json
│ ├─ tailwind.config.cjs
│ └─ vite.config.js
├─ firestore.rules
├─ .env.example
└─ README.md ← this file
Tool / Service | Recommended version |
---|---|
Node.js | 18 LTS |
npm | 9 or newer |
firebase-tools CLI |
13 or newer |
Particle Photon | Device OS ≥ 3.1 |
Firebase project | Firestore, Auth, Functions & Hosting enabled |
Clone & Install
git clone https://github.com/your-org/photon-firebase-dashboard.git
cd photon-firebase-dashboard
npm install -g firebase-tools
Initialize Firebase
firebase login
firebase init # select Firestore, Functions, Hosting
Flash the Photon
firmware/dht11_firebase.ino
in Particle Web IDE Create the Webhook (Particle Console → Integrations)
Field | Value |
---|---|
Event | envReading |
URL | https://<region>-<project>.cloudfunctions.net/addReading |
Type | POST / JSON |
Header | particle-device-id: {{PARTICLE_DEVICE_ID}} |
Set Environment Variables
cp frontend/.env.example frontend/.env
# then fill in:
# VITE_FB_API_KEY, VITE_FB_AUTH_DOMAIN, … (Firebase web config)
# VITE_PARTICLE_TOKEN (Particle access token)
Deploy Cloud Functions & Hosting
cd functions && npm install && cd ..
firebase deploy --only functions,hosting
(Optional) Promote an Admin User
cd functions
node setClaims.js <FIREBASE_UID>
Open the Hosting URL → sign up two test users and watch device ownership transfer in real time 🔥
Component | Purpose |
---|---|
firmware/dht11_firebase.ino |
Reads the DHT11 sensor, publishes JSON {t,h} to envReading , and exposes a relay function (on / off ). |
functions/index.js |
HTTP endpoint /addReading ingests data, stores it under /devices/{deviceId}/readings , and timestamps with serverTimestamp() . |
firestore.rules |
Core policy: owners or admins can read/update; only admins can create/delete. |
React Front‑end | Vite + Tailwind UI, live updates via onSnapshot , charts via Chart.js, relay commands sent with the Particle REST API. |
{"t":..,"h":..}
every 10 s /readings
sub‑collection grows in real time ownerUid
instantly changes device visibility in the UI.env.example
)# Firebase
VITE_FB_API_KEY=
VITE_FB_AUTH_DOMAIN=
VITE_FB_PROJECT_ID=
VITE_FB_STORAGE_BUCKET=
VITE_FB_MSG_SENDER_ID=
VITE_FB_APP_ID=
# Particle
VITE_PARTICLE_TOKEN=
Released under the MIT License – feel free to use, modify and share.
Happy Semana Santa! ✝️.