<?php
header('Content-Type: application/json; charset=utf-8');
require_once __DIR__ . '/../../../app/config/koneksi.php';

$q = $koneksi->query("SELECT suhu, kelembapan FROM sumberdaya ORDER BY id DESC LIMIT 1");
$r = $q->fetch_assoc();

echo json_encode([
    "suhu" => isset($r['suhu']) ? (float)$r['suhu'] : null,
    "hum"  => isset($r['kelembapan']) ? (float)$r['kelembapan'] : null
]);
