SDI12_boards.h file

This file defines the timing units needed for various Arduino boards.

Classes

class SDI12Timer
The class used to define the processor timer for the SDI-12 serial emulation.

Typedefs

using sdi12timer_t = uint8_t

Defines

#define ISR_MEM_ACCESS = IRAM_ATTR
Defines a memory access location, if needed for the interrupts service routines.
#define TIMER_IN_USE_STR = "Timer2"
A string description of the timer to use.
#define TIMER_INT_TYPE = uint8_t
The interger type of the timer.
#define TIMER_INT_SIZE = 8
The size in bits of the timer count value.
#define READTIME = TCNT2
The function or macro used to read the clock timer value.
#define PRESCALE_IN_USE_STR = "8MHz/256=31.25kHz"
A string description of the prescaler in use.
#define TICKS_PER_SECOND = 31250
The number of clock ticks per second, after accounting for the prescaler.
#define TICKS_PER_BIT = 26
The number of "ticks" of the timer that occur within the timing of one bit at the SDI-12 baud rate of 1200 bits/second.
#define BITS_PER_TICK_Q10 = 39
The number of "ticks" of the timer per SDI-12 bit, shifted by 2^10.
#define RX_WINDOW_FUDGE = 10
A "fudge factor" to get the Rx to work well. It mostly works to ensure that uneven tick increments get rounded up.

Typedef documentation

typedef uint8_t sdi12timer_t

The interger type (size) of the timer return value


Define documentation

#define ISR_MEM_ACCESS = IRAM_ATTR

Defines a memory access location, if needed for the interrupts service routines.

On espressif boards (ESP8266 and ESP32), the ISR must be stored in IRAM


#define TICKS_PER_BIT = 26

The number of "ticks" of the timer that occur within the timing of one bit at the SDI-12 baud rate of 1200 bits/second.

31250 'ticks'/sec = 32 µs / 'tick' (1 sec/1200 bits) * (1 tick/32 µs) = 26.04166667 ticks/bit

The 8-bit timer rolls over after 256 ticks, 9.8304 bits, or 8.192 ms (256 ticks/roll-over) * (1 bit/26.04166667 ticks) = 9.8304 bits (256 ticks/roll-over) * (1 sec/31250 ticks) = 8.192 milliseconds


#define BITS_PER_TICK_Q10 = 39

The number of "ticks" of the timer per SDI-12 bit, shifted by 2^10.

1/(26.04166667 ticks/bit) * 2^10 = 39.3216


#define RX_WINDOW_FUDGE = 10

A "fudge factor" to get the Rx to work well. It mostly works to ensure that uneven tick increments get rounded up.