Data logger to read and store SDI-12 data by interfacing with Dr. Liu's SDI-12 USB Adapter.
Official documentation can be found here.
There are a few important details to keep in mind when initializing sensors using the SDI-12 USB adapter:
- Only one digital sensor may be wired into the USB adapter at a time. If more than one digital sensor is wired into the adapter, the sensor intitialization will not work.
- For clarification: You are able to initialize a digital sensor address even if analog sensors are wired into the adapter.
- Analog sensors should hold a default sensor address of z.
- The script sdi_12_initialization.py has interactive steps to walk through the initialization of the sensors.
- Repeat the script as necessary for each sensor, as you can only initialize one at a time!
Note for IoT Team:
- Address for TEROS-12 = a
- Address for MPS-6 = b
A few examples of wiring sensors into the SDI-12 USB adapter are shown below
Digital Wiring Reference With MPS-6:
Digital Wiring Reference With TEROS-12:
MPS-6 and TEROS-12 In Adapter:
Analog Wiring Reference With Thermistor:
-
Install docker:
sudo apt install docker.io
-
Check if docker is functioning:
sudo docker run hello-world
-
Clone repository to get Dockerfile and configuration files:
git clone https://github.com/DiscoverCCRI/sdi-12-data-collector.git
-
Change into directory:
cd sdi-12-data-collector
-
Modify config.yaml to match your implementation:
- Refer to comments for necessary changes
nano config.yaml
-
Modify crontab to match your implementation:
nano crontab
-
OPTIONAL: To change the docker containers time zone, edit line 10 in the Dockerfile. A list of acceptable time zones can be found at https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
-
Build docker image in current directory:
docker build -t sdi12 .
-
Create a directory in a convenient location to store the docker volume. For example:
mkdir -p Data/SDI12Data
-
Create a volume to store data inside the directory created in the previous step:
docker volume create --driver local \ --opt type=none \ --opt device=/SOME/LOCAL/DIRECTORY \ --opt o=bind \ YOUR_VOLUME_NAME
-
Execute docker container:
docker run --privileged -v YOUR_VOLUME_NAME:/Data -t -i -d --restart unless-stopped sdi12
-
Verify container is running:
docker ps
-
Done!
-
Pull this repository to your device:
git clone https://github.com/DiscoverCCRI/sdi-12-data-collector.git
-
Install pyserial:
pip install pyserial
-
Install PyYAML:
pip install PyYAML
-
Change into directory:
cd sdi-12-data-collector
-
Modify config.yaml to match your implementation:
- Refer to comments for necessary changes
nano config.yaml
-
Execute script:
./sdi_12_data_collector.sh
-
Done!
-
Open cron table file:
crontab -e
-
Paste the following lines into the cron table and modify the lines to adjust how often the cron job executes:
# execute sdi_12_data_collector.sh every 10 minutes */10 * * * * /usr/bin/python3 /SOME/PATH/TO/sdi_12_data_collector.sh
-
Save the cron table and verify it was loaded by inspecting running cron jobs:
crontab -l
The output into the log file should look like this:
The output into the csv file should look like this: