Simple Python SDI-12 logging scrip
December 4, 2018 5 Comments
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.
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!!
English:
Hello! My SDI-12 USB adapter has been tested to work with that sensor. I have python code for it. I think python is easier to use and you can run it on raspberry pi. Here is a link to my store: http://www.inmojo.com/store/liudr-arduino-and-physics-gadgets/item/sdi-12-usb-adapter/
SDI-12 USB for 44.95 USD. I can ship internationally but it will take time to deliver. Thank you!
Spanish from google translate:
¡Hola! Mi adaptador USB SDI-12 ha sido probado para funcionar con ese sensor. Tengo un código de Python para ello. Creo que Python es más fácil de usar y puedes ejecutarlo en Raspberry Pi. Aquí hay un enlace a mi tienda: http://www.inmojo.com/store/liudr-arduino-and-physics-gadgets/item/sdi-12-usb-adapter/
SDI-12 USB por 44.95 USD. Puedo realizar envíos internacionales pero llevará tiempo entregarlos. ¡Gracias!
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
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/
Excellent! Thank you for the info. I’ll give it a go and reply again if questions arise