diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2021-11-27 16:17:05 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2022-04-24 01:33:04 +0300 |
commit | c412bf2ee0a3fbf9032fc32a26837d4fbc7585c5 (patch) | |
tree | 5cca6bcab79331ad82cab4219c7692b9dd4eea21 /doc |
initial public
Diffstat (limited to 'doc')
-rw-r--r-- | doc/arecord_opi_lite.md | 13 | ||||
-rw-r--r-- | doc/autossh.md | 19 | ||||
-rw-r--r-- | doc/database.md | 65 | ||||
-rw-r--r-- | doc/gpio_h3.md | 7 | ||||
-rw-r--r-- | doc/inverter_bot.md | 76 | ||||
-rw-r--r-- | doc/sensors_bot.md | 33 | ||||
-rw-r--r-- | doc/sound_node.md | 72 | ||||
-rw-r--r-- | doc/test_api.md | 12 |
8 files changed, 297 insertions, 0 deletions
diff --git a/doc/arecord_opi_lite.md b/doc/arecord_opi_lite.md new file mode 100644 index 0000000..153f9a1 --- /dev/null +++ b/doc/arecord_opi_lite.md @@ -0,0 +1,13 @@ +In order to use microphone on **Orange Pi Lite**: +- enable audio codec in `armbian-config` +- put this to `/etc/rc.local` (and make it executable): + ``` + for v in unmute cap; do + /usr/bin/amixer set "Line In" $v + /usr/bin/amixer set "Mic1" $v + done + + for k in "Mic1 Boost" "Line In" "Mic1"; do + /usr/bin/amixer set "$k" "86%" + done + ```
\ No newline at end of file diff --git a/doc/autossh.md b/doc/autossh.md new file mode 100644 index 0000000..fdcde19 --- /dev/null +++ b/doc/autossh.md @@ -0,0 +1,19 @@ +`/etc/systemd/system/my-ssh-tunnel.service`: + +``` +[Unit] +Description=ssh tunnel for localhost:22 +After=network.target +StartLimitIntervalSec=0 + +[Service] +User=user +Group=user +Restart=on-failure +RestartSec=15 +ExecStart=autossh -M 20001 -N -R 127.0.0.1:44223:127.0.0.1:22 -o StrictHostKeyChecking=no -o ExitOnForwardFailure=yes solarmon-tunnel@solarmon.ru +WorkingDirectory=/home/user + +[Install] +WantedBy=multi-user.target +```
\ No newline at end of file diff --git a/doc/database.md b/doc/database.md new file mode 100644 index 0000000..ba5a3d2 --- /dev/null +++ b/doc/database.md @@ -0,0 +1,65 @@ +# Databases + +## Inverter database + +ClickHouse tables: +```sql +CREATE TABLE status ( + ClientTime DateTime, + ReceivedTime DateTime, + HomeID UInt16, + GridVoltage UInt16, + GridFrequency UInt16, + ACOutputVoltage UInt16, + ACOutputFrequency UInt16, + ACOutputApparentPower UInt16, + ACOutputActivePower UInt16, + OutputLoadPercent UInt8, + BatteryVoltage UInt16, + BatteryVoltageSCC UInt16, + BatteryVoltageSCC2 UInt16, + BatteryDischargingCurrent UInt16, + BatteryChargingCurrent UInt16, + BatteryCapacity UInt8, + HeatSinkTemp UInt16, + MPPT1ChargerTemp UInt16, + MPPT2ChargerTemp UInt16, + PV1InputPower UInt16, + PV2InputPower UInt16, + PV1InputVoltage UInt16, + PV2InputVoltage UInt16, + MPPT1ChargerStatus Enum8('Abnormal' = 0, 'NotCharging' = 1, 'Charging' = 2), + MPPT2ChargerStatus Enum8('Abnormal' = 0, 'NotCharging' = 1, 'Charging' = 2), + BatteryPowerDirection Enum8('DoNothing' = 0, 'Charge' = 1, 'Discharge' = 2), + DCACPowerDirection Enum8('DoNothing' = 0, 'AC/DC' = 1, 'DC/AC' = 2), + LinePowerDirection Enum8('DoNothing' = 0, 'Input' = 1, 'Output' = 2), + LoadConnected Enum8('Disconnected' = 0, 'Connected' = 1) +) ENGINE = MergeTree() +PARTITION BY toYYYYMMDD(ReceivedTime) +ORDER BY (HomeID, ReceivedTime); + +CREATE TABLE generation ( + ClientTime DateTime, + ReceivedTime DateTime, + HomeID UInt16, + Watts UInt16 +) ENGINE = MergeTree() +PARTITION BY toYYYYMMDD(ReceivedTime) +ORDER BY (HomeID, ReceivedTime); +``` + + +## Sensors database + +ClickHouse tables: +```sql +CREATE TABLE temp_table_name ( + ClientTime DateTime, + ReceivedTime DateTime, + HomeID UInt16, + Temperature Int16, + RelativeHumidity UInt16 +) ENGINE = MergeTree() +PARTITION BY toYYYYMMDD(ReceivedTime) +ORDER BY (HomeID, ReceivedTime); +```
\ No newline at end of file diff --git a/doc/gpio_h3.md b/doc/gpio_h3.md new file mode 100644 index 0000000..d3032ff --- /dev/null +++ b/doc/gpio_h3.md @@ -0,0 +1,7 @@ +As root: + +``` +git clone https://github.com/duxingkei33/orangepi_PC_gpio_pyH3 +cd orangepi_PC_gpio_pyH3 +python3 setup.pysdlfksdf install +```
\ No newline at end of file diff --git a/doc/inverter_bot.md b/doc/inverter_bot.md new file mode 100644 index 0000000..c9b299c --- /dev/null +++ b/doc/inverter_bot.md @@ -0,0 +1,76 @@ +# Inverter Bot + +### Bot configuration + +**`~/.config/inverter_bot/config.toml`**: + +```toml +[bot] +token = "..." +users = [ 1, 2, 3 ] +notify_users = [ 1, 2 ] + +[inverter] +host = "127.0.0.1" +port = 8305 + +[monitor] +vlow = 47 +vcrit = 45 + +gen_currents = [2, 10, 20, 30] +gen_raise_intervals = [ + 180, # 3 minutes for 2 A, then + 120, # 2 more minutes for 10 A, then + 120, # 3 more minutes for 20 A, then, finally, 30 A +] +gen_cur30_v_limit = 56.9 +gen_cur20_v_limit = 56.7 +gen_cur10_v_limit = 54 + +gen_floating_v = 54 +gen_floating_time_max = 7200 + +[logging] +verbose = false + +[api] +token = "..." +``` + +### systemd integration + +**`/etc/systemd/system/inverter_bot.service`**: + +```systemd +[Unit] +Description=inverter bot +After=inverterd.service + +[Service] +User=user +Group=user +Restart=on-failure +ExecStart=/home/user/home/bin/inverter_bot +WorkingDirectory=/home/user + +[Install] +WantedBy=multi-user.target +``` + + +### Commands +``` +lang - Set language +status - Show status +config - Show configuration +errors - Show errors +flags - Toggle flags +calcw - Calculate daily watts usage +calcwadv - Advanced watts usage calculator +setbatuv - Set battery under voltage +setgencc - Set AC charging current +setgenct - Set AC charging thresholds +monstatus - Monitor: dump state +monsetcur - Monitor: set charging currents +```
\ No newline at end of file diff --git a/doc/sensors_bot.md b/doc/sensors_bot.md new file mode 100644 index 0000000..9f1c008 --- /dev/null +++ b/doc/sensors_bot.md @@ -0,0 +1,33 @@ +# Sensors Bot + +Configuration is stored in **`~/.config/sensors_bot/config.toml`**. + +Example: + +```toml +[bot] +token = "..." +users = [ + 1, # user 1 + 2, # user 2 + 3, # user 3 +] + +[api] +token = ..." + +[sensors.name1] +ip = "192.168.0.2" +port = 8306 +label_ru = "Тут" +label_en = "Here" + +[sensors.name2] +ip = "192.168.0.3" +port = 8307 +label_ru = "Там" +label_en = "There" + +[logging] +verbose = false +```
\ No newline at end of file diff --git a/doc/sound_node.md b/doc/sound_node.md new file mode 100644 index 0000000..03e84e4 --- /dev/null +++ b/doc/sound_node.md @@ -0,0 +1,72 @@ +# Sound Node + +## Requirements + +``` +apt install -y python3-aiohttp python3-requests python3-toml +``` + +## Configuration + +Orange Pi Lite config (`/etc/sound_node.toml`): + +```toml +[node] +listen = "0.0.0.0:8313" +process_wait_timeout = 10 +name = "nodename" + +record_max_time = 1800 +storage = "/var/recordings" + +[arecord] +bin = "/usr/bin/arecord" + +[lame] +bin = "/usr/bin/lame" +bitrate = 192 + +[amixer] +bin = "/usr/bin/amixer" +controls = [ + { + name = "Line In", + caps = ["mute", "cap", "volume"] + }, + { + name = "Mic1", + caps = ["mute", "cap", "volume"] + }, + { + name = "Mic1 Boost", + caps = ["volume"] + } +] + +[logging] +verbose = false +default_fmt = true +``` + +## Audio recording + +Install `lame`. + +Command to record audio: `arecord -v -f S16 -r 44100 -t raw 2>/dev/null | lame -r -s 44.1 -b 192 -m m - output.mp3 >/dev/null 2>/dev/null` + +## Uploading audios to remote server + +- Generate ssh keys for root on each sound node: + ``` + cd /root/.ssh + ssh-keygen -t ed25519 + ``` +- Add public keys on the remote server +- Copy `tools/sync-recordings-to-remote.sh` script to `/usr/local/bin` on all sound nodes, don't forget to `chmod +x` it. +- Add following lines to the root crontab (on all sound nodes): + ``` + TG_TOKEN="your telegram bot token" + TG_CHAT_ID="your telegram chat id" + + 30 * * * * /usr/local/bin/sync-recordings-to-remote.sh + ```
\ No newline at end of file diff --git a/doc/test_api.md b/doc/test_api.md new file mode 100644 index 0000000..9c0483f --- /dev/null +++ b/doc/test_api.md @@ -0,0 +1,12 @@ +# test_api.py + +Config example: +```toml +[api] +host = "app-dev.domain.ru" +token = "" +basic_auth = "user:password" + +[logging] +verbose = true +```
\ No newline at end of file |