Skip to main content

CO₂ Sensors

The CO₂ Sensors feature displays a live network of environmental monitoring devices on the Cesium map. Each sensor reports CO₂ concentration, temperature, and humidity.

Hardware

Sensors are built on the Blues Wireless Notecard cellular IoT module paired with environmental sensors. Data flows:

Sensor hardware → Notecard → Notehub (Blues cloud) → Firebase Firestore → GeoLens

Data is stored in Firebase Firestore under devices/{devId}/readings/ as a time-ordered subcollection.

Enabling CO₂ Sensors

In the sidebar under Live Observation → UCF, click CO2 Sensors. The app fetches the latest reading for each device and plots a pin at each sensor's GPS location.

Sensor Pins

Each sensor is rendered as a custom billboard icon:

  • Icon is drawn on a <canvas> element using a Font Awesome symbol
  • A drop-shadow is applied for depth
  • The icon rotates based on its screen position (radially around the map center) for a polished look

Clicking a sensor pin opens an info box with:

  • Device ID
  • Latest CO₂ reading (ppm)
  • Temperature (°C)
  • Humidity (%)
  • Last seen timestamp
  • Historical chart (see below)

Historical Charts

The sensor info box includes a tabbed chart panel powered by ApexCharts. Time range options:

RangeDescription
24hLast 24 hours
7dLast 7 days
30dLast 30 days

Charts are fetched from the /co2-sensors/:devId/history endpoint with the selected duration parameter. The server downsamples to ~200 points for performance.

Available Chart Tabs

  • CO₂ — CO₂ concentration in ppm over time
  • Temperature — Temperature in °C over time (if available)
  • Additional sensor parameters if present in the data

Sensor Data Structure

Each sensor reading has this shape (from Firestore data.readings[0]):

{
"dev_id": "dev:000000000000001",
"co2": 412,
"humidity": 54.2,
"temp": 23.1,
"lat": 28.502,
"lon": -81.344,
"time": 1700000000,
"last_seen": 1700000000
}

Note: The Firestore document stores lon but some older readings use long. The app handles both field names.

Multi-Sensor Navigation

When multiple sensors are loaded, the info box includes navigation arrows (← →) to browse between sensors without closing and re-opening the panel. Sensor index (1 / N) is displayed.

Firebase Configuration

CO₂ data requires a Firebase Admin service account with Firestore read access. Set either:

  • FIREBASE_SERVICE_ACCOUNT_JSON — JSON string (recommended for Render)
  • FIREBASE_SERVICE_ACCOUNT_PATH — path to service account JSON file (recommended locally)

See Environment Variables for details.

Relationship to CO₂ Interpolation

The sensor data loaded by this feature is also used by the CO₂ Interpolation Tool to generate spatial concentration heatmaps. The two features work best together — enable sensors first, then run interpolation.