Added temp and water
This commit is contained in:
@@ -7,7 +7,7 @@ var renderer = new MatrixRenderer("192.168.0.150"); // Your WLED IP
|
||||
// Replace these with your actual InfluxDB v2 credentials
|
||||
// If Influx is on the same Pi, you can use the Pi's local IP and port 8086
|
||||
var influx = new InfluxDataService(
|
||||
url: "http://192.168.0.76:8086",
|
||||
url: "http://parsons.cc:8086",
|
||||
token: ":",
|
||||
org: "-",
|
||||
bucket: "sensor_data"
|
||||
@@ -16,6 +16,7 @@ var influx = new InfluxDataService(
|
||||
Console.WriteLine("Starting DDP stream with live InfluxDB data...");
|
||||
|
||||
float currentTemp = 1f;
|
||||
int currentWaterLevel = 100;
|
||||
Stopwatch dbTimer = Stopwatch.StartNew();
|
||||
|
||||
while (true)
|
||||
@@ -24,12 +25,15 @@ while (true)
|
||||
if (dbTimer.ElapsedMilliseconds > 5000 || currentTemp == 0f)
|
||||
{
|
||||
currentTemp = await influx.GetLatestTemperatureAsync();
|
||||
currentWaterLevel = await influx.GetLatestWaterAsync();
|
||||
Console.WriteLine($"Fetched new temp: {currentTemp}c");
|
||||
Console.WriteLine($"Fetched new water: {currentWaterLevel}%");
|
||||
dbTimer.Restart();
|
||||
}
|
||||
|
||||
// Keep pushing frames to WLED at 30 FPS
|
||||
await renderer.DrawAndSendFrameAsync(currentTemp);
|
||||
await renderer.DrawAndSendFrameAsync(currentTemp, currentWaterLevel);
|
||||
|
||||
|
||||
await Task.Delay(1000 / 30);
|
||||
}
|
||||
Reference in New Issue
Block a user