Closed nargetdev closed 1 year ago
I just refactored the Influxdb 1.x code to use Flux (master branch), so now the influxdb code is consolidated and very consistent with using Flux to access both 1.x and 2.x databases. This should help to move toward being able to specify different buckets. How that materializes, I'm not sure, so I'll have to chew on it for a while.
For now I patched it with a golang daemon process which just reads the existing influx stream and has some logic to echo it back to different buckets depending on which reservoir is being sampled.
An easy solution using the current code to separate sensor measurements for each reservoir is to add, for example, 3 of the same EC input, all configured to the one EC probe, and only activate one input at a time via a Function based on which reservoir is currently being measured/regulated.
That was actually how I did it initially. But my intention was to soon after go to 8 reservoirs, and it quickly got unwieldy, as I also had functions which needed to shut off the outputs to many GPIO to configure the sample loop.
We've built a solenoid manifold which routes water to three separate reservoirs. Effectively you use one set of probes to sample as many reservoirs as you like, and one set of peristaltic to dose all reservoirs and maintain distinct EC, pH levels for each. Of course with the caveat that some logic is needed to route that one set of sensor's info to three separate influxDB buckets. Furthermore, special care must be taken so that any closed loop control algorithm must only run when the pump is actively sampling.
Describe alternatives you've considered It is actually possible to implement a configuration like this in existing Mycodo, but it's not pretty. For example, three separate pH inputs (all wired to the same physical sensor), and having separate "daily time span/point" functions which turn on and off those inputs to pull the sample and separately both activate the correct control loop algo at the correct time - one for each reservoir to maintain separate set-points.
Additional context I'm considering implementing this entirely externally by configuring Telegraf to switch buckets on the backend from an MQTT message, and then use a golang process to execute control loops by reading the influxdb stream and leverage the Mycodo API to actually execute the outputs dosing. This feels cleaner to me.
Just curious if anybody has thought about this problem.