I’ve LoRaWAN data coming into my local InfluxDB database using Chirp Stack. I’ve integrated database with Chronograf and Grafana for visualization. I’ve battery voltage data stored in an individual measurement, visualization of sample data is shown here:
We can monitor the life of a battery in terms of number of cycles, for which we require charging and discharging pattern. Battery voltage acts as a proxy to determine the charging and discharging pattern. Basically, the battery voltage is increasing when it is in charge (CH) state, whereas it is decreasing when its in discharge (DC) state (there are exceptions in charge state though). So we can make use of the derivative function in Flux to classify whether the battery is charging or discharging, from the battery voltage data of two successive data points (dV/dt>0 for CH; dV/dt<0 for DC). Once the classification is done, the consecutive CH+DC cycles should be counted to estimate the number of cycles, and thus the life of battery.
Need help in writing flux query for this. Any help will be greatly appreciated. Thanks in advance.