ents 2.3.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ents-2.3.2/.gitignore +160 -0
- ents-2.3.2/LICENSE +21 -0
- ents-2.3.2/PKG-INFO +206 -0
- ents-2.3.2/README.md +180 -0
- ents-2.3.2/pyproject.toml +55 -0
- ents-2.3.2/src/ents/__init__.py +23 -0
- ents-2.3.2/src/ents/calibrate/PingSMU.py +51 -0
- ents-2.3.2/src/ents/calibrate/PingSPS.py +66 -0
- ents-2.3.2/src/ents/calibrate/README.md +3 -0
- ents-2.3.2/src/ents/calibrate/__init__.py +0 -0
- ents-2.3.2/src/ents/calibrate/linear_regression.py +78 -0
- ents-2.3.2/src/ents/calibrate/plots.py +83 -0
- ents-2.3.2/src/ents/calibrate/recorder.py +678 -0
- ents-2.3.2/src/ents/calibrate/requirements.txt +9 -0
- ents-2.3.2/src/ents/cli.py +546 -0
- ents-2.3.2/src/ents/config/README.md +123 -0
- ents-2.3.2/src/ents/config/__init__.py +1 -0
- ents-2.3.2/src/ents/config/adv_trace.py +56 -0
- ents-2.3.2/src/ents/config/user_config.py +935 -0
- ents-2.3.2/src/ents/proto/__init__.py +33 -0
- ents-2.3.2/src/ents/proto/decode.py +106 -0
- ents-2.3.2/src/ents/proto/encode.py +298 -0
- ents-2.3.2/src/ents/proto/esp32.py +179 -0
- ents-2.3.2/src/ents/proto/soil_power_sensor_pb2.py +72 -0
- ents-2.3.2/src/ents/simulator/__init__.py +0 -0
- ents-2.3.2/src/ents/simulator/node.py +161 -0
- ents-2.3.2/tests/__init__.py +0 -0
- ents-2.3.2/tests/test_generic.py +373 -0
- ents-2.3.2/tests/test_simulator.py +100 -0
ents-2.3.2/.gitignore
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# poetry
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
102
|
+
#poetry.lock
|
|
103
|
+
|
|
104
|
+
# pdm
|
|
105
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
106
|
+
#pdm.lock
|
|
107
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
108
|
+
# in version control.
|
|
109
|
+
# https://pdm.fming.dev/#use-with-ide
|
|
110
|
+
.pdm.toml
|
|
111
|
+
|
|
112
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
113
|
+
__pypackages__/
|
|
114
|
+
|
|
115
|
+
# Celery stuff
|
|
116
|
+
celerybeat-schedule
|
|
117
|
+
celerybeat.pid
|
|
118
|
+
|
|
119
|
+
# SageMath parsed files
|
|
120
|
+
*.sage.py
|
|
121
|
+
|
|
122
|
+
# Environments
|
|
123
|
+
.env
|
|
124
|
+
.venv
|
|
125
|
+
env/
|
|
126
|
+
venv/
|
|
127
|
+
ENV/
|
|
128
|
+
env.bak/
|
|
129
|
+
venv.bak/
|
|
130
|
+
|
|
131
|
+
# Spyder project settings
|
|
132
|
+
.spyderproject
|
|
133
|
+
.spyproject
|
|
134
|
+
|
|
135
|
+
# Rope project settings
|
|
136
|
+
.ropeproject
|
|
137
|
+
|
|
138
|
+
# mkdocs documentation
|
|
139
|
+
/site
|
|
140
|
+
|
|
141
|
+
# mypy
|
|
142
|
+
.mypy_cache/
|
|
143
|
+
.dmypy.json
|
|
144
|
+
dmypy.json
|
|
145
|
+
|
|
146
|
+
# Pyre type checker
|
|
147
|
+
.pyre/
|
|
148
|
+
|
|
149
|
+
# pytype static type analyzer
|
|
150
|
+
.pytype/
|
|
151
|
+
|
|
152
|
+
# Cython debug symbols
|
|
153
|
+
cython_debug/
|
|
154
|
+
|
|
155
|
+
# PyCharm
|
|
156
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
157
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
158
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
159
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
160
|
+
#.idea/
|
ents-2.3.2/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 jLab in Smart Sensing at UCSC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
ents-2.3.2/PKG-INFO
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ents
|
|
3
|
+
Version: 2.3.2
|
|
4
|
+
Summary: Python package for Environmental NeTworked Sensor (ENTS)
|
|
5
|
+
Project-URL: Homepage, https://github.com/jlab-sensing/soil-power-sensor-firmware
|
|
6
|
+
Project-URL: Issues, https://github.com/jlab-sensing/soil-power-sensor-firmware/issues
|
|
7
|
+
Author-email: John Madden <jmadden173@pm.me>
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Requires-Python: >=3.11
|
|
13
|
+
Requires-Dist: matplotlib
|
|
14
|
+
Requires-Dist: pandas
|
|
15
|
+
Requires-Dist: protobuf>5.0.0
|
|
16
|
+
Requires-Dist: pyserial
|
|
17
|
+
Requires-Dist: requests
|
|
18
|
+
Requires-Dist: scikit-learn
|
|
19
|
+
Requires-Dist: tqdm
|
|
20
|
+
Provides-Extra: dev
|
|
21
|
+
Requires-Dist: black; extra == 'dev'
|
|
22
|
+
Requires-Dist: ruff; extra == 'dev'
|
|
23
|
+
Provides-Extra: gui
|
|
24
|
+
Requires-Dist: pyqt5; extra == 'gui'
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
# Soil Power Sensor Python Protobuf Bindings
|
|
28
|
+
|
|
29
|
+
The soil power sensor protobuf protocol is implemented as a Python package that allows for `Measurement` messages to be decoded into a dictionary and `Response` messages to be encoded. The generated files from protobuf are also accessible for more complex use cases.
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
Use the following to install the `ents` package with gui via `pip`:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install ents[gui]
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
You can also install the package from source with the following:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# install package
|
|
44
|
+
pip install .[gui]
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
If you are planning to develop the package we recommend you install the package
|
|
48
|
+
in editable mode with development dependencies. This allows you to make changes
|
|
49
|
+
to the source code and have them reflected in the package without needing to
|
|
50
|
+
reinstall it.
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# install development dependencies
|
|
54
|
+
pip install -e .[gui,dev]
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Usage
|
|
58
|
+
|
|
59
|
+
The following example code demonstrates decoding the measurement message and encoding a response.
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
from ents import encode, decode
|
|
63
|
+
|
|
64
|
+
# get data encoded by the soil power sensor
|
|
65
|
+
data = ...
|
|
66
|
+
|
|
67
|
+
meas_dict = decode(data)
|
|
68
|
+
|
|
69
|
+
# process data
|
|
70
|
+
...
|
|
71
|
+
|
|
72
|
+
# send response
|
|
73
|
+
resp_str = encode(success=True)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The formatting of the dictionary depends on the type of measurement sent. The key `type` is included on all measurement types and can be used to determine the type of message. See the source `*.proto` files to get the full list of types to get the full list of types and keys. A list is provided in [Message Types](#message-types). The Python protobuf API uses camel case when naming keys. The key `ts` is in ISO 8601 format as a string.
|
|
77
|
+
|
|
78
|
+
## Message Types
|
|
79
|
+
|
|
80
|
+
Type `power`
|
|
81
|
+
```python
|
|
82
|
+
meas_dict = {
|
|
83
|
+
"type": "power",
|
|
84
|
+
"loggerId": ...,
|
|
85
|
+
"cellId": ...,
|
|
86
|
+
"ts": ...,
|
|
87
|
+
"data": {
|
|
88
|
+
"voltage": ...,
|
|
89
|
+
"current": ...
|
|
90
|
+
},
|
|
91
|
+
"data_type": {
|
|
92
|
+
"voltage": float,
|
|
93
|
+
"voltage": float
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Type `teros12`
|
|
99
|
+
```python
|
|
100
|
+
meas_dict = {
|
|
101
|
+
"type": "teros12",
|
|
102
|
+
"loggerId": ...,
|
|
103
|
+
"cellId": ...,
|
|
104
|
+
"ts": ...,
|
|
105
|
+
"data": {
|
|
106
|
+
"vwcRaw": ...,
|
|
107
|
+
"vwcAdj": ...,
|
|
108
|
+
"temp": ...,
|
|
109
|
+
"ec": ...
|
|
110
|
+
},
|
|
111
|
+
"data_type": {
|
|
112
|
+
"vwcRaw": float,
|
|
113
|
+
"vwcAdj": float,
|
|
114
|
+
"temp": float,
|
|
115
|
+
"ec": int
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Type `bme280` with `raw=True` (default)
|
|
121
|
+
```python
|
|
122
|
+
meas_dict = {
|
|
123
|
+
"type": "bme280",
|
|
124
|
+
"loggerId": ...,
|
|
125
|
+
"cellId": ...,
|
|
126
|
+
"ts": ...,
|
|
127
|
+
"data": {
|
|
128
|
+
"pressure": ...,
|
|
129
|
+
"temperature": ...,
|
|
130
|
+
"humidity": ...,
|
|
131
|
+
},
|
|
132
|
+
"data_type": {
|
|
133
|
+
"pressure": int,
|
|
134
|
+
"temperature": int,
|
|
135
|
+
"humidity": int,
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Type `bme280` with `raw=False`
|
|
141
|
+
```python
|
|
142
|
+
meas_dict = {
|
|
143
|
+
"type": "bme280",
|
|
144
|
+
"loggerId": ...,
|
|
145
|
+
"cellId": ...,
|
|
146
|
+
"ts": ...,
|
|
147
|
+
"data": {
|
|
148
|
+
"pressure": ...,
|
|
149
|
+
"temperature": ...,
|
|
150
|
+
"humidity": ...,
|
|
151
|
+
},
|
|
152
|
+
"data_type": {
|
|
153
|
+
"pressure": float,
|
|
154
|
+
"temperature": float,
|
|
155
|
+
"humidity": float,
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
## Simulator
|
|
162
|
+
|
|
163
|
+
Simulate WiFi sensor uploads without requiring ENTS hardware.
|
|
164
|
+
|
|
165
|
+
### Examples
|
|
166
|
+
|
|
167
|
+
The examples below can be tested standalone (without ents-backend), by running the http server in `tools/http_server.py` to see the request format.
|
|
168
|
+
|
|
169
|
+
#### Upload a days worth of power measurements on a 60 second interval
|
|
170
|
+
|
|
171
|
+
```shell
|
|
172
|
+
ents sim --url http://localhost:3000/api/sensor/ --mode batch --sensor power --cell 200 --logger 200 --start 2025-05-01 --end 2025-05-02 --freq 60
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
```
|
|
176
|
+
...
|
|
177
|
+
total: 1437, failed: 0, avg (ms): 0.10716012526096033, last (ms): 0.0896
|
|
178
|
+
total: 1438, failed: 0, avg (ms): 0.10714290681502087, last (ms): 0.0824
|
|
179
|
+
total: 1439, failed: 0, avg (ms): 0.10712599027102154, last (ms): 0.0828
|
|
180
|
+
total: 1440, failed: 0, avg (ms): 0.10710909722222223, last (ms): 0.0828
|
|
181
|
+
total: 1441, failed: 0, avg (ms): 0.10709035392088828, last (ms): 0.08009999999999999
|
|
182
|
+
Done!
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
#### Upload measurements every 10 seconds
|
|
186
|
+
|
|
187
|
+
```shell
|
|
188
|
+
ents sim --url http://localhost:3000/api/sensor/ --mode stream --sensor power --cell 200 --logger 200 --freq 10
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
```
|
|
192
|
+
Use CTRL+C to stop the simulation
|
|
193
|
+
total: 1, failed: 1, avg (ms): 23.386100000000003, last (ms): 23.386100000000003
|
|
194
|
+
total: 2, failed: 2, avg (ms): 13.668950000000002, last (ms): 3.9517999999999995
|
|
195
|
+
total: 3, failed: 3, avg (ms): 10.795566666666668, last (ms): 5.0488
|
|
196
|
+
total: 4, failed: 4, avg (ms): 8.97235, last (ms): 3.5027000000000004
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## Testing
|
|
200
|
+
|
|
201
|
+
To run the package tests, create a virtual environment, install as an editable package (if you haven't done so already), and run `unittest`.
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
cd python/
|
|
205
|
+
python -m unittest
|
|
206
|
+
```
|
ents-2.3.2/README.md
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
# Soil Power Sensor Python Protobuf Bindings
|
|
2
|
+
|
|
3
|
+
The soil power sensor protobuf protocol is implemented as a Python package that allows for `Measurement` messages to be decoded into a dictionary and `Response` messages to be encoded. The generated files from protobuf are also accessible for more complex use cases.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
Use the following to install the `ents` package with gui via `pip`:
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pip install ents[gui]
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
You can also install the package from source with the following:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# install package
|
|
18
|
+
pip install .[gui]
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
If you are planning to develop the package we recommend you install the package
|
|
22
|
+
in editable mode with development dependencies. This allows you to make changes
|
|
23
|
+
to the source code and have them reflected in the package without needing to
|
|
24
|
+
reinstall it.
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# install development dependencies
|
|
28
|
+
pip install -e .[gui,dev]
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
The following example code demonstrates decoding the measurement message and encoding a response.
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from ents import encode, decode
|
|
37
|
+
|
|
38
|
+
# get data encoded by the soil power sensor
|
|
39
|
+
data = ...
|
|
40
|
+
|
|
41
|
+
meas_dict = decode(data)
|
|
42
|
+
|
|
43
|
+
# process data
|
|
44
|
+
...
|
|
45
|
+
|
|
46
|
+
# send response
|
|
47
|
+
resp_str = encode(success=True)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The formatting of the dictionary depends on the type of measurement sent. The key `type` is included on all measurement types and can be used to determine the type of message. See the source `*.proto` files to get the full list of types to get the full list of types and keys. A list is provided in [Message Types](#message-types). The Python protobuf API uses camel case when naming keys. The key `ts` is in ISO 8601 format as a string.
|
|
51
|
+
|
|
52
|
+
## Message Types
|
|
53
|
+
|
|
54
|
+
Type `power`
|
|
55
|
+
```python
|
|
56
|
+
meas_dict = {
|
|
57
|
+
"type": "power",
|
|
58
|
+
"loggerId": ...,
|
|
59
|
+
"cellId": ...,
|
|
60
|
+
"ts": ...,
|
|
61
|
+
"data": {
|
|
62
|
+
"voltage": ...,
|
|
63
|
+
"current": ...
|
|
64
|
+
},
|
|
65
|
+
"data_type": {
|
|
66
|
+
"voltage": float,
|
|
67
|
+
"voltage": float
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Type `teros12`
|
|
73
|
+
```python
|
|
74
|
+
meas_dict = {
|
|
75
|
+
"type": "teros12",
|
|
76
|
+
"loggerId": ...,
|
|
77
|
+
"cellId": ...,
|
|
78
|
+
"ts": ...,
|
|
79
|
+
"data": {
|
|
80
|
+
"vwcRaw": ...,
|
|
81
|
+
"vwcAdj": ...,
|
|
82
|
+
"temp": ...,
|
|
83
|
+
"ec": ...
|
|
84
|
+
},
|
|
85
|
+
"data_type": {
|
|
86
|
+
"vwcRaw": float,
|
|
87
|
+
"vwcAdj": float,
|
|
88
|
+
"temp": float,
|
|
89
|
+
"ec": int
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Type `bme280` with `raw=True` (default)
|
|
95
|
+
```python
|
|
96
|
+
meas_dict = {
|
|
97
|
+
"type": "bme280",
|
|
98
|
+
"loggerId": ...,
|
|
99
|
+
"cellId": ...,
|
|
100
|
+
"ts": ...,
|
|
101
|
+
"data": {
|
|
102
|
+
"pressure": ...,
|
|
103
|
+
"temperature": ...,
|
|
104
|
+
"humidity": ...,
|
|
105
|
+
},
|
|
106
|
+
"data_type": {
|
|
107
|
+
"pressure": int,
|
|
108
|
+
"temperature": int,
|
|
109
|
+
"humidity": int,
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Type `bme280` with `raw=False`
|
|
115
|
+
```python
|
|
116
|
+
meas_dict = {
|
|
117
|
+
"type": "bme280",
|
|
118
|
+
"loggerId": ...,
|
|
119
|
+
"cellId": ...,
|
|
120
|
+
"ts": ...,
|
|
121
|
+
"data": {
|
|
122
|
+
"pressure": ...,
|
|
123
|
+
"temperature": ...,
|
|
124
|
+
"humidity": ...,
|
|
125
|
+
},
|
|
126
|
+
"data_type": {
|
|
127
|
+
"pressure": float,
|
|
128
|
+
"temperature": float,
|
|
129
|
+
"humidity": float,
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
## Simulator
|
|
136
|
+
|
|
137
|
+
Simulate WiFi sensor uploads without requiring ENTS hardware.
|
|
138
|
+
|
|
139
|
+
### Examples
|
|
140
|
+
|
|
141
|
+
The examples below can be tested standalone (without ents-backend), by running the http server in `tools/http_server.py` to see the request format.
|
|
142
|
+
|
|
143
|
+
#### Upload a days worth of power measurements on a 60 second interval
|
|
144
|
+
|
|
145
|
+
```shell
|
|
146
|
+
ents sim --url http://localhost:3000/api/sensor/ --mode batch --sensor power --cell 200 --logger 200 --start 2025-05-01 --end 2025-05-02 --freq 60
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
```
|
|
150
|
+
...
|
|
151
|
+
total: 1437, failed: 0, avg (ms): 0.10716012526096033, last (ms): 0.0896
|
|
152
|
+
total: 1438, failed: 0, avg (ms): 0.10714290681502087, last (ms): 0.0824
|
|
153
|
+
total: 1439, failed: 0, avg (ms): 0.10712599027102154, last (ms): 0.0828
|
|
154
|
+
total: 1440, failed: 0, avg (ms): 0.10710909722222223, last (ms): 0.0828
|
|
155
|
+
total: 1441, failed: 0, avg (ms): 0.10709035392088828, last (ms): 0.08009999999999999
|
|
156
|
+
Done!
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
#### Upload measurements every 10 seconds
|
|
160
|
+
|
|
161
|
+
```shell
|
|
162
|
+
ents sim --url http://localhost:3000/api/sensor/ --mode stream --sensor power --cell 200 --logger 200 --freq 10
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
```
|
|
166
|
+
Use CTRL+C to stop the simulation
|
|
167
|
+
total: 1, failed: 1, avg (ms): 23.386100000000003, last (ms): 23.386100000000003
|
|
168
|
+
total: 2, failed: 2, avg (ms): 13.668950000000002, last (ms): 3.9517999999999995
|
|
169
|
+
total: 3, failed: 3, avg (ms): 10.795566666666668, last (ms): 5.0488
|
|
170
|
+
total: 4, failed: 4, avg (ms): 8.97235, last (ms): 3.5027000000000004
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Testing
|
|
174
|
+
|
|
175
|
+
To run the package tests, create a virtual environment, install as an editable package (if you haven't done so already), and run `unittest`.
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
cd python/
|
|
179
|
+
python -m unittest
|
|
180
|
+
```
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "ents"
|
|
7
|
+
version = "2.3.2"
|
|
8
|
+
authors = [
|
|
9
|
+
{ name="John Madden", email="jmadden173@pm.me" },
|
|
10
|
+
]
|
|
11
|
+
description = "Python package for Environmental NeTworked Sensor (ENTS)"
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
requires-python = ">=3.11"
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
]
|
|
19
|
+
dependencies = [
|
|
20
|
+
'protobuf>5.0.0',
|
|
21
|
+
'matplotlib',
|
|
22
|
+
'pandas',
|
|
23
|
+
'pyserial',
|
|
24
|
+
'scikit-learn',
|
|
25
|
+
'tqdm',
|
|
26
|
+
'requests',
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[project.optional-dependencies]
|
|
30
|
+
gui = [
|
|
31
|
+
'PyQt5',
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
dev = [
|
|
35
|
+
"black",
|
|
36
|
+
"ruff",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
[project.scripts]
|
|
40
|
+
ents = "ents.cli:entry"
|
|
41
|
+
|
|
42
|
+
[project.gui-scripts]
|
|
43
|
+
ents-gui = "ents.config.user_config:main"
|
|
44
|
+
|
|
45
|
+
[project.urls]
|
|
46
|
+
Homepage = "https://github.com/jlab-sensing/soil-power-sensor-firmware"
|
|
47
|
+
Issues = "https://github.com/jlab-sensing/soil-power-sensor-firmware/issues"
|
|
48
|
+
|
|
49
|
+
[tool.ruff]
|
|
50
|
+
exclude = [
|
|
51
|
+
"src/ents/proto/soil_power_sensor_pb2.py",
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
[tool.black]
|
|
55
|
+
exclude = ".*_pb2.py"
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from .proto.encode import (
|
|
2
|
+
encode_response,
|
|
3
|
+
encode_power_measurement,
|
|
4
|
+
encode_teros12_measurement,
|
|
5
|
+
encode_phytos31_measurement,
|
|
6
|
+
encode_bme280_measurement,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
from .proto.decode import decode_response, decode_measurement
|
|
10
|
+
|
|
11
|
+
from .proto.esp32 import encode_esp32command, decode_esp32command
|
|
12
|
+
|
|
13
|
+
__all__ = [
|
|
14
|
+
"encode_response",
|
|
15
|
+
"encode_power_measurement",
|
|
16
|
+
"encode_teros12_measurement",
|
|
17
|
+
"encode_phytos31_measurement",
|
|
18
|
+
"encode_bme280_measurement",
|
|
19
|
+
"decode_response",
|
|
20
|
+
"decode_measurement",
|
|
21
|
+
"encode_esp32command",
|
|
22
|
+
"decode_esp32command",
|
|
23
|
+
]
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""To test connection via socket to Kiethley 2450
|
|
2
|
+
|
|
3
|
+
Stephen Taylor, 5/20/2024
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import socket
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def ping_smu(host, port):
|
|
10
|
+
try:
|
|
11
|
+
# Create a TCP/IP socket
|
|
12
|
+
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
13
|
+
|
|
14
|
+
# Set a timeout for the connection attempt
|
|
15
|
+
sock.settimeout(1)
|
|
16
|
+
|
|
17
|
+
# Connect to the SMU
|
|
18
|
+
sock.connect((host, port))
|
|
19
|
+
|
|
20
|
+
# Send the *IDN? command
|
|
21
|
+
sock.sendall(b"*RST\n")
|
|
22
|
+
sock.sendall(b"*IDN?\n")
|
|
23
|
+
|
|
24
|
+
# Receive the response
|
|
25
|
+
response = sock.recv(1024)
|
|
26
|
+
response = response.strip()
|
|
27
|
+
print("Response from SMU:", response)
|
|
28
|
+
|
|
29
|
+
# Close the socket
|
|
30
|
+
sock.close()
|
|
31
|
+
|
|
32
|
+
# Return True if connection successful
|
|
33
|
+
return True
|
|
34
|
+
except Exception as e:
|
|
35
|
+
# Connection failed
|
|
36
|
+
print(f"Error: {e}")
|
|
37
|
+
return False
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
if __name__ == "__main__":
|
|
41
|
+
# Specify the IP address or hostname of the SMU and its port
|
|
42
|
+
smu_host = (
|
|
43
|
+
"128.114.204.56" # Replace with the actual IP address or hostname of the SMU
|
|
44
|
+
)
|
|
45
|
+
smu_port = 23 # Replace with the actual port used by the SMU
|
|
46
|
+
|
|
47
|
+
# Ping the SMU
|
|
48
|
+
if ping_smu(smu_host, smu_port):
|
|
49
|
+
print("SMU is reachable.")
|
|
50
|
+
else:
|
|
51
|
+
print("Failed to ping SMU.")
|