Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analog sensor vegetronix #223

Open
wants to merge 67 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
ef3161e
Added sensor2 and soil moisture sensor
opensprinklershop Jul 12, 2019
df7c098
RAIN->SOIL
opensprinklershop Jul 12, 2019
3992adb
Added sensor2 and soil moisture sensor
opensprinklershop Jul 12, 2019
889210d
RAIN->SOIL
opensprinklershop Jul 12, 2019
fd56955
Merge remote-tracking branch 'upstream/dev/219-7'
opensprinklershop Oct 1, 2020
69e35e3
Merge branch 'master' of https://github.com/opensprinklershop/OpenSpr…
opensprinklershop Oct 1, 2020
61673ab
lwip version - bases on Arduino 3.0.2: Needs updates version of LitteFS
opensprinklershop Apr 1, 2022
0b70b8b
Update README.txt
opensprinklershop Apr 1, 2022
e1af753
Update README.txt
opensprinklershop Apr 1, 2022
81eaf3b
Version 105: Register check enc_28j60, dhcp_renew und check_network
Apr 2, 2022
ad2c2a3
- static ip init fix
May 26, 2022
337ddf0
When using a Fixed IP don't call dhcp_renew
Jun 7, 2022
37d7beb
2.2.0.108
Jul 24, 2022
6bf0802
Version .109 mit geänderten Build Flags und zusätzlicher Wiederholung…
Jul 30, 2022
35f0e02
Version 111
Sep 7, 2022
2d88056
Update 112
Oct 15, 2022
8f2cb95
sensor groups added
Oct 15, 2022
a2e5757
Sensor Api working
Oct 28, 2022
e404865
Water adjustments calculation added (incomplete...)
Nov 1, 2022
b932e97
Analog sensor board test commit
opensprinklershop Nov 11, 2022
c2401b8
Added ADS1015 support
Nov 15, 2022
9fa0931
Working plattformio.ini , new sensors: SMT50 Moisture+Temp, changed l…
Nov 15, 2022
4eefe68
List Program adjustments (se) and List supported sensor types (sf) added
Nov 16, 2022
892faca
- list sensor types
Nov 19, 2022
dc34bba
1. Update Sensor API
Nov 23, 2022
af2cce4
sg+sr with optional nr parameter
Dec 7, 2022
1571ef3
Sensor API added flags / show option
Dec 26, 2022
6c64ebb
Added effective program adjustment output for se
Dec 27, 2022
092b0be
Fixt sensor timeout issue
Dec 28, 2022
66c3d30
Analog Sensor API V1.0 Release
Jan 12, 2023
3430975
Analog Sensor API V1.0 Release
Jan 13, 2023
930de19
Added dhcp and enc28J60 check
Jan 13, 2023
7bdcd0a
Fix ADC sensor id
Jan 16, 2023
1955089
*.bak to gitignore
Jan 16, 2023
bc71c28
Added Ping check (icmp ping)
Jan 16, 2023
03cd825
Start OSPi compat
Jan 26, 2023
66dc372
Next step OSPi compat
Jan 26, 2023
4b301bd
Another OSPi compat
Jan 26, 2023
e62df05
Next OSPi sensor compat try
Jan 26, 2023
0bec617
Fix ip convert OSPi
Jan 26, 2023
36b0f8c
OSPi compat
Jan 26, 2023
1a5f82b
Tryfix peek for OSPi
Jan 26, 2023
39b7253
read data OSPi compat
Jan 26, 2023
23ce723
Typo fix
Jan 26, 2023
d7be929
Added support for OpenThingsFramework - big result data
Jan 30, 2023
6fb6b05
Added support for Vegetronix VH400, THERM200 and AQUAPLUMB
Jan 31, 2023
e705a3f
Added SMT100 Analog support
Feb 13, 2023
2d2837d
Fix log crash
Feb 15, 2023
3e770e8
Log Switching: Analog sensor data is logged in 2 files with max 8000 …
Feb 22, 2023
b998a40
fix remote sensor read
Feb 24, 2023
f59da7b
fix remote sensor read
Feb 24, 2023
e67bc82
Added download log as CSV
Feb 27, 2023
3a84c20
Fix Program adjustment (prog1 = prog0)
Mar 4, 2023
0ed3df8
Fixed logging switch: Rotating log with 2x 8000 entries,
Mar 10, 2023
b550d72
Fix: Deleted last sensor or program adjustment
Mar 19, 2023
9a4bd96
Fix: if a group has logging enabled, logging is
Mar 19, 2023
6a26b06
Added Support for ApexCharts Day, Week and Month
Apr 5, 2023
7d2766f
1. sensor configuration with "data_ok" flag 2. Faster week+month stat…
Apr 6, 2023
b523a8c
Fix weeklog + monthlog calculation
Apr 12, 2023
5fdf1b6
Fix Week/Month calculation, if some days are missing
Apr 13, 2023
c697771
Fix week/month calc
Apr 14, 2023
605fec1
Fix large logs downloading
Apr 14, 2023
78f01e7
Added weather data as a sensor for logging weather
Apr 29, 2023
e22369b
Sensor values published by MQTT and IFTTT
May 7, 2023
028a1fb
- added mqtt checks
May 7, 2023
7b8edf5
V 2.3.0(126): Ping check only reboots, if we
May 8, 2023
46e8fe8
changed 0-3.3V 100% sensor to "level %", fixed wifi lost after 1h
May 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ testmode.h
build-1284/*
.vscode
.pio
*.bak
137 changes: 137 additions & 0 deletions Sensor API.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
Sensor API
This api documentation is part of the opensprinkler

<ip> the ip-address, for example 192.168.0.55
<pw> the MD5 encrypted password, opendoor=a6d82bced638de3def1e9bbb4983225c


Create Sensors (sc):
creates, modifies or deletes a sensor.
"nr" for a unique number >= 1
"type" for the sensor-type, see sf. type=0 deletes the sensor
"group" for group assignment, a nr of another sensor with type=SENSOR_GROUP_YXZ
"name" a name
"ip" for the ip-address, only for network connected sensors. All others use ip=0
"port" for the ip-port-address, only for network connected sensors. All others use port=0
"id" sub-id, e.a. modbus address or subid, for ADC Sensors 0..7
"ri" read interval in seconds
"enable" 0=sensor disabled, 1=sensor enabled
"log" 0=logging disabled, 1=logging enabled

examples:
http://<ip>/sc?pw=<pw>&nr=1&type=1&group=0&name=SMT100-Mois&ip=4261456064&port=8899&id=253&ri=60&enable=1&log=1
http://<ip>/sc?pw=<pw>&nr=2&type=2&group=0&name=SMT100-Temp&ip=4261456064&port=8899&id=253&ri=60&enable=1&log=1
http://<ip>/sc?pw=<pw>&nr=3&type=11&group=0&name=SMT50-Mois&ip=0&id=0&ri=60&enable=1&log=1
http://<ip>/sc?pw=<pw>&nr=4&type=12&group=0&name=SMT50-Temp&ip=0&id=1&ri=60&enable=1&log=1

ip: dec=4261456064 = hex=FE00A8C0 =
FE = 254
00 = 000
A8 = 168
C0 = 192
= 192.168.000.254

For the Truebner SMT100 RS485 Modbus you need a RS485 Modbus RTU over TCP converter.
Set ip/port for the converter, e.a PUSR USR-W610 in transparent modus.

For the analog ports of the extension board (including SMT50) use id 0..7

type:
SENSOR_NONE 0 None or deleted sensor
SENSOR_SMT100_MODBUS_RTU_MOIS 1 Truebner SMT100 RS485 Modbus RTU over TCP, moisture mode
SENSOR_SMT100_MODBUS_RTU_TEMP 2 Truebner SMT100 RS485 Modbus RTU over TCP, temperature mode
SENSOR_ANALOG_EXTENSION_BOARD 10 New OpenSprinkler analog extension board x8 - voltage mode 0..4V
SENSOR_ANALOG_EXTENSION_BOARD_P 11 New OpenSprinkler analog extension board x8 - percent 0..3.3V to 0..100%
SENSOR_SMT50_MOIS 15 New OpenSprinkler analog extension board x8 - SMT50 VWC [%] = (U * 50) : 3
SENSOR_SMT50_TEMP 16 New OpenSprinkler analog extension board x8 - SMT50 T [°C] = (U – 0,5) * 100
SENSOR_OSPI_ANALOG_INPUTS 20 Old OSPi analog input
SENSOR_REMOTE 100 Remote sensor of an remote opensprinkler
SENSOR_GROUP_MIN 1000 Sensor group with min value
SENSOR_GROUP_MAX 1001 Sensor group with max value
SENSOR_GROUP_AVG 1002 Sensor group with avg value
SENSOR_GROUP_SUM 1003 Sensor group with sum value

List Sensors (sl):
lists the current sensors
examples:
http://<ip>/sl?pw=<pw>

Get last Sensor values (sg):
returns last read sensor values
examples:
http://<ip>/sg?pw=<pw>
http://<ip>/sg?pw=<pw>&nr=1

Read sensor now (sr):
executes sensor read and returns the values
examples:
http://<ip>/sr?pw=<pw>
http://<ip>/sr?pw=<pw>&nr=1

Set sensor address for SMT100 (sa):
Only for SMT100: Set modbus address
Disconnect all other modbus sensors, so that only one sensor is connected. Sets the modbus address for sensor nr to id
examples:
http://<ip>/sa?pw=<pw>&nr=1&id=1

Dump Sensor Log (so):
dumps the sensor log
examples:
http://<ip>/so?pw=<pw>
http://<ip>/so?pw=<pw>&start=0&max=100&nr=1&type=1&before=1666915277&after=1666915277

Clear Sensor Log (sn):
clears the sensor log
examples:
http://<ip>/sn?pw=<pw>

Program adjustments (sb):
defines program adjustments
"nr" adjustment-nr
"type" adjustment-type (0=delete, 1=linear, 2=digital min, 3=digital max)
"sensor" sensor-nr
"prog" program-nr
"factor1", "factor2", "min", "max" formula-values
examples:
http://<ip>/sb?pw=<pw>&nr=1&type=1&sensor=4&prog=1&factor1=0&factor2=2&min=0&max=50

type:
PROG_NONE 0 //No adjustment (delete)
PROG_LINEAR 1 //formula
PROG_DIGITAL_MIN 2 //1=under or equal min, 0=above
PROG_DIGITAL_MAX 3 //1=over or equal max, 0=below

formula:
min max factor1 factor2
10..90 -> 5..1 factor1 > factor2
a b c d
(b-sensorData) / (b-a) * (c-d) + d

10..90 -> 1..5 factor1 < factor2
a b c d
(sensorData-a) / (b-a) * (d-c) + c

min/max is the used range of the sensor (for example min=10 max=80)
factor1/factor2 is the calculated adjustment (for example factor1=2 factor2=0)
So a sensordata of 10 will be a adjustment of factor 2 (200%) or
a sensordata of 80 will be a adjustment of factor 0 (0%)
everything between will be linear scaled in the range of 0..2

List Program adjustments (se):
lists the current program adjustments
examples:
http://<ip>/se?pw=<pw>
&nr=1&prog=1

List supported sensor types (sf):
lists supported sensor types
examples:
http://<ip>/sf?pw=<pw>

List supported program adjustments (sh):
http://<ip>/sh?pw=<pw>

System used and free space (du):
http://<ip>/du?pw=<pw>


6 changes: 3 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ if [ "$1" == "demo" ]; then
echo "Installing required libraries..."
apt-get install -y libmosquitto-dev
echo "Compiling firmware..."
g++ -o OpenSprinkler -DDEMO -std=c++14 -m32 main.cpp OpenSprinkler.cpp program.cpp opensprinkler_server.cpp utils.cpp weather.cpp gpio.cpp etherport.cpp mqtt.cpp -lpthread -lmosquitto
g++ -o OpenSprinkler -DDEMO -std=c++14 -m32 main.cpp OpenSprinkler.cpp program.cpp opensprinkler_server.cpp utils.cpp weather.cpp gpio.cpp etherport.cpp mqtt.cpp sensors.cpp -lpthread -lmosquitto
elif [ "$1" == "osbo" ]; then
echo "Installing required libraries..."
apt-get install -y libmosquitto-dev
echo "Compiling firmware..."
g++ -o OpenSprinkler -DOSBO main.cpp OpenSprinkler.cpp program.cpp opensprinkler_server.cpp utils.cpp weather.cpp gpio.cpp etherport.cpp mqtt.cpp -lpthread -lmosquitto
g++ -o OpenSprinkler -DOSBO main.cpp OpenSprinkler.cpp program.cpp opensprinkler_server.cpp utils.cpp weather.cpp gpio.cpp etherport.cpp mqtt.cpp sensors.cpp -lpthread -lmosquitto
else
echo "Installing required libraries..."
apt-get update
Expand All @@ -31,7 +31,7 @@ else
exit 0
fi
echo "Compiling firmware..."
g++ -o OpenSprinkler -DOSPI main.cpp OpenSprinkler.cpp program.cpp opensprinkler_server.cpp utils.cpp weather.cpp gpio.cpp etherport.cpp mqtt.cpp -lpthread -lmosquitto
g++ -o OpenSprinkler -DOSPI main.cpp OpenSprinkler.cpp program.cpp opensprinkler_server.cpp utils.cpp weather.cpp gpio.cpp etherport.cpp mqtt.cpp sensors.cpp -lpthread -lmosquitto
fi

if [ ! "$SILENT" = true ] && [ -f OpenSprinkler.launch ] && [ ! -f /etc/init.d/OpenSprinkler.sh ]; then
Expand Down
6 changes: 3 additions & 3 deletions defines.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@
#ifndef _DEFINES_H
#define _DEFINES_H

//#define ENABLE_DEBUG // enable serial debug
#define ENABLE_DEBUG // enable serial debug

typedef unsigned char byte;
typedef unsigned long ulong;

#define TMP_BUFFER_SIZE 255 // scratch buffer size

/** Firmware version, hardware version, and maximal values */
#define OS_FW_VERSION 220 // Firmware version: 220 means 2.2.0
#define OS_FW_VERSION 230 // Firmware version: 220 means 2.2.0
// if this number is different from the one stored in non-volatile memory
// a device reset will be automatically triggered

#define OS_FW_MINOR 1 // Firmware minor version
#define OS_FW_MINOR 127 // Firmware minor version

/** Hardware version base numbers */
#define OS_HW_VERSION_BASE 0x00 // OpenSprinkler
Expand Down
Loading