diff --git a/doc/build/.buildinfo b/doc/build/.buildinfo new file mode 100644 index 0000000..6803e7c --- /dev/null +++ b/doc/build/.buildinfo @@ -0,0 +1,4 @@ +# Sphinx build info version 1 +# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. +config: a84e020f225cc7ba65e040666d94782f +tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/doc/build/.doctrees/db_structure.doctree b/doc/build/.doctrees/db_structure.doctree new file mode 100644 index 0000000..680e195 Binary files /dev/null and b/doc/build/.doctrees/db_structure.doctree differ diff --git a/doc/build/.doctrees/environment.pickle b/doc/build/.doctrees/environment.pickle new file mode 100644 index 0000000..f9cc728 Binary files /dev/null and b/doc/build/.doctrees/environment.pickle differ diff --git a/doc/build/.doctrees/examples.doctree b/doc/build/.doctrees/examples.doctree new file mode 100644 index 0000000..5104630 Binary files /dev/null and b/doc/build/.doctrees/examples.doctree differ diff --git a/doc/build/.doctrees/index.doctree b/doc/build/.doctrees/index.doctree new file mode 100644 index 0000000..dd659f2 Binary files /dev/null and b/doc/build/.doctrees/index.doctree differ diff --git a/doc/build/.doctrees/introduction.doctree b/doc/build/.doctrees/introduction.doctree new file mode 100644 index 0000000..7fa4da5 Binary files /dev/null and b/doc/build/.doctrees/introduction.doctree differ diff --git a/doc/build/.nojekyll b/doc/build/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/doc/build/_sources/db_structure.rst.txt b/doc/build/_sources/db_structure.rst.txt new file mode 100644 index 0000000..cc09b1f --- /dev/null +++ b/doc/build/_sources/db_structure.rst.txt @@ -0,0 +1,244 @@ +Structure of InfluxDB +===================== + + influxDB SCHEMA: + + DB weather + measure wind + ---------------- + value | speed or direction or windgust + --------------------------------------- + field tag + + measure temphumi + ---------------- + temperature | humidity | external, internal | pressure + --------------------------------------------------------- + field field tag field + + measure rain + ---------------- + rain | rate / total / intensity | restart if zero, was it 65535 => before? + --------------------------------------------- + field tag field(int) + + + + DB status + + ISS measure + ---------------- + voltage | solar or capacitor | state / lqi / | battery or future_shit | + ---------------------------------------------------------------- + field tag field tag + + RasPI system + ---------------- + usage | disk, mem, cpu, eth, wifi % + ------------------------------------ + field | tag + + SQLite SCHEMA: + + DB status + + TABLE raspi + ---------------- + t_stamp | usage | host | type + ----------------------------------------------- + INT | INT | VARCHAR(50) | VARCHAR(20) + + CREATE TABLE raspi( + t_stamp INT, + usage INT, + host VARCHAR(50), + type VARCHAR(20)); + + TABLE network + ---------------- + t_stamp | count | type | nic | host + ------------------------------------------------------------ + INT | INT | VARCHAR(20) | VARCHAR(20) | VARCHAR(50) + + CREATE TABLE network( + t_stamp INT, + count INT, + type VARCHAR(20), + nic VARCHAR(20), + host VARCHAR(50)); + + TABLE vantage_vue_iss + ---------------------- + t_stamp | voltage | type | lqi | rssi | batt_low + ------------------------------------------------------------------ + INT | INT | VARCHAR(20) | TINYINT | TINYINT | BOOL + +------------------------------------------------------------------------------- +ENERGY +------------------------------------------------------------------------------- +CREATE CONTINUOUS QUERY cq_power_1m on voltage BEGIN + SELECT max(power) AS p_max, min(power) AS p_min, + mean(power) as power, mean(voltage) AS voltage + INTO voltage.monthly.mppt_aggregated + FROM voltage.realtime.mppt + GROUP BY time(1m),type +END +CREATE CONTINUOUS QUERY "cq_power_1h" ON "voltage" BEGIN + SELECT max("power") AS p_max,min(power) AS p_min, + mean(power) as power, mean(voltage) AS voltage + INTO "yearly"."mppt_aggregated" + FROM realtime.mppt + GROUP BY time(1h), type +END +CREATE CONTINUOUS QUERY "cq_power_6h" ON "voltage" BEGIN + SELECT max("power") AS p_max,min(power) AS p_min, + mean(power) as power, mean(voltage) AS voltage + INTO "infinite"."mppt_aggregated" + FROM realtime.mppt + GROUP BY time(6h), type +END + + + +drop continuous query cq_power_30m on voltage +show retention policies on weather_v2 + +create retention policy realtime on weather_v2 duration 168h replication 1 shard duration 1h +create retention policy monthly on weather_v2 duration 720h replication 1 shard duration 24h +create retention policy yearly on weather_v2 duration 8760h replication 1 shard duration 168h +create retention policy infinite on weather_v2 duration 0s replication 1 shard duration 720h + +select time,value into realtime.rain from autogen.rain where time > now()-1w group by * +select time,humidity,pressure,temperature into realtime.temphumi from autogen.temphumi where time > now()-1w group by * +select time,humidity,temperature into realtime.usense from autogen.usense where time > now()-1w group by * +select time,value into realtime.wind from autogen.wind where time > now()-1w group by * + +alter retention policy realtime on weather_v2 default + +------------------------------------------------------------------------------- +WIND - DONE +------------------------------------------------------------------------------- +CREATE CONTINUOUS QUERY "cq_rain_10m" ON "weather_v2" BEGIN + SELECT max("rainrate") AS rrate_max, mean(rainrate) AS rrate, max(rain_bucket_tips) AS rain_tips + INTO "monthly"."rainrate_aggregated" + FROM realtime.rain + GROUP BY time(10m) +END +CREATE CONTINUOUS QUERY "cq_rain_1h" ON "weather_v2" BEGIN + SELECT max("rainrate") AS rrate_max, mean(rainrate) AS rrate, max(rain_bucket_tips) AS rain_tips + INTO "yealy"."rainrate_aggregated" + FROM realtime.rain + GROUP BY time(10m) +END + +------------------------------------------------------------------------------- +RAIN - DONE +------------------------------------------------------------------------------- +CREATE CONTINUOUS QUERY "cq_rain_10m" ON "weather_v2" BEGIN + SELECT max("value") AS val_max, mean(value) AS value + INTO "monthly"."rainrate_aggregated" + FROM realtime.rain + GROUP BY type,time(10m) +END +CREATE CONTINUOUS QUERY "cq_rain_1h" ON "weather_v2" BEGIN + SELECT max("value") AS val_max, mean(value) AS value + INTO "yearly"."rainrate_aggregated" + FROM realtime.rain + GROUP BY type,time(1h) +END +CREATE CONTINUOUS QUERY "cq_rain_6h" ON "weather_v2" BEGIN + SELECT max("value") AS val_max, mean(value) AS value + INTO "infinite"."rainrate_aggregated" + FROM realtime.rain + GROUP BY type,time(6h) +END +------------------------------------------------------------------------------- +TEMPHUMI - DONE +------------------------------------------------------------------------------- +CREATE CONTINUOUS QUERY "cq_temphumi_10m" ON "weather_v2" BEGIN + SELECT + max("humidity") AS humidity_max, + min("humidity") AS humidity_min, + mean("humidity") AS humidity, + max("temperature") AS temperature_max, + min("temperature") AS temperature_min, + mean("temperature") AS temperature + INTO "monthly"."temphumi_aggregated" + FROM realtime.temphumi + GROUP BY type, time(10m) +END + +CREATE CONTINUOUS QUERY "cq_temphumi_1h" ON "weather_v2" BEGIN + SELECT + max("humidity") AS humidity_max, + min("humidity") AS humidity_min, + mean("humidity") AS humidity, + max("temperature") AS temperature_max, + min("temperature") AS temperature_min, + mean("temperature") AS temperature + INTO "yearly"."temphumi_aggregated" + FROM realtime.temphumi + GROUP BY type, time(1h) +END + +CREATE CONTINUOUS QUERY "cq_temphumi_6h" ON "weather_v2" BEGIN + SELECT + max("humidity") AS humidity_max, + min("humidity") AS humidity_min, + mean("humidity") AS humidity, + max("temperature") AS temperature_max, + min("temperature") AS temperature_min, + mean("temperature") AS temperature + INTO "infinite"."temphumi_aggregated" + FROM realtime.temphumi + GROUP BY type, time(6h) +END + +------------------------------------------------------------------------------- +USENSE - DONE +------------------------------------------------------------------------------- +CREATE CONTINUOUS QUERY "cq_usense_6h" ON "weather_v2" BEGIN + SELECT mean("battery") AS battery, mean(humidity) AS humidity, mean(temperature) AS temperature + INTO "yearly"."usense_aggregated" + FROM realtime.usense + GROUP BY type,time(6h) +END + +CREATE CONTINUOUS QUERY "cq_usense_12h" ON "weather_v2" BEGIN + SELECT mean("battery") AS battery, mean(humidity) AS humidity, mean(temperature) AS temperature + INTO "infinite"."usense_aggregated" + FROM realtime.usense + GROUP BY type,time(12h) +END + +------------------------------------------------------------------------------- +WIND +------------------------------------------------------------------------------- + + +------------------------------------------------------------------------------- +STATUS +------------------------------------------------------------------------------- + POLICIES + -------- +create retention policy realtime on status duration 168h replication 1 shard duration 1h +create retention policy monthly on status duration 720h replication 1 shard duration 24h +create retention policy yearly on status duration 8760h replication 1 shard duration 168h +create retention policy infinite on status duration 0s replication 1 shard duration 720h + +select time,usage into realtime.RasPI_aggregated from autogen.RasPI where time > now()-1w group by * +select time,voltage into realtime.iss_aggregated from autogen.iss where time > now()-1w group by * + +-- +SELECT NON_NEGATIVE_DERIVATIVE(max(*)) as traffic INTO "monthly"."net_aggregated" FROM autogen.net WHERE time > now()-2w GROUP BY time(30s) +CQ +-- +CREATE CONTINUOUS QUERY "cq_net_1m" ON "status" BEGIN + SELECT NON_NEGATIVE_DERIVATIVE(max(*)) as traffic + INTO "monthly"."net_aggregated" + FROM realtime.net + WHERE time > now()-1m + GROUP BY time(30s) +END + +alter retention policy realtime on status default diff --git a/doc/build/_sources/examples.rst.txt b/doc/build/_sources/examples.rst.txt new file mode 100644 index 0000000..87e2866 --- /dev/null +++ b/doc/build/_sources/examples.rst.txt @@ -0,0 +1,31 @@ +.. Plutonium reporter documentation master file, created by + sphinx-quickstart on Wed Apr 3 15:53:15 2019. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +============================================== +! +============================================== + +.. toctree:: + :maxdepth: 3 + :caption: Contents: + + +Dynamic data +===================== +.. automodule:: modules.dynamic + :members: + +Dynamic Weather +================ +.. autoclass:: modules.dynamic.DynamicWeather + :members: + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/doc/build/_sources/index.rst.txt b/doc/build/_sources/index.rst.txt new file mode 100644 index 0000000..ef344a0 --- /dev/null +++ b/doc/build/_sources/index.rst.txt @@ -0,0 +1,95 @@ +.. Plutonium reporter documentation master file, created by + sphinx-quickstart on Wed Apr 3 15:53:15 2019. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +============================================== +DOC: Plutonium reporter +============================================== + +.. toctree:: + :maxdepth: 3 + :caption: Contents: + + introduction + + +Scope +===== +This document covers the **software part** of the reporter, although it consists +of a multitude of hw technologies, please keep that in mind. + +Purpose +======== + +Delivering aggregated and comprehensive representation of data-value pairs +in such a way, that even a complete idiot can read them. *This project is +created by AND for me.* + +In short, this application spins up a web server and on its address plots and +displays values gathered from various sources. + +An example granted: https://bastart.spoton.cz + +Sources +-------- + +The sources for feeding the **Plutonium** include: + +- Davis Vantage vue weather station (with a couple HW mods) +- Victron MPPT solar converter (Utilizing the Victron Direct RS232 protocol) +- CPU, MEM, DISK, (W)LAN statistics, plotted +- Custom ESP8266 data loggers + - Temp / Humidity + battery logging + - Current monitoring for LED lighting + +Discrepancies and hardware dependencies +--------------------------------------- +Obviously, all the monitoring cannot be done without proper HW equipment. +Although this server is primarily aimed at use on a Raspberry PI, it can be +installed on an old notebook, or similar, as the platform is Python3 and thus +independent of the OS. + +RasPI statistics +++++++++++++++++ +- Just the RasPI, should work out of the box + +Davis Vantage Vue ++++++++++++++++++ +- Obviously the Davis Vantage Vue weather station +- The CC1101 / wireless version +- arduino mini / Uno @ 3.3V +- CC1101 receiver with a couple other components +- Data structure received from davis: + + 2 = Supercap voltage (Vue only) + 3 = ? + 4 = UV Index + 5 = Rain rate + 6 = Solar radiation + 7 = Solar Cell output (Vue only) + 8 = Temperature + 9 = Wind gust + a = Humidity + e = Rain + + {'nxt': 64, 'P0': 1020.43, 'lqi': 6, 'b2': 3, 'P': 969.29, 'h': 144, 'Ti': 24.49, + 'cnt': 1, 'Hhtu': 28.68, 'b4': 129, 'b5': 247, 'b6': 36, 'b7': 255, 'b0': 1, 'b1': 10, + 'hop': 0, 'b3': 225, 'Thtu': 24.28, 'b8': 255, 'b9': 182, 'rssi': 45} + + +Solar / MPPT +++++++++++++ +- Victron MPPT solar charge controller (Bluesolar) +- RS232 -> USB or similar, to get the data to RasPi + +ESP8266 stuff ++++++++++++++ +- basically anything that can feed into the influxDB. + +Indices and tables +=================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/doc/build/_sources/introduction.rst.txt b/doc/build/_sources/introduction.rst.txt new file mode 100644 index 0000000..aa6f9d1 --- /dev/null +++ b/doc/build/_sources/introduction.rst.txt @@ -0,0 +1,134 @@ +.. Plutonium reporter documentation master file, created by + sphinx-quickstart on Wed Apr 3 15:53:15 2019. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + + +Introduction to Plutonium ++++++++++++++++++++++++++ + +.. toctree:: + :maxdepth: 5 + :caption: Contents: + +Directory structure +=================== +Following structure is applied to this project. Some directories are +minified in this view on purpose. +:: + . + ├── chttpd.py + ├── config + │   └── plutonium.ini + ├── config.py + ├── doc ... (documentation in sphinx) + ├── index.py + ├── localdeploy.sh + ├── modules + │   ├── dynamic.py + │   ├── status.py + │   ├── temphumi.py + │   ├── voltage.py + │   └── weather.py + ├── static + │   ├── css + │   │   ├── bootstrap.css + │   │   └── dygraph.css ... + │   ├── img + │   │   ├── battery_0.png ... + │   └── js + │   ├── solar_graph.js + │   ├── status_graph.js + │   ├── temphum_graph.js + │   └── weather_graph.js ... + ├── templates + │   ├── footer.html + │   ├── header.html + │   ├── landing_page.html + │   ├── status_admin.html + │   ├── temphumi_admin.html + │   ├── top_menu.html + │   ├── voltage_admin.html + │   └── weather_admin.html + └── TODO.txt + +CherryPy configuration (config.py) +================================== +Configuration is stored in a separate file statically, so each submodule can +load the same configuration. This should be variables, that are project-wide. + +CherryPy configuration file (plutonium.ini) +------------------------------------------- +Configuration file, .ini style. Option = value. File resides in ./config +directory. It is read by confi.py and parsed into a dict(), available +throughout the project. +:: + _server_protocol = https + _server_name = bastart.spoton.cz + _server_port = 80 + _server_bind_ip = 0.0.0.0 + _influx_host = localhost + _influx_port = 8086 + _influx_user = pi + _influx_pwd = password + _influx_weather_db = weather_v2 + _influx_status_db = status + _influx_voltage_db = voltage + _influx_IoT_db = weather_v2 + +Configuration classes and functions +------------------------------------ +.. automodule:: config + :members: + +CherryPy server (chttpd.py) +=========================== +The server uses CherryPy module. For more information, please consult the +Cherrypy documentation. + +CHTTPD.py is also the executable, that can be launched as a standalone +application by simply typing ./chttpd.py, or python3 chttpd.py + +.. automodule:: chttpd + :members: + +Modules and web paths +--------------------- + +Modules are located in the `modules` directory, hence the imports from a +subdirectory +:: + from modules import voltage + from modules import weather + from modules import dynamic + from modules import status + from modules import temphumi + +As can be seen, each class / module is mounted under a specific web path. This +is the preferred way of future expansion modules. +:: + cherrypy.tree.mount(voltage.EnergyInfo(), "/", conf) + cherrypy.tree.mount(voltage.EnergyInfo(), "/energy", conf) + cherrypy.tree.mount(weather.WeatherInfo(), "/weather", conf) + cherrypy.tree.mount(status.StatusInfo(), "/status", conf) + cherrypy.tree.mount(dynamic.Expose(), "/data", conf) + cherrypy.tree.mount(temphumi.PuerhInfo(), "/temphumi", conf) + +Index (index.py) +================ +Reserved for future use. Currently not displayed, as the EnergyInfo() class is +mounted under root(/) of the web, defined in chttpd.py +:: + cherrypy.tree.mount(voltage.EnergyInfo(), "/", conf) + +.. automodule:: index + :members: + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/doc/build/db_structure.html b/doc/build/db_structure.html new file mode 100644 index 0000000..f451543 --- /dev/null +++ b/doc/build/db_structure.html @@ -0,0 +1,438 @@ + + + + + + + + + + + Structure of InfluxDB — Plutonium reporter 1.0 documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + + + + +
+ + + + +
+
+
+
+ +
+

Structure of InfluxDB

+
+

influxDB SCHEMA:

+

DB weather +measure wind +—————-

+
+

field tag

+
+
+

field field tag field

+
+
+

field tag field(int)

+
+

DB status

+
+

field tag field tag

+
+
+

field | tag

+
+

SQLite SCHEMA:

+

DB status

+
+

INT | INT | VARCHAR(50) | VARCHAR(20)

+
+
+
CREATE TABLE raspi(

t_stamp INT, +usage INT, +host VARCHAR(50), +type VARCHAR(20));

+
+
+
+
+
+

INT | INT | VARCHAR(20) | VARCHAR(20) | VARCHAR(50)

+
+
+
CREATE TABLE network(

t_stamp INT, +count INT, +type VARCHAR(20), +nic VARCHAR(20), +host VARCHAR(50));

+
+
+

TABLE vantage_vue_iss

+
+
+
+

INT | INT | VARCHAR(20) | TINYINT | TINYINT | BOOL

+
+
+
+

ENERGY

+
+
CREATE CONTINUOUS QUERY cq_power_1m on voltage BEGIN
+
SELECT max(power) AS p_max, min(power) AS p_min,

mean(power) as power, mean(voltage) AS voltage

+
+
+

INTO voltage.monthly.mppt_aggregated +FROM voltage.realtime.mppt +GROUP BY time(1m),type

+
+
+

END +CREATE CONTINUOUS QUERY “cq_power_1h” ON “voltage” BEGIN

+
+
+
SELECT max(“power”) AS p_max,min(power) AS p_min,

mean(power) as power, mean(voltage) AS voltage

+
+
+

INTO “yearly”.”mppt_aggregated” +FROM realtime.mppt +GROUP BY time(1h), type

+
+

END +CREATE CONTINUOUS QUERY “cq_power_6h” ON “voltage” BEGIN

+
+
+
SELECT max(“power”) AS p_max,min(power) AS p_min,

mean(power) as power, mean(voltage) AS voltage

+
+
+

INTO “infinite”.”mppt_aggregated” +FROM realtime.mppt +GROUP BY time(6h), type

+
+

END

+

drop continuous query cq_power_30m on voltage +show retention policies on weather_v2

+

create retention policy realtime on weather_v2 duration 168h replication 1 shard duration 1h +create retention policy monthly on weather_v2 duration 720h replication 1 shard duration 24h +create retention policy yearly on weather_v2 duration 8760h replication 1 shard duration 168h +create retention policy infinite on weather_v2 duration 0s replication 1 shard duration 720h

+

select time,value into realtime.rain from autogen.rain where time > now()-1w group by * +select time,humidity,pressure,temperature into realtime.temphumi from autogen.temphumi where time > now()-1w group by * +select time,humidity,temperature into realtime.usense from autogen.usense where time > now()-1w group by * +select time,value into realtime.wind from autogen.wind where time > now()-1w group by *

+

alter retention policy realtime on weather_v2 default

+
+
+

WIND - DONE

+
+
CREATE CONTINUOUS QUERY “cq_rain_10m” ON “weather_v2” BEGIN

SELECT max(“rainrate”) AS rrate_max, mean(rainrate) AS rrate, max(rain_bucket_tips) AS rain_tips +INTO “monthly”.”rainrate_aggregated” +FROM realtime.rain +GROUP BY time(10m)

+
+
+

END +CREATE CONTINUOUS QUERY “cq_rain_1h” ON “weather_v2” BEGIN

+
+

SELECT max(“rainrate”) AS rrate_max, mean(rainrate) AS rrate, max(rain_bucket_tips) AS rain_tips +INTO “yealy”.”rainrate_aggregated” +FROM realtime.rain +GROUP BY time(10m)

+
+

END

+
+
+

RAIN - DONE

+
+
CREATE CONTINUOUS QUERY “cq_rain_10m” ON “weather_v2” BEGIN

SELECT max(“value”) AS val_max, mean(value) AS value +INTO “monthly”.”rainrate_aggregated” +FROM realtime.rain +GROUP BY type,time(10m)

+
+
+

END +CREATE CONTINUOUS QUERY “cq_rain_1h” ON “weather_v2” BEGIN

+
+

SELECT max(“value”) AS val_max, mean(value) AS value +INTO “yearly”.”rainrate_aggregated” +FROM realtime.rain +GROUP BY type,time(1h)

+
+

END +CREATE CONTINUOUS QUERY “cq_rain_6h” ON “weather_v2” BEGIN

+
+

SELECT max(“value”) AS val_max, mean(value) AS value +INTO “infinite”.”rainrate_aggregated” +FROM realtime.rain +GROUP BY type,time(6h)

+
+
+

END

+
+
+

TEMPHUMI - DONE

+
+
CREATE CONTINUOUS QUERY “cq_temphumi_10m” ON “weather_v2” BEGIN
+
SELECT

max(“humidity”) AS humidity_max, +min(“humidity”) AS humidity_min, +mean(“humidity”) AS humidity, +max(“temperature”) AS temperature_max, +min(“temperature”) AS temperature_min, +mean(“temperature”) AS temperature

+
+
+

INTO “monthly”.”temphumi_aggregated” +FROM realtime.temphumi +GROUP BY type, time(10m)

+
+
+

END

+
+
CREATE CONTINUOUS QUERY “cq_temphumi_1h” ON “weather_v2” BEGIN
+
SELECT

max(“humidity”) AS humidity_max, +min(“humidity”) AS humidity_min, +mean(“humidity”) AS humidity, +max(“temperature”) AS temperature_max, +min(“temperature”) AS temperature_min, +mean(“temperature”) AS temperature

+
+
+

INTO “yearly”.”temphumi_aggregated” +FROM realtime.temphumi +GROUP BY type, time(1h)

+
+
+

END

+
+
CREATE CONTINUOUS QUERY “cq_temphumi_6h” ON “weather_v2” BEGIN
+
SELECT

max(“humidity”) AS humidity_max, +min(“humidity”) AS humidity_min, +mean(“humidity”) AS humidity, +max(“temperature”) AS temperature_max, +min(“temperature”) AS temperature_min, +mean(“temperature”) AS temperature

+
+
+

INTO “infinite”.”temphumi_aggregated” +FROM realtime.temphumi +GROUP BY type, time(6h)

+
+
+

END

+
+
+
+

USENSE - DONE

+
+
CREATE CONTINUOUS QUERY “cq_usense_6h” ON “weather_v2” BEGIN

SELECT mean(“battery”) AS battery, mean(humidity) AS humidity, mean(temperature) AS temperature +INTO “yearly”.”usense_aggregated” +FROM realtime.usense +GROUP BY type,time(6h)

+
+
+

END

+
+
CREATE CONTINUOUS QUERY “cq_usense_12h” ON “weather_v2” BEGIN

SELECT mean(“battery”) AS battery, mean(humidity) AS humidity, mean(temperature) AS temperature +INTO “infinite”.”usense_aggregated” +FROM realtime.usense +GROUP BY type,time(12h)

+
+
+

END

+
+
+

WIND

+
+
+

STATUS

+
+
+

create retention policy realtime on status duration 168h replication 1 shard duration 1h +create retention policy monthly on status duration 720h replication 1 shard duration 24h +create retention policy yearly on status duration 8760h replication 1 shard duration 168h +create retention policy infinite on status duration 0s replication 1 shard duration 720h

+

select time,usage into realtime.RasPI_aggregated from autogen.RasPI where time > now()-1w group by * +select time,voltage into realtime.iss_aggregated from autogen.iss where time > now()-1w group by *

+

– +SELECT NON_NEGATIVE_DERIVATIVE(max(*)) as traffic INTO “monthly”.”net_aggregated” FROM autogen.net WHERE time > now()-2w GROUP BY time(30s) +CQ +– +CREATE CONTINUOUS QUERY “cq_net_1m” ON “status” BEGIN

+
+

SELECT NON_NEGATIVE_DERIVATIVE(max(*)) as traffic +INTO “monthly”.”net_aggregated” +FROM realtime.net +WHERE time > now()-1m +GROUP BY time(30s)

+
+

END

+

alter retention policy realtime on status default

+
+
+ + +
+ +
+ + +
+
+ +
+ +
+ + + + + + + + + + + + \ No newline at end of file diff --git a/doc/build/examples.html b/doc/build/examples.html new file mode 100644 index 0000000..b0c152f --- /dev/null +++ b/doc/build/examples.html @@ -0,0 +1,206 @@ + + + + + + + + + + + Dynamic data — Plutonium reporter 1.0 documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + + + + +
+ + + + +
+
+
+
+ +
+
+
+
+

Dynamic data

+
+
+

Dynamic Weather

+
+
+

Indices and tables

+ +
+ + +
+ +
+ + +
+
+ +
+ +
+ + + + + + + + + + + + \ No newline at end of file diff --git a/doc/build/genindex.html b/doc/build/genindex.html new file mode 100644 index 0000000..a92a6cb --- /dev/null +++ b/doc/build/genindex.html @@ -0,0 +1,194 @@ + + + + + + + + + + + + Index — Plutonium reporter 1.0 documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + + + + +
+ +
    + +
  • Docs »
  • + +
  • Index
  • + + +
  • + + + +
  • + +
+ + +
+
+
+
+ + +

Index

+ +
+ +
+ + +
+ +
+ + +
+
+ +
+ +
+ + + + + + + + + + + + \ No newline at end of file diff --git a/doc/build/index.html b/doc/build/index.html new file mode 100644 index 0000000..65f5feb --- /dev/null +++ b/doc/build/index.html @@ -0,0 +1,311 @@ + + + + + + + + + + + DOC: Plutonium reporter — Plutonium reporter 1.0 documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + + + + +
+ + + + +
+
+
+
+ +
+

DOC: Plutonium reporter

+ +
+

Scope

+

This document covers the software part of the reporter, although it consists +of a multitude of hw technologies, please keep that in mind.

+
+
+

Purpose

+

Delivering aggregated and comprehensive representation of data-value pairs +in such a way, that even a complete idiot can read them. This project is +created by AND for me.

+

In short, this application spins up a web server and on its address plots and +displays values gathered from various sources.

+

An example granted: https://bastart.spoton.cz

+
+

Sources

+

The sources for feeding the Plutonium include:

+
    +
  • Davis Vantage vue weather station (with a couple HW mods)

  • +
  • Victron MPPT solar converter (Utilizing the Victron Direct RS232 protocol)

  • +
  • CPU, MEM, DISK, (W)LAN statistics, plotted

  • +
  • +
    Custom ESP8266 data loggers
      +
    • Temp / Humidity + battery logging

    • +
    • Current monitoring for LED lighting

    • +
    +
    +
    +
  • +
+
+
+

Discrepancies and hardware dependencies

+

Obviously, all the monitoring cannot be done without proper HW equipment. +Although this server is primarily aimed at use on a Raspberry PI, it can be +installed on an old notebook, or similar, as the platform is Python3 and thus +independent of the OS.

+
+

RasPI statistics

+
    +
  • Just the RasPI, should work out of the box

  • +
+
+
+

Davis Vantage Vue

+
    +
  • Obviously the Davis Vantage Vue weather station

  • +
  • The CC1101 / wireless version

  • +
  • arduino mini / Uno @ 3.3V

  • +
  • CC1101 receiver with a couple other components

  • +
  • Data structure received from davis:

    +
    +

    2 = Supercap voltage (Vue only) +3 = ? +4 = UV Index +5 = Rain rate +6 = Solar radiation +7 = Solar Cell output (Vue only) +8 = Temperature +9 = Wind gust +a = Humidity +e = Rain

    +

    {‘nxt’: 64, ‘P0’: 1020.43, ‘lqi’: 6, ‘b2’: 3, ‘P’: 969.29, ‘h’: 144, ‘Ti’: 24.49, +‘cnt’: 1, ‘Hhtu’: 28.68, ‘b4’: 129, ‘b5’: 247, ‘b6’: 36, ‘b7’: 255, ‘b0’: 1, ‘b1’: 10, +‘hop’: 0, ‘b3’: 225, ‘Thtu’: 24.28, ‘b8’: 255, ‘b9’: 182, ‘rssi’: 45}

    +
    +
  • +
+
+
+

Solar / MPPT

+
    +
  • Victron MPPT solar charge controller (Bluesolar)

  • +
  • RS232 -> USB or similar, to get the data to RasPi

  • +
+
+
+

ESP8266 stuff

+
    +
  • basically anything that can feed into the influxDB.

  • +
+
+
+
+
+

Indices and tables

+ +
+
+ + +
+ +
+ + +
+
+ +
+ +
+ + + + + + + + + + + + \ No newline at end of file diff --git a/doc/build/introduction.html b/doc/build/introduction.html new file mode 100644 index 0000000..7aa5247 --- /dev/null +++ b/doc/build/introduction.html @@ -0,0 +1,331 @@ + + + + + + + + + + + Introduction to Plutonium — Plutonium reporter 1.0 documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + + + + +
+ + + + +
+
+
+
+ +
+

Introduction to Plutonium

+
+
+
+

Directory structure

+

Following structure is applied to this project. Some directories are +minified in this view on purpose.

+
.
+├── chttpd.py
+├── config
+│   └── plutonium.ini
+├── config.py
+├── doc ... (documentation in sphinx)
+├── index.py
+├── localdeploy.sh
+├── modules
+│   ├── dynamic.py
+│   ├── status.py
+│   ├── temphumi.py
+│   ├── voltage.py
+│   └── weather.py
+├── static
+│   ├── css
+│   │   ├── bootstrap.css
+│   │   └── dygraph.css ...
+│   ├── img
+│   │   ├── battery_0.png ...
+│   └── js
+│       ├── solar_graph.js
+│       ├── status_graph.js
+│       ├── temphum_graph.js
+│       └── weather_graph.js ...
+├── templates
+│   ├── footer.html
+│   ├── header.html
+│   ├── landing_page.html
+│   ├── status_admin.html
+│   ├── temphumi_admin.html
+│   ├── top_menu.html
+│   ├── voltage_admin.html
+│   └── weather_admin.html
+└── TODO.txt
+
+
+
+
+

CherryPy configuration (config.py)

+

Configuration is stored in a separate file statically, so each submodule can +load the same configuration. This should be variables, that are project-wide.

+
+

CherryPy configuration file (plutonium.ini)

+

Configuration file, .ini style. Option = value. File resides in ./config +directory. It is read by confi.py and parsed into a dict(), available +throughout the project.

+
_server_protocol = https
+_server_name = bastart.spoton.cz
+_server_port = 80
+_server_bind_ip = 0.0.0.0
+_influx_host = localhost
+_influx_port = 8086
+_influx_user = pi
+_influx_pwd = password
+_influx_weather_db = weather_v2
+_influx_status_db = status
+_influx_voltage_db = voltage
+_influx_IoT_db = weather_v2
+
+
+
+
+

Configuration classes and functions

+
+
+
+

CherryPy server (chttpd.py)

+

The server uses CherryPy module. For more information, please consult the +Cherrypy documentation.

+

CHTTPD.py is also the executable, that can be launched as a standalone +application by simply typing ./chttpd.py, or python3 chttpd.py

+
+

Modules and web paths

+

Modules are located in the modules directory, hence the imports from a +subdirectory

+
from modules import voltage
+from modules import weather
+from modules import dynamic
+from modules import status
+from modules import temphumi
+
+
+

As can be seen, each class / module is mounted under a specific web path. This +is the preferred way of future expansion modules.

+
cherrypy.tree.mount(voltage.EnergyInfo(), "/", conf)
+cherrypy.tree.mount(voltage.EnergyInfo(), "/energy", conf)
+cherrypy.tree.mount(weather.WeatherInfo(), "/weather", conf)
+cherrypy.tree.mount(status.StatusInfo(), "/status", conf)
+cherrypy.tree.mount(dynamic.Expose(), "/data", conf)
+cherrypy.tree.mount(temphumi.PuerhInfo(), "/temphumi", conf)
+
+
+
+
+
+

Index (index.py)

+

Reserved for future use. Currently not displayed, as the EnergyInfo() class is +mounted under root(/) of the web, defined in chttpd.py

+
cherrypy.tree.mount(voltage.EnergyInfo(), "/", conf)
+
+
+
+
+

Indices and tables

+ +
+
+ + +
+ +
+ + +
+
+ +
+ +
+ + + + + + + + + + + + \ No newline at end of file diff --git a/doc/build/objects.inv b/doc/build/objects.inv new file mode 100644 index 0000000..f75803f --- /dev/null +++ b/doc/build/objects.inv @@ -0,0 +1,7 @@ +# Sphinx inventory version 2 +# Project: Plutonium reporter +# Version: +# The remainder of this file is compressed using zlib. +xmM +09\B.[7.Jd@~$N@o_mL}o#D> +a"YJ'@FgsԶan gnFS&-rbQ$'zJv[۞9罄FrVG ʐwrm=ndNrG3Ni8.EZĀJkܻNȽD}{db \ No newline at end of file diff --git a/doc/build/search.html b/doc/build/search.html new file mode 100644 index 0000000..3931fab --- /dev/null +++ b/doc/build/search.html @@ -0,0 +1,207 @@ + + + + + + + + + + + Search — Plutonium reporter 1.0 documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + + + + +
+ +
    + +
  • Docs »
  • + +
  • Search
  • + + +
  • + + + +
  • + +
+ + +
+
+
+
+ + + + +
+ +
+ +
+ +
+ + +
+
+ +
+ +
+ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/doc/build/searchindex.js b/doc/build/searchindex.js new file mode 100644 index 0000000..e84663b --- /dev/null +++ b/doc/build/searchindex.js @@ -0,0 +1 @@ +Search.setIndex({docnames:["db_structure","examples","index","introduction"],envversion:{"sphinx.domains.c":1,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":1,"sphinx.domains.javascript":1,"sphinx.domains.math":2,"sphinx.domains.python":1,"sphinx.domains.rst":1,"sphinx.domains.std":1,"sphinx.ext.intersphinx":1,"sphinx.ext.viewcode":1,sphinx:56},filenames:["db_structure.rst","examples.rst","index.rst","introduction.rst"],objects:{},objnames:{},objtypes:{},terms:{"10m":0,"12h":0,"168h":0,"24h":0,"30s":0,"720h":0,"8760h":0,"class":2,"default":0,"function":2,"import":3,"int":0,"short":2,"static":3,AND:2,For:3,INTO:0,The:[2,3],_influx_host:3,_influx_iot_db:3,_influx_port:3,_influx_pwd:3,_influx_status_db:3,_influx_us:3,_influx_voltage_db:3,_influx_weather_db:3,_server_bind_ip:3,_server_nam:3,_server_port:3,_server_protocol:3,address:2,aggreg:2,aim:2,all:2,also:3,alter:0,although:2,anyth:2,appli:3,applic:[2,3],arduino:2,autogen:0,avail:3,basic:2,bastart:[2,3],batteri:[0,2],battery_0:3,begin:0,bluesolar:2,bool:0,bootstrap:3,box:2,can:[2,3],cannot:2,cc1101:2,cell:2,charg:2,cherrypi:2,chttpd:2,cnt:2,complet:2,compon:2,comprehens:2,conf:3,confi:3,config:2,configur:2,consist:2,consult:3,content:2,continu:0,control:2,convert:2,count:0,coupl:2,cover:2,cpu:2,cq_net_1m:0,cq_power_1h:0,cq_power_1m:0,cq_power_30m:0,cq_power_6h:0,cq_rain_10m:0,cq_rain_1h:0,cq_rain_6h:0,cq_temphumi_10m:0,cq_temphumi_1h:0,cq_temphumi_6h:0,cq_usense_12h:0,cq_usense_6h:0,creat:[0,2],css:3,current:[2,3],custom:2,data:[2,3],defin:3,deliv:2,dict:3,direct:2,directori:2,disk:2,displai:[2,3],doc:3,document:[2,3],done:2,drop:0,durat:0,dygraph:3,dynam:3,each:3,energi:3,energyinfo:3,equip:2,even:2,exampl:2,execut:3,expans:3,expos:3,feed:2,field:0,file:2,follow:3,footer:3,from:[0,2,3],futur:3,gather:2,get:2,grant:2,group:0,gust:2,header:3,henc:3,hhtu:2,hop:2,host:0,html:3,http:[2,3],humid:[0,2],humidity_max:0,humidity_min:0,idiot:2,img:3,includ:2,independ:2,index:[1,2],infinit:0,influxdb:2,inform:3,ini:2,instal:2,introduct:2,iss:0,iss_aggreg:0,its:2,just:2,keep:2,lan:2,landing_pag:3,launch:3,led:2,light:2,load:3,localdeploi:3,localhost:3,locat:3,log:2,logger:2,lqi:2,max:0,mean:0,measur:0,mem:2,min:0,mind:2,mini:2,minifi:3,mod:2,modul:[1,2],monitor:2,monthli:0,more:3,mount:3,mppt:0,mppt_aggreg:0,multitud:2,net:0,net_aggreg:0,network:0,nic:0,non_negative_deriv:0,notebook:2,now:0,nxt:2,obvious:2,old:2,onli:2,option:3,other:2,out:2,output:2,p_max:0,p_min:0,page:[1,2,3],pair:2,pars:3,part:2,password:3,path:2,platform:2,pleas:[2,3],plot:2,png:3,polici:0,power:0,prefer:3,pressur:0,primarili:2,project:[2,3],proper:2,protocol:2,puerhinfo:3,purpos:3,python3:[2,3],queri:0,radiat:2,rain:2,rain_bucket_tip:0,rain_tip:0,rainrat:0,rainrate_aggreg:0,raspberri:2,raspi:0,raspi_aggreg:0,rate:2,read:[2,3],realtim:0,receiv:2,replic:0,represent:2,reserv:3,resid:3,retent:0,root:3,rrate:0,rrate_max:0,rs232:2,rssi:2,same:3,schema:0,search:[1,2,3],seen:3,select:0,separ:3,server:2,shard:0,should:[2,3],show:0,similar:2,simpli:3,softwar:2,solar_graph:3,some:3,specif:3,sphinx:3,spin:2,spoton:[2,3],sqlite:0,standalon:3,station:2,statu:3,status_admin:3,status_graph:3,statusinfo:3,store:3,structur:2,style:3,subdirectori:3,submodul:3,supercap:2,t_stamp:0,tabl:0,tag:0,technolog:2,temp:2,temperatur:[0,2],temperature_max:0,temperature_min:0,temphum_graph:3,temphumi:3,temphumi_admin:3,temphumi_aggreg:0,templat:3,them:2,thi:[2,3],throughout:3,thtu:2,thu:2,time:0,tinyint:0,todo:3,top_menu:3,traffic:0,tree:3,txt:3,type:[0,3],under:3,uno:2,usag:0,usb:2,use:[2,3],usense_aggreg:0,uses:3,util:2,val_max:0,valu:[0,2,3],vantage_vue_iss:0,varchar:0,variabl:3,variou:2,version:2,victron:2,view:3,voltag:[0,2,3],voltage_admin:3,wai:[2,3],weather:[0,2,3],weather_admin:3,weather_graph:3,weather_v2:[0,3],weatherinfo:3,web:2,where:0,wide:3,wind:2,wireless:2,without:2,work:2,yeali:0,yearli:0},titles:["Structure of InfluxDB","Dynamic data","DOC: Plutonium reporter","Introduction to Plutonium"],titleterms:{"class":3,"function":3,cherrypi:3,chttpd:3,config:3,configur:3,data:1,davi:2,depend:2,directori:3,discrep:2,doc:2,done:0,dynam:1,end:0,energi:0,esp8266:2,file:3,hardwar:2,index:3,indic:[1,2,3],influxdb:0,ini:3,introduct:3,modul:3,mppt:2,path:3,plutonium:[2,3],purpos:2,rain:0,raspi:2,report:2,scope:2,server:3,solar:2,sourc:2,statist:2,statu:0,structur:[0,3],stuff:2,tabl:[1,2,3],temphumi:0,usens:0,vantag:2,vue:2,weather:1,web:3,wind:0}}) \ No newline at end of file