Skip to content
This repository was archived by the owner on Mar 6, 2025. It is now read-only.

Commit a87e362

Browse files
committed
add ADS1115 moisture functionality
1 parent c1162e6 commit a87e362

File tree

7 files changed

+432
-195
lines changed

7 files changed

+432
-195
lines changed

ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Release 3.0.0:
1313
- change deprecated SPIFFS to LittleFS
1414
- move all webfiles (css,js) to FS
1515
- create new Webpage to maintain the FS-files, editing json registers on-the-fly is now possible
16+
- add ADS1115 moisture functionality
1617

1718
Release 2.5.3:
1819
- Bug: Oled Typ selectionbox in GUI will now list correct

data/web/sensorconfig.html

Lines changed: 181 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -6,149 +6,196 @@
66
<link rel='stylesheet' type='text/css' href='/web/Style.css'>
77
<script language='javascript' type='text/javascript' src='/web/esp/gpio.js'></script>
88
<script language='javascript' type='text/javascript' src='/web/Javascript.js'></script>
9+
<script language='javascript' type='text/javascript' src='/web/valvefunctions.js'></script>
910
<script language='javascript' type='text/javascript' src='/web/sensorconfig.js'></script>
1011
<title>Pumpcontrol</title>
1112
</head>
1213
<body>
1314

1415
<form id='DataForm'>
15-
<table id='maintable' class='editorDemoTable'>
16-
<thead>
17-
<tr>
18-
<td style='width: 250px;'>Name</td>
19-
<td style='width: 200px;'>Wert</td>
20-
</tr>
21-
</thead>
22-
<tbody>
23-
24-
<tr>
25-
<td colspan='2'>
26-
<div class='inline'>
27-
<input type='radio' id='sel0' name='selection' value='none' onclick="radioselection([''],['all_1','all_2','all_3','analog_0','analog_1','analog_2','hcsr04_1','hcsr04_2','hcsr04_3','hcsr04_4','extern_1','ads1115_0','ads1115_1'])"/>
28-
<label for='sel0'>keine Füllstandsmessung</label>
29-
</div>
30-
31-
<div class='inline'>
32-
<input type='radio' id='sel1' name='selection' value='hcsr04' onclick="radioselection(['all_1','all_2','all_3','hcsr04_1','hcsr04_2','hcsr04_3','hcsr04_4'],['analog_0','analog_1','analog_2','extern_1','ads1115_0','ads1115_1'])"/>
33-
<label for='sel1'>Füllstandsmessung mit Ultraschallsensor HCSR04</label>
34-
</div>
35-
36-
<div class='inline'>
37-
<input type='radio' id='sel2' name='selection' value='analog' onclick="radioselection(['all_1','all_2','all_3','analog_0','analog_1','analog_2'],['hcsr04_1','hcsr04_2','hcsr04_3','hcsr04_4','extern_1','ads1115_0','ads1115_1'])"/>
38-
<label for='sel2'>Füllstandsmessung mit Analogsignal am ESP</label>
39-
</div>
40-
41-
<div id="sel_ADS1115" class='inline'>
42-
<input type='radio' id='sel3' name='selection' value='ads1115' onclick="radioselection(['all_1','all_2','all_3','analog_1','analog_2','ads1115_0','ads1115_1'],['hcsr04_1','hcsr04_2','hcsr04_3','hcsr04_4','extern_1','analog_0'])"/>
43-
<label for='sel3'>Füllstandsmessung mit Analogsignal am ADS1115 </label>
44-
</div>
45-
46-
47-
<div class='inline'>
48-
<input type='radio' id='sel4' name='selection' value='extern' onclick="radioselection(['all_2','all_3','extern_1'],['all_1','hcsr04_1','hcsr04_2','hcsr04_3','hcsr04_4','analog_0','analog_1','analog_2','ads1115_0','ads1115_1'])"/>
49-
<label for='sel4'>Füllstandsmessung mit externem Signal per MQTT</label>
50-
</div>
51-
52-
</td>
53-
</tr>
54-
55-
<tr id='all_1'>
56-
<td>Messintervall</td>
57-
<td>
58-
<input id="measurecycle" min='0' max='254' name='measurecycle' type='number' />
59-
</td>
60-
</tr>
61-
62-
<tr id='hcsr04_1'>
63-
<td>Abstand Sensor min (in cm)</td>
64-
<td>
65-
<input id="measureDistMin" min='0' max='254' name='measureDistMin' type='number'/>
66-
</td>
67-
</tr>
68-
69-
<tr id='hcsr04_2'>
70-
<td>Abstand Sensor max (in cm)</td>
71-
<td>
72-
<input min='0' max='254' name='measureDistMax' type='number'/>
73-
</td>
74-
</tr>
75-
76-
<tr id='hcsr04_3'>
77-
<td>Pin HC-SR04 Trigger</td>
78-
<td>
79-
<input min='0' max='15' id='GpioPin_1' name='pinhcsr04trigger' type='number'/>
80-
</td>
81-
</tr>
82-
83-
<tr id='hcsr04_4'>
84-
<td>Pin HC-SR04 Echo</td>
85-
<td>
86-
<input min='0' max='15' id='GpioPin_2' name='pinhcsr04echo' type='number' />
87-
</td>
88-
</tr>
89-
90-
<tr id='analog_0'>
91-
<td>GPIO an welchem das Signal anliegt</td>
92-
<td>
93-
<input min='0' size='15' id='AnalogPin_1' name='pinanalog' type='number' />
94-
</td>
95-
</tr>
96-
97-
<tr id='ads1115_0'>
98-
<td>i2c Adresse des ADS1115</td>
99-
<td>
100-
<input id="ads1115_i2c" maxlength='2' name='ads1115_i2c' type='text'/>
101-
</td>
102-
</tr>
103-
104-
<tr id='ads1115_1'>
105-
<td>Portnummer am ADS1115 bei dem das Signal anliegt</td>
106-
<td>
107-
<input id="ads1115_port" min='0' max='4' size='15' name='ads1115_port' type='number'/>
108-
</td>
109-
</tr>
110-
111-
<tr id='analog_1'>
112-
<td>Kalibrierung: 0% entspricht RAW Wert</td>
113-
<td>
114-
<input id="a_measureDistMin" min='0' size='5' name='measureDistMin' type='number'/>
115-
</td>
116-
</tr>
117-
118-
<tr id='analog_2'>
119-
<td>Kalibrierung: 100% entspricht RAW Wert</td>
120-
<td>
121-
<input id="a_measureDistMax" min='0' name='measureDistMax' type='number'/>
122-
</td>
123-
</tr>
124-
125-
<tr id='extern_1'>
126-
<td>MQTT-Topic des externen Sensors (Füllstand in %)</td>
127-
<td>
128-
<input id="externalSensor" size='30' name='externalSensor' type='text'/>
129-
</td>
130-
</tr>
131-
132-
<tr id='all_2'>
133-
<td >Sensor Treshold Min für 3WegeVentil</td>
134-
<td>
135-
<input id="treshold_min" min='0' max='254' name='treshold_min' type='number'/>
136-
</td>
137-
</tr>
138-
139-
<tr id='all_3'>
140-
<td>Sensor Treshold Max für 3WegeVentil</td>
141-
<td>
142-
<input id="treshold_max" min='0' max='254' name='treshold_max' type='number'/>
143-
</td>
144-
<tr>
145-
146-
</tbody>
147-
</table>
16+
<table id='maintable' class='editorDemoTable'>
17+
<thead>
18+
<tr>
19+
<td style='width: 250px;'>Name</td>
20+
<td style='width: 200px;'>Wert</td>
21+
</tr>
22+
</thead>
23+
<tbody>
24+
25+
<tr>
26+
<td colspan='2'>
27+
<div class='inline'>
28+
<input type='radio' id='sel0' name='selection' value='none' onclick="radioselection([],['all_1','all_2','all_3','analog_0','analog_1','analog_2','hcsr04_1','hcsr04_2','hcsr04_3','hcsr04_4','extern_1','ads1115_0','ads1115_1'])"/>
29+
<label for='sel0'>keine Füllstandsmessung</label>
30+
</div>
31+
32+
<div class='inline'>
33+
<input type='radio' id='sel1' name='selection' value='hcsr04' onclick="radioselection(['all_1','all_2','all_3','hcsr04_1','hcsr04_2','hcsr04_3','hcsr04_4'],['analog_0','analog_1','analog_2','extern_1','ads1115_0','ads1115_1'])"/>
34+
<label for='sel1'>Füllstandsmessung mit Ultraschallsensor HCSR04</label>
35+
</div>
36+
37+
<div class='inline'>
38+
<input type='radio' id='sel2' name='selection' value='analog' onclick="radioselection(['all_1','all_2','all_3','analog_0','analog_1','analog_2'],['hcsr04_1','hcsr04_2','hcsr04_3','hcsr04_4','extern_1','ads1115_0','ads1115_1'])"/>
39+
<label for='sel2'>Füllstandsmessung mit Analogsignal am ESP</label>
40+
</div>
41+
42+
<div id="sel_ADS1115" class='inline'>
43+
<input type='radio' id='sel3' name='selection' value='ads1115' onclick="radioselection(['all_1','all_2','all_3','analog_1','analog_2','ads1115_0','ads1115_1'],['hcsr04_1','hcsr04_2','hcsr04_3','hcsr04_4','extern_1','analog_0'])"/>
44+
<label for='sel3'>Füllstandsmessung mit Analogsignal am ADS1115 </label>
45+
</div>
46+
47+
48+
<div class='inline'>
49+
<input type='radio' id='sel4' name='selection' value='extern' onclick="radioselection(['all_2','all_3','extern_1'],['all_1','hcsr04_1','hcsr04_2','hcsr04_3','hcsr04_4','analog_0','analog_1','analog_2','ads1115_0','ads1115_1'])"/>
50+
<label for='sel4'>Füllstandsmessung mit externem Signal per MQTT</label>
51+
</div>
52+
53+
</td>
54+
</tr>
55+
56+
<tr id='all_1'>
57+
<td>Messintervall</td>
58+
<td>
59+
<input id="measurecycle" min='0' max='254' name='measurecycle' type='number' />
60+
</td>
61+
</tr>
62+
63+
<tr id='hcsr04_1'>
64+
<td>Abstand Sensor min (in cm)</td>
65+
<td>
66+
<input id="measureDistMin" min='0' max='254' name='measureDistMin' type='number'/>
67+
</td>
68+
</tr>
69+
70+
<tr id='hcsr04_2'>
71+
<td>Abstand Sensor max (in cm)</td>
72+
<td>
73+
<input min='0' max='254' name='measureDistMax' type='number'/>
74+
</td>
75+
</tr>
76+
77+
<tr id='hcsr04_3'>
78+
<td>Pin HC-SR04 Trigger</td>
79+
<td>
80+
<input min='0' max='15' id='GpioPin_1' name='pinhcsr04trigger' type='number'/>
81+
</td>
82+
</tr>
83+
84+
<tr id='hcsr04_4'>
85+
<td>Pin HC-SR04 Echo</td>
86+
<td>
87+
<input min='0' max='15' id='GpioPin_2' name='pinhcsr04echo' type='number' />
88+
</td>
89+
</tr>
90+
91+
<tr id='analog_0'>
92+
<td>GPIO an welchem das Signal anliegt</td>
93+
<td>
94+
<input min='0' size='15' id='AnalogPin_1' name='pinanalog' type='number' />
95+
</td>
96+
</tr>
97+
98+
<tr id='ads1115_0'>
99+
<td>i2c Adresse des ADS1115</td>
100+
<td>
101+
<input id="ads1115_i2c" maxlength='2' name='ads1115_i2c' type='text'/>
102+
</td>
103+
</tr>
104+
105+
<tr id='ads1115_1'>
106+
<td>Portnummer am ADS1115 bei dem das Signal anliegt</td>
107+
<td>
108+
<input id="ads1115_port" min='0' max='4' size='15' name='ads1115_port' type='number'/>
109+
</td>
110+
</tr>
111+
112+
<tr id='analog_1'>
113+
<td>Kalibrierung: 0% entspricht RAW Wert</td>
114+
<td>
115+
<input id="a_measureDistMin" min='0' size='5' name='measureDistMin' type='number'/>
116+
</td>
117+
</tr>
118+
119+
<tr id='analog_2'>
120+
<td>Kalibrierung: 100% entspricht RAW Wert</td>
121+
<td>
122+
<input id="a_measureDistMax" min='0' name='measureDistMax' type='number'/>
123+
</td>
124+
</tr>
125+
126+
<tr id='extern_1'>
127+
<td>MQTT-Topic des externen Sensors (Füllstand in %)</td>
128+
<td>
129+
<input id="externalSensor" size='30' name='externalSensor' type='text'/>
130+
</td>
131+
</tr>
132+
133+
<tr id='all_2'>
134+
<td >Sensor Treshold Min für 3WegeVentil</td>
135+
<td>
136+
<input id="treshold_min" min='0' max='254' name='treshold_min' type='number'/>
137+
</td>
138+
</tr>
139+
140+
<tr id='all_3'>
141+
<td>Sensor Treshold Max für 3WegeVentil</td>
142+
<td>
143+
<input id="treshold_max" min='0' max='254' name='treshold_max' type='number'/>
144+
</td>
145+
</tr>
146+
</tbody>
147+
</table>
148+
149+
<p/>
150+
151+
<table id="moistureTable" class='editorDemoTable'>
152+
<thead>
153+
<tr>
154+
<td style='width: 130px;'>
155+
<input type='radio' id='sel_moisture1' name='sel_moisture' value='off' %s onclick="radioselection([],['moisture'])"/>
156+
<label for='sel_moisture1'>Off</label>
157+
<input type='radio' id='sel_moisture2' name='sel_moisture' value='on' %s onclick="radioselection(['moisture'],[])"/>
158+
<label for='sel_moisture2'>On</label>
159+
</td>
160+
<td style='width: 600px;'>Bodenfeuchtesensoren am ADS1115</td>
161+
</tr>
162+
</thead>
163+
<tbody>
164+
<tr id='moisture'>
165+
<td valign=top class="noborder">
166+
<input type='button' value='&#10010; add new Port' onclick='addrow("moistureRows")'>
167+
</td>
168+
<td class="noborder">
169+
<table id='moistureRows' class='editorDemoTable'>
170+
<thead>
171+
<tr>
172+
<td style='width: 25px;'>Nr</td>
173+
<td style='width: 250px;'>MQTT Topic</td>
174+
<td style='width: 100px;'>I2c Addr</td>
175+
<td style='width: 100px;'>Port</td>
176+
<td style='width: 25px;'>Delete</td>
177+
</tr>
178+
</thead>
179+
<tbody>
180+
<template id="rows">
181+
<tr>
182+
<td></td>
183+
<td><input id='mqtttopic' name='mqtttopic' type='text' size='30' placeholder='topic'/></td>
184+
<td><input id="ads_addr" maxlength='2' name='ads_addr' type='text'/></td>
185+
<td><input id='ads_port' name='ads_port' type='number' min='0' max='4'/></td>
186+
<td><input type='button' value='&#10008;' onclick='delrow(this)'></td>
187+
</tr>
188+
</template>
189+
</tbody>
190+
</table>
191+
</td>
192+
</tr>
193+
</tbody>
194+
</table>
148195
</form>
149196

150197
<br/>
151-
<input type='submit' onclick="onSubmit('DataForm', '.*')" value='Speichern' />
198+
<input type='submit' onclick="onSubmit('DataForm', 'mqtttopic.*')" value='Speichern' />
152199
<span id='response'></span>
153200
</body>
154201
</html>

data/web/sensorconfig.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ function GetInitData() {
1616
function MyCallback() {
1717
CreateSelectionListFromInputField('input[type=number][id^=GpioPin]', [gpio]);
1818
CreateSelectionListFromInputField('input[type=number][id^=AnalogPin]', [gpioanalog]);
19+
validate_identifiers("moistureRows");
1920
}
2021

2122
// ************************************************

0 commit comments

Comments
 (0)