Skip to content

Data logger to read and store SDI-12 data by interfacing with Dr. Liu's SDI-12 USB Adapter.

License

Notifications You must be signed in to change notification settings

DiscoverCCRI/sdi-12-data-collector

Repository files navigation

sdi-12-data-logger

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.

Screen Shot 2023-08-14 at 3 00 53 PM

Initializing SDI-12 Sensor Addresses Using The USB Adapter:

There are a few important details to keep in mind when initializing sensors using the SDI-12 USB adapter:

  1. 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.
  2. Analog sensors should hold a default sensor address of z.
  3. The script sdi_12_initialization.py has interactive steps to walk through the initialization of the sensors.
  4. 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

Wiring Sensors

A few examples of wiring sensors into the SDI-12 USB adapter are shown below

Digital Wiring Reference With MPS-6:

Screen Shot 2023-08-08 at 7 16 59 PM

Digital Wiring Reference With TEROS-12:

Screen Shot 2023-08-08 at 7 17 12 PM

MPS-6 and TEROS-12 In Adapter:

Screen Shot 2023-08-08 at 7 17 23 PM

Analog Wiring Reference With Thermistor:

Screen Shot 2023-08-08 at 7 18 39 PM

Using the SDI-12 Adapter With Docker:

  • 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!

Using the SDI-12 Adapter With Python:

  • 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!

Using Cron

  • 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
    

Expected Output Format

The output into the log file should look like this:

Screen Shot 2023-08-17 at 3 15 32 PM

The output into the csv file should look like this:

Screen Shot 2023-08-17 at 3 16 36 PM

About

Data logger to read and store SDI-12 data by interfacing with Dr. Liu's SDI-12 USB Adapter.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published