SDI12.h file

This file contains the main class for the SDI-12 implementation.

========================== Arduino SDI-12 ==================================

An Arduino library for SDI-12 communication with a wide variety of environmental sensors. This library provides a general software solution, without requiring any additional hardware.

======================== Attribution & License =============================

Copyright (C) 2013 Stroud Water Research Center Available at https://github.com/EnviroDIY/Arduino-SDI-12

Authored initially in August 2013 by: Kevin M. Smith (http://ethosengineering.org) Inquiries: SDI12@ethosengineering.org

Modified 2017 by Manuel Jimenez Buendia to work with ARM based processors (Arduino Zero)

Maintenance and merging 2017 by Sara Damiano

based on the SoftwareSerial library (formerly NewSoftSerial), authored by: ladyada (http://ladyada.net) Mikal Hart (http://www.arduiniana.org) Paul Stoffregen (http://www.pjrc.com) Garrett Mace (http://www.macetech.com) Brett Hagman (http://www.roguerobotics.com/)

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Classes

class SDI12
The main class for SDI 12 instances.

Enums

enum LookaheadMode { SKIP_ALL, SKIP_NONE, SKIP_WHITESPACE }
This enumeration provides the lookahead options for parseInt(), parseFloat().

Typedefs

using FlashString = const __FlashStringHelper*
Helper for strings stored in flash.

Defines

#define NO_IGNORE_CHAR = '\x01'
a char not found in a valid ASCII numeric field
#define SDI12_CHECK_PARITY
Check the value of the parity bit on reception.
#define SDI12_WAKE_DELAY = 0
The amount of additional time in milliseconds that the sensor takes to wake before being ready to receive a command. Default is 0ms - meaning the sensor is ready for a command by the end of the 12ms break. Per protocol, the wake time must be less than 100 ms.
#define SDI12_BUFFER_SIZE = 81
The buffer size for incoming SDI-12 data.
#define SDI12_YIELD_MS = 0
The time to delay, in milliseconds, to allow the buffer to fill before returning the value from the buffer.
#define SDI12_YIELD() = { delay(
A delay function to allow the buffer to fill before returning the value from the buffer.

Enum documentation

enum LookaheadMode

This enumeration provides the lookahead options for parseInt(), parseFloat().

The rules set out here are used until either the first valid character is found or a time out occurs due to lack of input.

This enum is part of the Stream parent class, but is missing from the ESP8266 core and ESP32 cores prior to 3.0 (IDF prior to 5.1).

Enumerators
SKIP_ALL

All invalid characters are ignored.

SKIP_NONE

Nothing is skipped, and the stream is not touched unless the first waiting character is valid.

SKIP_WHITESPACE

Only tabs, spaces, line feeds & carriage returns are skipped.


Define documentation

#define SDI12_BUFFER_SIZE = 81

The buffer size for incoming SDI-12 data.

All responses should be less than 81 characters:

  • address is a single (1) character
  • values has a maximum value of 75 characters
  • CRC is 3 characters
  • CR is a single character
  • LF is a single character

#define SDI12_YIELD_MS = 0

The time to delay, in milliseconds, to allow the buffer to fill before returning the value from the buffer.

This may be needed for faster processors to account for the slow baud rate of SDI-12. Without this, the available() function may return 0 while we're in the middle of reading a character.

There are 8.33 ms/character, so we delay by 8ms for fast processors to allow one character to finish.


#define SDI12_YIELD() = { delay(

A delay function to allow the buffer to fill before returning the value from the buffer.

This may be needed for faster processors to account for the slow baud rate of SDI-12.