Teaser photo

What can this new board do?

2016-11-22-11-08-48

Guesses? Comments? Answer revealed after US Thanksgiving holiday (2016-11-24)!

(There is nothing on the back side)

Read analog sensors on SDI-12 USB + Analog adapter

Reading analog sensors are easy. The adapter has SDI-12 address of ‘z’, lower case. So reading the analog sensor just involves querying the SDI-12 address ‘z’. There are two sensing modes: single-ended, and differential. If you have mixed single-ended and  differential channels, read single-ended, then differential. Discard channels you don’t need. It won’t hurt the sensors or the adapter if you wire them in differential mode but read in single-ended mode. The reverse is also true.

The sensing commands are ‘zM!’ for single-ended readings, and ‘zM1!’ for differential readings.

In both modes, you use ‘zD01!’ zee-Dee-zero-!, to get data. Essentially, the adapter itself is an SDI-12 sensor that reports 2 or 4 values, depending on sensing mode. This makes it very easy to integrate analog sensors into your existing data logger that is based on the original SDI-12 USB adapter. It is still advantageous to keep the original SDI-12 USB adapter so it can split SDI-12 sensors with the SDI-12 + Analog adapter. In case one SDI-12 sensor gets broken and interferes with the rest of the sensors on that adapter, the SDI-12 sensors on the other adapter will be unaffected.

To make this complete, the SDI-12 USB + Analog adapter also responds to the following commands:

Command:’z!’

Response: ‘z\r\n’ This means that the adapter is responding to queries.

Command: ‘z!’

Response: ‘z13Liudr   SDITRD130\r\n’ This indicates that the firmware is in version 1.3.0.

Command: ‘zM!’

Response: ‘z0014\r\nz\r\n’ This means that the adapter needs 1 second to acquire 4 single-ended auto-scale analog values. The second ‘z’ indicates it completed the acquisition.

Command: ‘zM1!’

Response: ‘z0012\r\nz\r\n’ This means that the adapter needs 1 second to acquire 2 differential auto-scale analog values. The second ‘z’ indicates it completed the acquisition.

C0mmand: ‘zD0!’

Response: ‘z+1.23456+2.34567+3.45678+4.56789\r\n’ or ‘z+1.23456+2.34567\r\n’ These are single-ended or differential channel readings, depending on whether M or M1 was issued before D0.

 

Update on the SDI-12 + Analog USB adapter

sdi-12-usb-analog

Here is an update:

In case you wonder what all those green screw terminal blocks are doing, here is a graphical explanation:

Both the SDI-12 USB and SDI-12 + Analog USB are explained in this illustration.

To maintain the same compact size, I printed all the pin information on the bottom of the board again. So if you don’t know what a certain pin on a block does, just flip it around and you’ll see it. The jumper information is all on top side.

The SDI-12 + Analog USB adapter comes with a jumper to select either internal 5V or external voltage at the Ext. Power screw terminal block. You may connect a small 9V battery to the Ext. Power screw terminal block. You can also connect your  12V battery that powers your logger to this pin. The external power is only sent to the SDI-12 sensors. It’s not powering the adapter or sent to the analog inputs’ “+” connections. Those “++ connections are always from the 5V USB power. There are 3 pins on the terminal block and the center pin is not connected to anything. It makes it easier to separate the + and – of the external power and I don’t have to source 2-pole blocks besides 3-pole blocks.

All four SDI-12 blocks have “+ S -“. The “+” is either USB 5V or external power depending on the power jumper. “S” is SDI-12 signal. “-” is ground. All grounds should be connected together. These four blocks are all connected. They are not four separate buses. There is no way to transparently bridge one USB serial port to more than one SDI-12 bus. If you wish separate SDI-12 bus for each sensor, which is unnecessary, get a separate adapter for a separate SDI-12 bus. This need for separate SDI-12 bus may come from some suspicion that if a single SDI-12 sensor breaks, it may take the whole bus down with it. I have not been so unfortunate and broken SDI-12 sensors I have had didn’t affect good ones. In any case, a broken sensor needs replacement. Unless you deploy redundant sensors one set on each SDI-12 bus, you are OK with a single adapter that bridges a single SDI-12 bus for all sensors.

The four analog channels are as accurate as 0.02mV when the signal is small, below 0.256V. The adapter automatically uses the best scale to determine the signal. The highest signal allowed is 6.144V on any channel. There are 6 ranges (gain levels), with maximal ranges of 6.144V, 4.096V, 2.048V, 1.024V, 0.512V and 0.256V. Within each range of voltage, the analog input is turned into a numerical value between 0 and 32767. So if you have a signal that is 0.1V, using the largest range of 6.144V will give an smallest change of 0.1875mV. This sounds very accurate, because this change is 0.1% of the signal. But the real resolution of the ADC is not the smallest change. It is usually many times that. Plus there is fluctuation in supply voltage and noise in the signal. The result is likely in the neighborhood of 2mV. This becomes 2% of the signal magnitude. But if you use the 0.256V range, its smallest change is 0.0078125mV. The accuracy is about 0.02mV to be conservative. Since SDI-12 standard has no way to change scale, the adapter does it automatically.

The auto scale is done with a 10%~90% range. The adapter starts with the largest scale to protect the converter and reads the signal. It then calculates the smallest scale that will fit the signal within 10%-90% of the scale. It reads at this scale and returns the value. Each channel is auto scaled independently from the other channels so you may have some larger signals automatically read at a larger scale and smaller signals automatically read at a smaller scale.

The meaning of single-ended channel is that each one of the four channels is read against the common ground. This is less accurate for small signals over long wires. If you have a pyronometer or some other small voltage signal sensor, you may want to use two channels in differential mode. In this mode, the “+” wire is connected to say channel 0, and the “-” wire is connected to channel 1. The difference between these two are read and the difference may either be positive or negative. Range of the difference between these wires can be +-6.144, … +-0.256Vetc.

(to be continued)

 

SDI-12 USB + Analog prototype

So finally the boards and parts are here and I built the first batch of 3 boards (purple as in oshpark.com). Here is a photo of one of them with my hand as size reference:

2016-11-04-09-27-20

This board is twice the size of the original SDI-12 USB adapter and features the following additional features:

  1. 4 SDI-12 screw terminal blocks. The original adapter can handle multiple SDI-12 sensors if you wire them all together to the single SDI-12 block. On the other hand, I can make this easier by providing more connectors. 4 connections don’t mean limit of SDI-12 sensors to 4. You can wire any number of sensors to the same connection. More connections just mean more convenience when building your logger or swapping sensors in the field.
  2. External power supply block. With the original adapter, SDI-12 sensors are powered by 5V from USB. If it is not enough, you need another power source and some additional wiring. With the new version, just wire external power to this connection and select the SDI-12 power jumper to Ext., less wiring.
  3. Analog channels: Many users asked about using analog sensors that are NOT SDI-12 sensors. That requires additional hardware and distracts you from focusing on making your logger. Enter 4 analog channels! Each channel is capable of 16-bit analog to digital conversion and can have up to 16X gain. The smallest voltage you can read is down to 8 micro volts! You are welcome, pyranometers! You can use them as 4 single-ended channels, for PT1000 or other resistive temperature sensors or as 2 differential channels, best suited for pyranometers.
  4. Resistance sensors: resistance measurements are available on every analog channel. The channels come with select-able high-precision low-temperature-drift pull-up resistors. You can select 1K resistor for PT1000 and anything with low resistance or 10K resistor for 10K thermistors or anything with high resistance. If your sensor generates a voltage, such as pyranometer, you can disconnect the jumper to disable this pull-up resistor. Each channel is separately configurable and auto-scales for best precision.
  5. Analog channels are sensed the SAME way you would sensor an SDI-12 sensor. The address is ‘z’ (lower case). Just in case you wonder, there is also a differential mode to further increase precision of small signals if you pair channels 0 and 1 as a differential channel, or 2 and 3 as another differential channel. Send zM! to the adapter for single-ended measurements. Send zM1! for differential measurements. If you have them mixed, say channels 0-1 is used as differential for a pyranometer and 2, 3 are single-ended for two PT1000 temperature sensors, sense it twice, once as single-ended, discard values from channels 0 and 1. Then sense as differential, discard value from 2-3 differential.
  6. Every key component, such as the analog-to-digital converter IC, the ATMEGA328 processor, the FT232RL USB chip, crystal oscillator, fuse, and precision resistors, comes from reputable vendors such as digikey, mouser, or newark. Every adapter is assembled by myself and tested with an actual SDI-12 sensor (also an analog or resistive sensor). I don’t know how else to ensure excellent quality! There is no guarantee coming with ebay purchases!

I expect this product to be available in a few weeks after I conclude my testing phase. My estimate retail price is $89. I will release data logger code that can log both SDI-12 sensor and the analog channels when this is offered for sale.

SDI-12 eye candy! an SDI-12 + analog input USB adapter

The SDI-12 USB adapter is definitely a success! They are flying off the shelf! I guess people want to log data with PC/raspberry pi just as much as with Arduino (I have an SDI-12 data logging shield for Arduino). So I thought what else I can do to provide even better service to the community of SDI-12 sensor users.So here it is (well, just the design, actual device is not ready for prime time yet):

sdi-12-analog-usb-adapter

Here are the things that I added to make another version of the adapter:

  1. 4 SDI-12 screw terminal blocks. The original adapter can handle multiple SDI-12 sensors if you wire them all together to the single SDI-12 block. On the other hand, I can make this easier by providing more connectors. 4 connections don’t mean limit of SDI-12 sensors to 4. You can wire any number of sensors to the same connection. More connections just mean more convenience when building your logger.
  2. External power supply block. With the original adapter, SDI-12 sensors are powered by 5V from USB. If it is not enough, you need another power source and some additional wiring. With the new version, just wire external power to this connection and select the SDI-12 power jumper to Ext., less wiring.
  3. Analog channels: Many users asked about using analog sensors that are NOT SDI-12 sensors. That requires additional hardware and distracts you from focusing on making your logger. Enter 4 analog channels! Each channel is capable of 16-bit analog to digital conversion and can have up to 16X gain. The smallest voltage you can read is down to 8 micro volts! You are welcome, pyranometers!
  4. Resistance sensors: resistance measurements are available on every analog channel. The channels come with select-able high-precision low-temperature-drift pull-up resistors. You can select 1K resistor for PT1000 and anything with low resistance or 10K resistor for 10K thermistors or anything with high resistance. If your sensor generates a voltage, such as pyranometer, you can disconnect the jumper to disable this pull-up resistor. Each channel is separately configurable and auto-scales for best precision.
  5. Analog channels are sensed the SAME way you would sensor an SDI-12 sensor. The address is ‘z’ (lower case). Just in case you wonder, there is also a differential mode to further increase precision of small signals if you pair channels 0 and 1 as a differential channel, or 2 and 3 as another differential channel. A different command is used for differential channels also at address ‘z’ (lower case).
  6. Every key component, such as the analog-to-digital converter IC, the ATMEGA328 processor, the FT232RL USB chip, crystal oscillator, fuse, and precision resistors, comes from reputable vendors such as digikey, mouser, or newark. Every adapter is assembled by myself and tested with an actual SDI-12 sensor (also an analog or resistive sensor). I don’t know how else to ensure excellent quality! There is no guarantee coming with ebay purchases!

Important! This version will be named SDI-12 + Analog USB adapter and the original adapter will still be offered. The original adapter works great as part of a desktop/lab test device and for data loggers mostly made up of SDI-12 sensors. The new adapter is more expensive due to added capabilities.

Any comments? Suggestions? Please feel free to tell me.

Connect SDI-12 USB adapter to a sensor

If you wonder how to connect your SDI-12 sensor to the SDI-12 USB adapter, here are two videos showing you how to. In the video, I was using a Decagon PRI spectral reflectance sensor. It comes with 3 wire leads. Bare wire is ground. Wire wire is power. Red wire is SDI-12 bus. If you purchased a Decagon sensor with the 1/4″ stereo plug, you can purchase an adapter from them that break out the wires into 3 wire leads.

Decagon sensor wiring

The jeweler’s screw driver that I used was 0.1″ wide flat-head. On my next post, I will demonstrate how to run configuration and data logging scripts.

Update SDI-12 USB adapter firmware

I have just released an update to the SDI-12 USB adapter. This update makes the adapter recover from errors in communication so it won’t hang your data logging process in case a sensor is broken while you are logging.

To make the firmware update easy, I wrote a Python script to use avrdude.exe to load the firmware to the adapter. You will run the script just like the data logging script or config script:

  1. Install Python 3.5 with Pyserial 3.0 (instruction in the manual).
  2. Unzip the content of the firmware update package in a folder.
  3. Check the properties of avrdude.exe to make sure that it is not blocked from running.
  4. Run the script SDI_12_firmware_update.py in Python environment IDLE.
  5. Select the adapter’s serial port from a list.
  6. Pick the firmware file, usually SDI_12_translator_v1_x.hex (must be stored in the same folder as the script), then wait for it to complete, which takes less than 30 seconds.

Here is the output from Python:

 

sdi-12 USB adapter firmware update

I had the adapter on COM4.

Once updated, try connect to it using a terminal program and send zI! (zee-EYE!) and you will see the response has version 1.2 in it.

(Updated) This script now works on Windows, Mac OSX, GNU/Linux (64-bit) and Raspberry Pi.

SDI-12 USB adapter on Raspberry pi

I have successfully developed Python code to run the SDI-12 USB adapter data logger on Raspberry PI. It was quite a learning experience for me but I was able to boil down the steps into a tutorial on how to install the latest Python on Debian/Raspbian here.

Here are some screen shots of the data logger:

2016-02-03-171037_1680x1050_scrot

2016-02-05-100346_1680x1050_scrotI was using a Decagon 5TM soil temperature and humidity sensor (hanging free in air and sometimes touching my table).

I have translated the Tera Term scripts into Python so it would run on all operating systems, including Win 10, Linux (Debian), and Raspberry PI (Raspbian). I have not got my Mac fixed but don’t expect any issues.

Now you have two Python scripts:

The configuration script detects the SDI-12 sensor’s address, prints the name of the sensor, and you can change it to a different address.

The data logger script lists all available serial ports to let you choose the correct one, then asks for sensor address, total data points, delays between data points, and also what time (GMT or local) to use. You can expand the script to take data from multiple probes and upload data to a server. I’ll add more info on the server upload to sparkfun’s phant data server.

While developing the code, I also discovered that the serial port console was very useful. You can set up auto login and run the data logger script upon auto login. This way the data logger starts logging data once the RPI boots up and auto logs on. No need to log in or use VNC (not good if your logger is using 4G hotspot for internet). Just a command prompt is all that is needed. Next step is to add a config file so the data logger will no longer ask for user inputs when this file exists and takes parameters from the file. This config file will reside in the FAT partition so that the user can easily update the parameters without having to boot into raspberry pi. Just remove the sd card and change parameters on a PC.

SDI-12 USB adapter

After some delay, the SDI-12 USB adapter is finally here:

2015-10-03 16.16.57

This adapter is extremely easy to use. Just connect it to your PC and SDI-12 sensor. Then you can use any serial monitor or terminal emulator program to talk with your sensor. Just open the serial port at 9600 Baud rate. You can start by sending device identification command such as ?!. You will see a response from your sensor, which is the one-character address of your sensor. If you have not set its address, it is most likely to be zero (0). Then you can use 0I! to find out the manufacture and model of your sensor, before getting measurements from it. Getting measurement is easy as pie. First send 0M!, then wait for response. Then send 0D0! to fetch the measurements.

For PC users, I even wrote a data logger script that can automatically log data using the popular Tera Term program. You can choose sensor address, total number of data points, delay between points, and time zone when logging, then the program will keep logging data. The following is a screen grab of Tera Term. The sensor is a Decagon 5TM soil temperature and moisture sensor. The address is one (1) and the returned values are relative dielectric permittivity and then temperature in Celsius.

Data logger

Once you get data logging going, you can import the .CSV file into your Excel and plot it. You can choose a proper refresh rate so your data and plot are up to date when you look at them.

Plot

I’m still ordering more circuit boards but should be able to sell these on my inmojo.com store starting now. There is even a quantity discount if you need 10 or more.

Inmojo store sales page

Making your programming jig

I have recently developed an open source device based on arduino, with an ATMEGA1284P chip. I need to build a number of them and program/test them as well. I did some research and found this article from sparkfun to be quite useful:

https://www.sparkfun.com/tutorials/138

For me, my device is rather large, not a small breakout board. So I need something for its size. The device has LCD, rotary encoder, RTC, SD card, etc. All need some tests before I flash a standard firmware. So I need some software that can flash at least two different firmware to a target with some human interactions. Luckly Nick Gammon has done all the great work with hex loader code. You can turn an arduino into a hex loader that programs fuse values on a target, and load hex files from an SD card to a target. Here is his repo:

https://github.com/nickgammon/arduino_sketches

I used his Atmega_hex_uploader code. It is interactive. You open the serial port and type in commands and see printouts. Very nicely done. Thanks Nick!

For my programmer, I thought about just using an arduino and a jumper wire. Then I have to solder male pins to my device’s ICSP pins. It’s a bit unnecessary and time-consuming, say if I need to program 100 devices (at least a couple extra hours to solder the pins). So I based on my original device design, moved the ICSP header to a different location, and placed a target ICSP header where the original device has ICSP header. I then kept the SD card, RTC, power supply, FTDI chip, and the MCU from the original design. The result is a device that can program other devices. I put it on standoffs. Since this device has the same screw hole locations, I can slide a newly-assembled device down the standoffs to make contact with the programmer. Then use nuts to hold the new device. I can then program it using serial port (fuses, hex code etc.) The programmer also has 2 push buttons. In the future, I will get rid of serial port and have the programmer standalone. If I press button 1, it will flash the target with one hex file that runs a series of tests. Then if all tests pass, I press the second button to flash the target with standard firmware and move on to the next board. I also have 4 LEDs (not yet soldered on) and a buzzer to show audio and visual indications of success and failure firmware flash. I also have a 8-dip switch row to further customize what I do with the target, such as program different standard firmware versions to the target for different variations of the device etc.

Here are some pictures:

Front side (left side has programmer’s own ICSP header, right side is 6 pogo sticks)

Back side (SD card, MCU, two buttons, RTC, power supply):

Programmer with a target board on top (angled top view):

Programmer with target board on top (side view). You can see the gold pogo sticks to the left of the right standoffs.

In the future, I will also write a more capable hex programmer with Nick’s code to do:

  • At the push of button 1, program target fuses and flash FLASH/EEPROM with the current time and date saved to target EEPROM. This way the target can program its own RTC based on the time of the programmer’s RTC, with at most a few seconds off. The rest of the program will self test target.
  • At the push of button 2, program target fuses and flash FLASH with a standard firmware.
  • Audio indicator of success/failure. With audio, you don’t have to watch the programmer. You can do other stuff and be reminded by success/failure tunes.
  • Programming mode (which standard firmware, what fuse setting etc.) based on the 8-dip switches.

I’ll post some videos when I get a chance.

%d bloggers like this: