Simple Python SDI-12 logging scrip

In case you wish to integrate the SDI-12 USB adapter into your existing Python script, here I provide a simple script to demonstrate how to get data. You can also use this script as a spring board to establish serial port communication in Python for anything else, such as talking to Arduino.

The goal is to not complicate things with the full-feature data logger script. You’ll see that the actual data logging only needs a few lines of code:

Simple sensor detection and reading (2018-12-03)

This script demonstrates how to integrate SDI-12 sensors into your existing Python data logging system by providing the minimal necessary features. It MUST run with a single sensor on the bus. For full-featured logging script, download the Data Logger script.

I’ll keep this script together with all my other scripts and provide updates to it when necessary. I’m also considering writing simple scripts for other programming languages. Do you wish to use the SDI-12 USB adapter with a programming language other than Python? Leave me a message here.

5 Responses to Simple Python SDI-12 logging scrip

  1. Alex says:

    Hola, gusto saludarte, necesito conectar un sensor de humedad de suelo Enviro Pro, de acuerdo al manual del fabricante el sensor utiliza el protocolo SDI12, me gustaría ver la opción de hacerlo con Python o Arduino, tienes algo de eso?……Gracias!!

  2. Dan says:

    Hello, I’m am hoping to write a script that will allow an Allen Bradley Micro800 PLC to communicate with SDI-12 sensors. The Micro800 has a serial port and support ASCII. I am hoping to avoid purchasing this device (https://www.tekbox.com/product/tbs06-sdi-12-to-rs232-converter/). I understand this may be a “from scratch” code but it may be worth the effort.
    Thanks,
    Dan

    • liudr says:

      You can use my python script “simple sensor detection and reading” as a guide for your own script. I have not worked on PLCs before but I suppose they use programming languages similar to those used on PC. The process is to first write an acquire command such as 1M!, then wait for response, and after that write a data read command such as 1D0!.

      Look under data logger programs:
      https://liudr.wordpress.com/gadget/sdi-12-usb-adapter/

      I think it’s best if you purchased a USB-interfaced sdi-12 adapter from me, then use a PC and a terminal program to connect to it to test out an sdi-12 sensor to get some experience on how the protocol works. Purchase link is below. Select “SDI-12 USB”. Then you can replicate that on your PLC. The PLC probably has +-12V RS232 logic. My adapter has a TTL serial 5V variant that could use a MAX3232 breakout board to talk to the PLC. Here is a link. Select “SDI-12 TTL Serial adapter” option. You could turn a USB module into a 5V TTL module but you have to be willing to do some precision soldering. Otherwise I would have a USB version to test out sensors on a PC and a TTL version to actually connect sensor to PLC.

      http://www.inmojo.com/store/liudr-arduino-and-physics-gadgets/item/sdi-12-usb-adapter/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: