This is a simple demonstration of the SDI-12 library for Arduino. It requests information about a single attached sensor, including its address and manufacturer info, and prints it to the serial port
PlatformIO Configuration
1; PlatformIO Project Configuration File
4description = SDI-12 Library Example A: Getting information for a single attached sensor
5src_dir = .piolibdeps/Arduino-SDI-12_ID1486/examples/a_wild_card
The Complete Example
2 * @example{lineno} a_wild_card.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>
8 * @brief Example A: Using the Wildcard - Getting Single Sensor Information
10 * This is a simple demonstration of the SDI-12 library for Arduino.
12 * It requests information about the attached sensor, including its address and
18uint32_t serialBaud = 115200; /*!< The baud rate for the output serial port */
19int8_t dataPin = 7; /*!< The pin of the SDI-12 data bus */
20int8_t powerPin = 22; /*!< The sensor power pin (or -1 if not switching power) */
22/** Define the SDI-12 bus */
23SDI12 mySDI12(dataPin);
26 '?' is a wildcard character which asks any and all sensors to respond
27 'I' indicates that the command wants information about the sensor
28 '!' finishes the command
30String myCommand = "?I!";
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 mySDI12.sendCommand(myCommand);
52 delay(300); // wait a while for a response
53 while (mySDI12.available()) { // write the response to the screen
54 Serial.write(mySDI12.read());
56 delay(3000); // print again in three seconds