Moved directories to make github pages work

This commit is contained in:
Magnus Persson
2022-01-06 16:49:58 +01:00
parent 27b7b70998
commit 4de40366bb
153 changed files with 40132 additions and 2 deletions

View File

@ -0,0 +1,19 @@
Backlog of changes
######################################
Documentation
-------------
- Create page with list of releases
- Updates over OTA (from PC)
- Write compile instructions
- Write contribution instructions
- publish docs
Code
-------------
- Support for MQTT
- Support for plato
- Use pre-commit for validating check-in
- Automatic builds via github actions

View File

@ -0,0 +1,21 @@
Compiling the software
-----------------------
This section is under construction.
VSCODE + PlatformIO
=============================
Targets
=============================
Source structure
=============================
Options
=============================

55
src_docs/source/conf.py Normal file
View File

@ -0,0 +1,55 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
# -- Project information -----------------------------------------------------
project = 'GravityMon'
copyright = '2021-2022, Magnus Persson'
author = 'Magnus Persson'
# The full version, including alpha/beta/rc tags
release = '0.5.0'
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

View File

@ -0,0 +1,441 @@
Configuration
-----------------------
The device can operate in two modes and must be in `configuration mode` in order for the web server to be active.
One of the following conditions will place the device in `configuration mode`:
- Gyro has not been calibrated
- Sleep mode has been disabled in the web interface
- Placed in horizontal mode 85-90 degrees
- Charger connected >4.15V
Main index
==========
URL: (http://gravmon.local)
.. image:: images/index.png
:width: 800
:alt: Index page
Configuration is accessed by entering the URL for the device, this will be the mDNS name *device.local* or the IP adress. The following chapter assumes the device name is *gravmon*.
The main page shows the device readings; gravity, angle, temperature and battery charge. If the checkbox is active then the device will never go into sleep mode. This is useful if
you are collecting angle/tilt for calibration. If this is unchecked the device will change mode as explained before.
.. note::
If you are connected to the device via a serial console (speed: 115200) you can see the connection sequence and get the Unique ID and IP adress from there.
Device
======
URL: (http://gravmon.local/device)
.. image:: images/device.png
:width: 800
:alt: Device Settings
* **Version:**
Installed version of the code and html files.
* **Device name:**
This is unique name of the device.
* **Device ID:**
This is unique identifier for the device (ESP8266 id), this is required when using the API as an API Key to safeguard against faulty requests.
Configuration
=============
URL: (http://gravmon.local/config)
Device Setting
**************
.. image:: images/config1.png
:width: 800
:alt: Device Settings
* **Device name:**
This is unique name for the device. It will be used in pushing data as well as mDNS name on the network (<name>.local)
* **Temperature format:**
Choose between Celsius and Farenheight
* **Interval:**
This defines how long the device should be sleeping between the readings when in `gravity monitoring` mode. You will also see the values in minutes/seconds to easier set the interval. 900s is a recommended interval.
.. note::
The sleep interval can be set between 10 - 3600 seconds (60 minutes).
* **Calibration values:**
These are calibration data for the gyro. Place the device flat on a table and press the button to save the default orientation values. Without this calibration we cannot calculate the correct angle/tilt.
.. note::
The device will **not** go into `gravity monitoring` mode unless calibrated
Push Settings
*************
.. image:: images/config2.png
:width: 800
:alt: Push Settings
* **HTTP URL 1:**
Endpoint to send data via http. Format used is standard iSpindle format (see format section).
* **HTTP URL 2:**
Endpoint to send data via http. Format used is standard iSpindle format (see format section).
* **Brewfather URL:**
Endpoint to send data via http to brewfather. Format used is defined by brewfather (see format section).
* **Influx DB v2 URL:**
Endpoint to send data via http to InfluxDB. For format (see format section).
* **Influx DB v2 Organisation:**
Name of organisation in Influx.
* **Influx DB v2 Bucket:**
Identifier for bucket.
* **Influx DB v2 Token:**
Token with write access to bucket.
Gravity Settings
****************
.. image:: images/config3.png
:width: 800
:alt: Gravity Settings
* **Gravity formula:**
Gravity formula is compatible with standard iSpindle formulas so any existing calculation option can be used. Is updated if the calibration function is used.
* **Temperature correct gravity:**
Will apply a temperature calibration formula to the gravity as a second step.
This is the formula used for temperature calibration (temp is in F). Cal = 20C.
::
gravity*((1.00130346-0.000134722124*temp+0.00000204052596*temp^2-0.00000000232820948*temp^3)/(1.00130346-0.000134722124*cal+0.00000204052596*cal^2-0.00000000232820948*cal^3))
Hardware Settings
*****************
.. image:: images/config4.png
:width: 800
:alt: Hardware Settings
* **Voltage factor:**
Factor used to calcualate the battery voltage. If you get a too low/high voltage you can adjust this value.
* **Temperature correction:**
This value will be added to the temperature reading (negative value will reduce temperature reading).
* **OTA URL:**
Should point to a URL where the .bin file + version.json file is located.
For the OTA to work, place the following files (version.json + firmware.bin) at the location that you pointed out in OTA URL. If the version number in the json file is newer than in the
code the update will be done during startup.
Example; OTA URL (don't forget trailing dash), the name of the file should be firmware.bin
::
http://192.168.1.1/firmware/gravmon/
Contents version.json
::
{ "project":"gravmon", "version":"0.5.0" }
Create formula
=============================
.. image:: images/formula1.png
:width: 800
:alt: Formula data
Here you can enter up to 5 values (angles + gravity) that is then used to create the formula. Angles equal to zero will be regarded as empty even if there is a gravity reading.
.. image:: images/formula2.png
:width: 800
:alt: Formula graph
Once the formula is created a graph over the entered values and a simulation of the formula will give you a nice overview on how the formula will work.
REST API
=============================
GET: /api/config
****************
Retrive the current configuation of the device via an HTTP GET command. Payload is in JSON format.
::
{
"mdns": "gravmon",
"id": "ee1bfc",
"ota-url": "http://192.168.1.50:80/firmware/gravmon/",
"temp-format": "C",
"brewfather-push": "http://log.brewfather.net/stream?id=Qwerty",
"http-push": "http://192.168.1.50:9090/api/v1/Qwerty/telemetry",
"http-push2": "http://192.168.1.50/ispindel",
"influxdb2-push": "http://192.168.1.50:8086",
"influxdb2-org": "Qwerty",
"influxdb2-bucket": "Qwerty",
"influxdb2-auth": "Qwerty",
"sleep-interval": 30,
"voltage-factor": 1.59,
"gravity-formula": "0.0*tilt^3+0.0*tilt^2+0.0017978*tilt+0.9436",
"gravity-format": "G",
"temp-adjustment-value": 0,
"gravity-temp-adjustment": false,
"gyro-calibration-data": {
"ax": -330,
"ay": -2249,
"az": 1170,
"gx": 99,
"gy": -6,
"gz": 4
},
"angle": 90.93,
"gravity": 1.105,
"battery": 0.04
}
GET: /api/device
****************
Retrive the current device settings via an HTTP GET command. Payload is in JSON format.
::
{
"app-name": "GravityMon ",
"app-ver": "0.0.0",
"id": "ee1bfc",
"mdns": "gravmon"
}
GET: /api/status
****************
Retrive the current device status via an HTTP GET command. Payload is in JSON format.
::
{
"id": "ee1bfc",
"angle": 89.86,
"gravity": 1.1052,
"gravity-tempcorr": 1.1031,
"temp-c": 0,
"temp-f": 32,
"battery": 0,
"temp-format": "C",
"sleep-mode": false,
"rssi": -56
}
GET: /api/config/formula
************************
Retrive the data used for formula calculation data via an HTTP GET command. Payload is in JSON format.
::
{
"id": "ee1bfc", // Unique id of the device (API Key)
"a1": 22.4, // Angles 1-5
"a2": 54.4,
"a3": 58,
"a4": 0,
"a5": 0,
"g1": 1.000, // Gravity 1-5
"g2": 1.053,
"g3": 1.062,
"g4": 1,
"g5": 1
"gravity-formula": "0.0*tilt^3+0.0*tilt^2+0.0017978*tilt+0.9436",
}
POST: /api/config/device
************************
Used to update device settings via an HTTP POST command. Payload is in JSON format.
::
{
"id": "ee1bfc", // Unique id of the device (API Key)
"mdns": "gravmon", // Network name / Device name
"temp-format": "C", // Can be either C or F
"sleep-interval": 30 // Time in seconds.
}
POST: /api/config/push
**********************
Used to update push settings via an HTTP POST command. Payload is in JSON format.
::
{
"id": "ee1bfc", // Unique id of the device (API Key)
"http-push": "http://192.168.1.50/ispindel",
"http-push2": "",
"brewfather-push": "",
"influxdb2-push": "http://192.168.1.50:8086",
"influxdb2-org": "Qwerty",
"influxdb2-bucket": "Qwerty",
"influxdb2-auth": "Qwerty"
}
POST: /api/config/gravity
*************************
Used to update gravity settings via an HTTP POST command. Payload is in JSON format.
::
{
"id": "ee1bfc", // Unique id of the device (API Key)
"gravity-formula": "0.0*tilt^3+0.0*tilt^2+0.0017978*tilt+0.9436",
"gravity-temp-adjustment": "off" // Can be on or off
}
POST: /api/config/gravity
*************************
Used to update hardware settings via an HTTP POST command. Payload is in JSON format.
::
{
"id": "ee1bfc", // Unique id of the device (API Key)
"voltage-factor": 1.59,
"temp-adjustment": 0,
"ota-url": "http://192.168.1.50/firmware/gravmon/"
}
POST: /api/config/formula
*************************
Used to update formula calculation data via an HTTP POST command. Payload is in JSON format.
::
{
"id": "ee1bfc", // Unique id of the device (API Key)
"a1": 22.4, // Angles 1-5
"a2": 54.4,
"a3": 58,
"a4": 0,
"a5": 0,
"g1": 1.000, // Gravity 1-5
"g2": 1.053,
"g3": 1.062,
"g4": 1,
"g5": 1
}
Data Formats
=============================
iSpindle format
***************
This is the format used for standard http posts.
::
{
"name" : "gravmon", // mDNS name
"ID": "2E6753", // esp device id
"token" : "gravmon",
"interval": 900,
"temperature": 20.5, // C or F based on setting, adjusted value.
"temp-units": "C", // C or F based on setting
"gravity": 1.0050, // Raw or temperature corrected gravity (based on setting)
"corr-gravity": 1.0050, // Temperature corrected gravity
"angle": 45.34,
"battery": 3.67,
"rssi": -12,
// Extension fields
"run-time": 230, // ms, Runtime for this reading, this is an additional field not part of the standard format
}
Brewfather format
******************
This is the format for Brewfather
::
{
"name" : "gravmon", // mDNS name
"temp": 20.5,
"temp-unit": "C",
"battery": 3.67,
"gravity": 1.0050,
"gravity_unit": "G", // G = SG, Plato is not yet supported
}
Influx DB v2
************
This is the format for InfluxDB v2
::
measurement,host=<mdns>,device=<id>,temp-format=<C|F>,gravity-format=SG,gravity=1.0004,corr-gravity=1.0004,angle=45.45,temp=20.1,battery=3.96,rssi=-18

View File

@ -0,0 +1,5 @@
Contributing
------------
This section is under construction.

View File

@ -0,0 +1,73 @@
Functionallity
==============
The main differences
--------------------
* **Operates in two modes `gravity monitoring` and `configuration mode`**
In gravity monitoring mode it behaves just like the iSpindle, it wakes up at regular intervals, measure angle/tile, temperature, calculates gravity and pushes the data to defined endpoints.
In configuration mode the device is always active and the webserver is active. Here you can view the angle/tilt values, change configuration options and more. When in this mode you can also interact with the device
via an REST API so data can be pushed to the device via scripts (see API section for more information)-
*See the configuration section for more information on how to trigger the configuration mode.*
* **Can send data to multiple endpoints at once**
The orignial iSpindle can only have one destination, this sofware will push data to all defined endpoints so in theory you can use them all. However this will consume a lot of battery power so use only as many as needed.
Currently the device supports the following endpoints: http (2 differnt), influxdb2 and Brewfather
If you want additional targets please raise a feature request in the github repo.
* **Build in function to create gravity formulas, so no need for using other tools for this part**
Another big difference is that this software can create the gravity formula in the device, just enter the angle/gravity data that you have collected. You will also see a graph simulating how the formula would work.
* **Automatic temperature adjustment of gravity reading**
If you want to correct gravity based on beer temperature you can do this in the formula but here is a nice feature that can correct the gravity as a second step making this independant of the formula.
.. note::
This feature needs more testing to be validated.
* **OTA support from local webserver**
When starting up in configuration mode the device will check for a software update from a local webserver.
* **DS18B20 temperature adjustments**
You can adjust the temperature reading of the temperature sensor.
* **Gyro Movement**
The software will detect if the gyro is moving and if this is the case it will go back to sleep for 60seconds. This way we should avoid faulty measurements.
Other features
--------------
* Support for Celcius and Farenheigt as temperature formats.
* Support SG (Plato is not yet supported)
* Gyro data is read 50 times to ensure good accuracy
Experimental features
---------------------
* Use the temperature sensor in the gyro instead of DS18B20
This works fine when the device has time to cool down between measurements and it saves a few milliseconds (reduced battery consumption). My testing shows that this is quite accurate.
.. note::
This is not enabled by default.
* Performance measurements
I've also create a small library to measure execution code in some areas of the code that i know is time consuming. This way I can find a good balance between performace and quality.
*See the compile section for more information.*

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

79
src_docs/source/index.rst Normal file
View File

@ -0,0 +1,79 @@
.. GravityMon documentation master file, created by
sphinx-quickstart on Wed Jan 5 22:46:42 2022.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to GravityMon's documentation!
######################################
GravityMon is a replacement firmare for the iSpindle hardware. It's used to measure gravity in beer and show the progress
of fermentation.
For more information on this topic and function please visit https://www.ispindel.de.
I started GravityMon because i like to create software and wanted to do some low level programming. I had done a few
projects based on esp8266 and also started to brew beer so this combination was quite natural.
The hardware design comes from the fantastic iSpindle project so that is not covered in this documentation.
My approach to this software is a little different from that the original ispindle firmware.
.. note::
This software is in the early stages even though its more than one year old so if you find issues, please
open a ticket on github.
I dont take responsibility for any errors that can cause problems with the use. I have tested v0.4 on 5+ brews
over the last 6 months without any issues.
The main differences:
---------------------
* Operates in two modes `gravity monitoring` and `configuration mode`
* Send data to multiple endpoints when pushing data.
* Automatic temperature adjustment of gravity reading
* OTA support from local webserver
* Build in function to create gravity formulas (*New in v0.5*)
There are also a experimental features such as:
* Using the temperature sensor in gyro instead of DS18B20 (faster)
* Performance measurements (used to optimise code)
**For a complete breakdown see the functionallity section.**
Credits to
----------
This software uses the following libraries and without these this would have been much more difficult to acheive:
* https://github.com/jrowberg/i2cdevlib.git
* https://github.com/codeplea/tinyexpr
* https://github.com/graphitemaster/incbin
* https://github.com/khoih-prog/ESP_DoubleResetDetector
* https://github.com/tzapu/WiFiManager
* https://github.com/thijse/Arduino-Log
* https://github.com/bblanchon/ArduinoJson
* https://github.com/PaulStoffregen/OneWire
* https://github.com/milesburton/Arduino-Temperature-Control-Library
* https://github.com/Rotario/arduinoCurveFitting
* https://graphjs.com/
* https://getbootstrap.com/
.. toctree::
:maxdepth: 2
:caption: Contents:
functionallity
installation
configuration
compiling
contributing
backlog
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

View File

@ -0,0 +1,32 @@
Installation
------------
Official esptool
================
The prefered option for flashing esp8266 device is via the official esptool. Documentation can be found
here; https://docs.espressif.com/projects/esptool/en/latest/esp32/
The basic command for flashing is;
``esptool.py --port COM4 write_flash 0x1000 firmware.bin``
In the /bin directory you will find 3 different firmware builds;
* firmware.bin - This is the standard release build (prefered version)
* firmware-perf.bin - This version also submits performance data to an influx database with detailed execution times.
* firmware-debug.bin - Development build. Not recommended for normal use.
In these versions all the html files are embedded in the binaries. The file system is currently only used for storing
the configuration file.
If the software becomes so large the html files can be moved to the file system, but this is not enabled by default. This makes
installation much easier and ensure that html files and code is in sync.
Configuring WIFI
================
When the device is flashed it will need to have WIFI configuration in order to work. If this is not configured in the device it will create an wirless access point called `GravMon`.
Connect to this AP and enter the SSID and password you want to use. If the web page dont open automatically you can enter the following adress in the browser: **http://192.168.4.1**