99 *---------------------------------------------------------------------------------
1010 */
1111
12- // A simple wrapper around the SparkFun Soil Moisture Sensor - based on the original example driver /example from Zio
13- // from here https://github.com/sparkfun/Zio-Qwiic-Soil-Moisture-Sensor
12+ // A simple wrapper around the SparkFun Soil Moisture Sensor - based on the original example driver /example from Zio
13+ // from here https://github.com/sparkfun/Zio-Qwiic-Soil-Moisture-Sensor
1414
1515#pragma once
1616
1717// To make the Arduino machine happy, include the toolkit header before the core implementation for this device
1818#include < SparkFun_Toolkit.h>
1919#include " sfeTk/sfeDevSoilMoisture.h"
2020
21+
2122// Note:
2223// The core of the implementation for this device library is in the SparkFun Toolkit object sfeDevSoilMoisture,
2324// contained in the directory sfeTk. This object implements all functionality independent of the bus type, I2C or SPI.
24- // The SparkFunSoilMoistureSensorI2C and SparkFunSoilMoistureSensorSPI classes below are the Arduino-specific, bus-specific
25- // implementations that inherit from the core toolkit class.
25+ // The SparkFunSoilMoistureSensorI2C and SparkFunSoilMoistureSensorSPI classes below are the Arduino-specific,
26+ // bus-specific implementations that inherit from the core toolkit class.
2627//
2728// -----------------------------------------------------------------------------------------------
2829// Define our Arduino Object - I2C version
2930class SparkFunSoilMoistureSensorI2C : public sfeDevSoilMoisture
3031{
3132 public:
32- // / @brief Begins the Device
33- // / @param address I2C device address to use for the sensor
34- // / @param wirePort Wire port to use for I2C communication
35- // / @return True if successful, false otherwise
33+ /* *
34+ * @brief Begins the Device
35+ *
36+ * Initializes the soil moisture sensor for I2C communication using the specified
37+ * I2C address and wire port.
38+ *
39+ * @param address I2C device address to use for the sensor (default is SFE_SOIL_MOISTURE_DEFAULT_I2C_ADDRESS)
40+ * @param wirePort Wire port to use for I2C communication (default is Wire)
41+ * @return true if successful, false otherwise
42+ */
3643 bool begin (const uint8_t address = SFE_SOIL_MOISTURE_DEFAULT_I2C_ADDRESS, TwoWire &wirePort = Wire)
3744 {
3845 // Setup Arduino I2C bus
@@ -42,8 +49,14 @@ class SparkFunSoilMoistureSensorI2C : public sfeDevSoilMoisture
4249 return sfeDevSoilMoisture::begin (&_theI2CBus) == kSTkErrOk ? isConnected () : false ;
4350 }
4451
45- // / @brief Checks if the Device is connected
46- // / @return True if the sensor is connected, false otherwise
52+ /* *
53+ * @brief Checks if the device is connected and responding
54+ *
55+ * Tests communication with the sensor by attempting to ping it over I2C.
56+ * A successful ping indicates the sensor is properly connected and responding.
57+ *
58+ * @return true if the sensor responds to communication attempts, false otherwise
59+ */
4760 bool isConnected ()
4861 {
4962 return _theI2CBus.ping () == kSTkErrOk ;
@@ -58,19 +71,27 @@ class SparkFunSoilMoistureSensorI2C : public sfeDevSoilMoisture
5871class SparkFunSoilMoistureSensorSPI : public sfeDevSoilMoisture
5972{
6073 public:
61- // / @brief Begins the Device with SPI as the communication bus
62- // / @param csPin The chip select pin for the sensor
63- // / @param spiPort The SPI port to use for communication
64- // / @param spiSettings The SPI settings to use for communication
65- // / @return True if successful, false otherwise
66- bool begin (const uint8_t csPin, SPIClass &spiPort = SPI, SPISettings spiSettings = SPISettings(100000 , MSBFIRST, SPI_MODE0))
74+ /* *
75+ * @brief Begins the Device with SPI as the communication bus
76+ *
77+ * Initializes the soil moisture sensor for SPI communication using the specified
78+ * chip select pin, SPI port, and SPI settings.
79+ *
80+ * @param csPin The chip select pin for the sensor
81+ * @param spiPort The SPI port to use for communication (default is SPI)
82+ * @param spiSettings The SPI settings to use for communication (default is SPISettings(100000, MSBFIRST,
83+ * SPI_MODE0))
84+ * @return true if successful, false otherwise
85+ */
86+ bool begin (const uint8_t csPin, SPIClass &spiPort = SPI,
87+ SPISettings spiSettings = SPISettings(100000 , MSBFIRST, SPI_MODE0))
6788 {
6889
6990 // Setup Arduino SPI bus
7091 _theSPIBus.init (spiPort, spiSettings, csPin, true );
7192
7293 // Begin the sensor with the SPI bus connection
73- return (sfeDevSoilMoisture::begin (&_theSPIBus) == kSTkErrOk );
94+ return (sfeDevSoilMoisture::begin (&_theSPIBus) == kSTkErrOk );
7495 }
7596
7697 private:
0 commit comments