New final

This commit is contained in:
Milan Toman
2021-01-20 15:03:50 +01:00
parent 7f7b593450
commit 58b74300cb
19 changed files with 2203 additions and 0 deletions

244
doc/build/_sources/db_structure.rst.txt vendored Normal file
View File

@@ -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

31
doc/build/_sources/examples.rst.txt vendored Normal file
View File

@@ -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`

95
doc/build/_sources/index.rst.txt vendored Normal file
View File

@@ -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`

134
doc/build/_sources/introduction.rst.txt vendored Normal file
View File

@@ -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`