This is a simple demonstration of the SDI-12 library for Arduino.
It's purpose is to allow a user to interact with an SDI-12 sensor directly, issuing commands through a serial terminal window.
PlatformIO Configuration
1; PlatformIO Project Configuration File
4description = SDI-12 Library Example G: Sending SDI-12 Commands from Serial Monitor
5src_dir = .piolibdeps/Arduino-SDI-12_ID1486/examples/g_terminal_window
The Complete Example
2 * @example{lineno} g_terminal_window.ino
3 * @copyright Stroud Water Research Center
4 * @license This example is published under the BSD-3 license.
5 * @author Kevin M.Smith <SDI12@ethosengineering.org>
7 * @author Ruben Kertesz <github@emnet.net> or \@rinnamon on twitter
10 * @brief Example G: Using the Arduino as a Command Terminal for SDI-12 Sensors
12 * This is a simple demonstration of the SDI-12 library for Arduino. It's purpose is to
13 * allow a user to interact with an SDI-12 sensor directly, issuing commands through a
14 * serial terminal window.
16 * Edited by Ruben Kertesz for ISCO Nile 502 2/10/2016
21uint32_t serialBaud = 115200; /*!< The baud rate for the output serial port */
22int8_t dataPin = 7; /*!< The pin of the SDI-12 data bus */
23int8_t powerPin = 22; /*!< The sensor power pin (or -1 if not switching power) */
25/** Define the SDI-12 bus */
26SDI12 mySDI12(dataPin);
29String sdiResponse = "";
33 Serial.begin(serialBaud);
37 Serial.println("Opening SDI-12 bus...");
39 delay(500); // allow things to settle
43 Serial.println("Powering up sensors...");
44 pinMode(powerPin, OUTPUT);
45 digitalWrite(powerPin, HIGH);
51 if (Serial.available()) {
52 inByte = Serial.read();
53 if ((inByte != '\n') &&
54 (inByte != '\r')) { // read all values entered in terminal window before enter
56 delay(10); // 1 character ~ 7.5ms
60 if (inByte == '\r') { // once we press enter, send string to SDI sensor/probe
62 Serial.println(myCommand);
63 mySDI12.sendCommand(myCommand);
64 delay(30); // wait a while for a response
66 while (mySDI12.available()) { // build a string of the response
67 char c = mySDI12.read();
68 if ((c != '\n') && (c != '\r')) {
70 delay(10); // 1 character ~ 7.5ms
73 if (sdiResponse.length() >= 1)
74 Serial.println(sdiResponse); // write the response to the screen
76 mySDI12.clearBuffer(); // clear the line