diff --git a/.github/workflows/test-compile-sketch.yml b/.github/workflows/test-compile-sketch.yml
index 4f3e8c3..17216d3 100644
--- a/.github/workflows/test-compile-sketch.yml
+++ b/.github/workflows/test-compile-sketch.yml
@@ -119,7 +119,7 @@ jobs:
run: |
arduino-cli config set library.enable_unsafe_install true
arduino-cli version
- arduino-cli lib install --git-url https://github.com/sparkfun/SparkFun_Toolkit.git#dc0f0ca
+ arduino-cli lib install "SparkFun Toolkit"@1.0.0
- name: Compile Sketch
run: arduino-cli compile --fqbn ${{ matrix.board.fqbn }} examples/Example_01_BasicReadings --library .
diff --git a/docs/doxygen/doxygen-config b/docs/doxygen/doxygen-config
index 04fc211..76380c8 100644
--- a/docs/doxygen/doxygen-config
+++ b/docs/doxygen/doxygen-config
@@ -171,7 +171,7 @@ ALWAYS_DETAILED_SEC = YES
# operators of the base classes will not be shown.
# The default value is: NO.
-INLINE_INHERITED_MEMB = NO
+INLINE_INHERITED_MEMB = YES
# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path
# before files name in the file list and in the header files. If set to NO the
diff --git a/docs/doxygen/doxygen-custom/header.html b/docs/doxygen/doxygen-custom/header.html
index c66b4f6..b9a870e 100644
--- a/docs/doxygen/doxygen-custom/header.html
+++ b/docs/doxygen/doxygen-custom/header.html
@@ -10,14 +10,14 @@
-
-
-
+
+
+
-
-
+
+
diff --git a/examples/Example_01_BasicReadings/Example_01_BasicReadings.ino b/examples/Example_01_BasicReadings/Example_01_BasicReadings.ino
index d447644..398de2b 100644
--- a/examples/Example_01_BasicReadings/Example_01_BasicReadings.ino
+++ b/examples/Example_01_BasicReadings/Example_01_BasicReadings.ino
@@ -22,7 +22,7 @@
#include "SparkFun_Soil_Moisture_Sensor.h" // CTRL+Click here to get the library: http://librarymanager/All#SparkFun_Soil_Moisture_Sensor
#include
-SparkFunSoilMoistureSensorI2C mySoilSensor; // Create an instance of the sensor class
+SparkFunSoilMoistureSensor mySoilSensor; // Create an instance of the sensor class
// Some Dev boards have their QWIIC connector on Wire or Wire1
// This #ifdef will help this sketch work across more products
diff --git a/examples/Example_02_ReadingsAndLED/Example_02_ReadingsAndLED.ino b/examples/Example_02_ReadingsAndLED/Example_02_ReadingsAndLED.ino
index 0b0c021..9895aca 100644
--- a/examples/Example_02_ReadingsAndLED/Example_02_ReadingsAndLED.ino
+++ b/examples/Example_02_ReadingsAndLED/Example_02_ReadingsAndLED.ino
@@ -22,7 +22,7 @@
#include "SparkFun_Soil_Moisture_Sensor.h" // CTRL+Click here to get the library: http://librarymanager/All#SparkFun_Soil_Moisture_Sensor
#include
-SparkFunSoilMoistureSensorI2C mySoilSensor; // Create an instance of the sensor class
+SparkFunSoilMoistureSensor mySoilSensor; // Create an instance of the sensor class
// Some Dev boards have their QWIIC connector on Wire or Wire1
// This #ifdef will help this sketch work across more products
diff --git a/examples/Example_03_LEDFlashMoisture/Example_03_LEDFlashMoisture.ino b/examples/Example_03_LEDFlashMoisture/Example_03_LEDFlashMoisture.ino
index 4b995a2..07b0481 100644
--- a/examples/Example_03_LEDFlashMoisture/Example_03_LEDFlashMoisture.ino
+++ b/examples/Example_03_LEDFlashMoisture/Example_03_LEDFlashMoisture.ino
@@ -26,7 +26,7 @@
#include "SparkFun_Soil_Moisture_Sensor.h" // CTRL+Click here to get the library: http://librarymanager/All#SparkFun_Soil_Moisture_Sensor
#include
-SparkFunSoilMoistureSensorI2C mySoilSensor; // Create an instance of the sensor class
+SparkFunSoilMoistureSensor mySoilSensor; // Create an instance of the sensor class
// The plan:
// The value of the sensor has the following range:
diff --git a/examples/Example_04_ChangeI2CAddress/Example_04_ChangeI2CAddress.ino b/examples/Example_04_ChangeI2CAddress/Example_04_ChangeI2CAddress.ino
index 11438bd..94e2787 100644
--- a/examples/Example_04_ChangeI2CAddress/Example_04_ChangeI2CAddress.ino
+++ b/examples/Example_04_ChangeI2CAddress/Example_04_ChangeI2CAddress.ino
@@ -22,7 +22,7 @@
#include "SparkFun_Soil_Moisture_Sensor.h" // CTRL+Click here to get the library: http://librarymanager/All#SparkFun_Soil_Moisture_Sensor
#include
-SparkFunSoilMoistureSensorI2C mySoilSensor; // Create an instance of the sensor class
+SparkFunSoilMoistureSensor mySoilSensor; // Create an instance of the sensor class
// Define our alternate I2C address - the default address + 1
#define ALTERNATE_I2C_ADDRESS SFE_SOIL_MOISTURE_DEFAULT_I2C_ADDRESS + 1
diff --git a/library.properties b/library.properties
index abe7577..a45c246 100644
--- a/library.properties
+++ b/library.properties
@@ -8,5 +8,5 @@ category=Sensors
url=https://github.com/sparkfun/SparkFun_Soil_Moisture_Arduino_Library
architectures=*
includes=SparkFun_Soil_Moisture_Sensor.h
-depends=SparkFun Toolkit
+depends=SparkFun Toolkit >=1.0.0
diff --git a/src/SparkFun_Soil_Moisture_Sensor.h b/src/SparkFun_Soil_Moisture_Sensor.h
index 3666a0e..49c801d 100644
--- a/src/SparkFun_Soil_Moisture_Sensor.h
+++ b/src/SparkFun_Soil_Moisture_Sensor.h
@@ -10,7 +10,7 @@
* @author SparkFun Electronics
* @date 2025
* @copyright Copyright (c) 2025, SparkFun Electronics Inc. This project is released under the MIT License.
- *
+ *
* SPDX-License-Identifier: MIT
*/
@@ -20,19 +20,20 @@
#pragma once
// To make the Arduino machine happy, include the toolkit header before the core implementation for this device
+// clang-format off
#include
-#include "sfeTk/sfeDevSoilMoisture.h"
-
+#include "sfTk/sfDevSoilMoisture.h"
+// clang-format on
// Note:
-// The core of the implementation for this device library is in the SparkFun Toolkit object sfeDevSoilMoisture,
-// contained in the directory sfeTk. This object implements all functionality independent of the bus type, I2C or SPI.
+// The core of the implementation for this device library is in the SparkFun Toolkit object sfDevSoilMoisture,
+// contained in the directory sfTk. This object implements all functionality independent of the bus type, I2C or SPI.
// The SparkFunSoilMoistureSensorI2C and SparkFunSoilMoistureSensorSPI classes below are the Arduino-specific,
// bus-specific implementations that inherit from the core toolkit class.
//
//-----------------------------------------------------------------------------------------------
// Define our Arduino Object - I2C version
-class SparkFunSoilMoistureSensorI2C : public sfeDevSoilMoisture
+class SparkFunSoilMoistureSensor : public sfDevSoilMoisture
{
public:
/**
@@ -45,13 +46,13 @@ class SparkFunSoilMoistureSensorI2C : public sfeDevSoilMoisture
* @param wirePort Wire port to use for I2C communication (default is Wire)
* @return true if successful, false otherwise
*/
- bool begin(const uint8_t address = SFE_SOIL_MOISTURE_DEFAULT_I2C_ADDRESS, TwoWire &wirePort = Wire)
+ bool begin(const uint8_t address = SF_SOIL_MOISTURE_DEFAULT_I2C_ADDRESS, TwoWire &wirePort = Wire)
{
// Setup Arduino I2C bus
_theI2CBus.init(wirePort, address);
// Begin the sensor and make sure it's connected.
- return sfeDevSoilMoisture::begin(&_theI2CBus) == kSTkErrOk ? isConnected() : false;
+ return sfDevSoilMoisture::begin(&_theI2CBus) == ksfTkErrOk ? isConnected() : false;
}
/**
@@ -64,16 +65,16 @@ class SparkFunSoilMoistureSensorI2C : public sfeDevSoilMoisture
*/
bool isConnected()
{
- return _theI2CBus.ping() == kSTkErrOk;
+ return _theI2CBus.ping() == ksfTkErrOk;
}
private:
- sfeTkArdI2C _theI2CBus;
+ sfTkArdI2C _theI2CBus;
};
//-----------------------------------------------------------------------------------------------
// Define our Arduino Object - SPI version
-class SparkFunSoilMoistureSensorSPI : public sfeDevSoilMoisture
+class SparkFunSoilMoistureSensorSPI : public sfDevSoilMoisture
{
public:
/**
@@ -96,9 +97,9 @@ class SparkFunSoilMoistureSensorSPI : public sfeDevSoilMoisture
_theSPIBus.init(spiPort, spiSettings, csPin, true);
// Begin the sensor with the SPI bus connection
- return (sfeDevSoilMoisture::begin(&_theSPIBus) == kSTkErrOk);
+ return (sfDevSoilMoisture::begin(&_theSPIBus) == ksfTkErrOk);
}
private:
- sfeTkArdSPI _theSPIBus;
+ sfTkArdSPI _theSPIBus;
};
\ No newline at end of file
diff --git a/src/sfeTk/sfeDevSoilMoisture.cpp b/src/sfTk/sfDevSoilMoisture.cpp
similarity index 66%
rename from src/sfeTk/sfeDevSoilMoisture.cpp
rename to src/sfTk/sfDevSoilMoisture.cpp
index 510f27b..2457cd5 100644
--- a/src/sfeTk/sfeDevSoilMoisture.cpp
+++ b/src/sfTk/sfDevSoilMoisture.cpp
@@ -1,5 +1,5 @@
/**
- * @file sfeDevSoilMoisture.cpp
+ * @file sfDevSoilMoisture.cpp
* @brief Implementation file for the soil moisture sensor class
*
* This file contains the implementation of the soil moisture sensor class, including
@@ -9,12 +9,11 @@
* @author SparkFun Electronics
* @date 2025
* @copyright Copyright (c) 2025, SparkFun Electronics Inc. This project is released under the MIT License.
- *
+ *
* SPDX-License-Identifier: MIT
*/
-
-#include "sfeDevSoilMoisture.h"
+#include "sfDevSoilMoisture.h"
// Impl for the core driver
@@ -22,74 +21,74 @@
/**
* @brief Command to turn off the on-board LED
*/
-#define kCommandLEDOff 0x00
+const uint8_t kCommandLEDOff = 0x00;
/**
* @brief Command to turn on the on-board LED
*/
-#define kCommandLEDOn 0x01
+const uint8_t kCommandLEDOn = 0x01;
/**
* @brief Command to change the I2C address of the sensor
*/
-#define kCommandChangeAddress 0x03
+const uint8_t kCommandChangeAddress = 0x03;
/**
* @brief Command to get the moisture value from the sensor
*/
-#define kCommandGetValue 0x05
+const uint8_t kCommandGetValue = 0x05;
/**
* @brief Command indicating no new data is available
*/
-#define kCommandNothingNew 0x99
+const uint8_t kCommandNothingNew = 0x99;
//---------------------------------------------------------------------
// Core object implementation
//---------------------------------------------------------------------
// start up the sensor
-sfeTkError_t sfeDevSoilMoisture::begin(sfeTkIBus *theBus)
+sfTkError_t sfDevSoilMoisture::begin(sfTkIBus *theBus)
{
// Nullptr check
if (theBus == nullptr)
- return kSTkErrBusNotInit;
+ return ksfTkErrBusNotInit;
// Set bus pointer
_theBus = theBus;
- return kSTkErrOk;
+ return ksfTkErrOk;
}
//----------------------------------------------------------------------------------------
// LED off command
-sfeTkError_t sfeDevSoilMoisture::LEDOff(void)
+sfTkError_t sfDevSoilMoisture::LEDOff(void)
{
if (_theBus == nullptr)
- return kSTkErrBusNotInit;
+ return ksfTkErrBusNotInit;
// Send the command to turn the LED off
- return _theBus->writeByte(kCommandLEDOff);
+ return _theBus->writeData(kCommandLEDOff);
}
//----------------------------------------------------------------------------------------
// LED on command
-sfeTkError_t sfeDevSoilMoisture::LEDOn(void)
+sfTkError_t sfDevSoilMoisture::LEDOn(void)
{
if (_theBus == nullptr)
- return kSTkErrBusNotInit;
+ return ksfTkErrBusNotInit;
// Send the command to turn the LED on
- return _theBus->writeByte(kCommandLEDOn);
+ return _theBus->writeData(kCommandLEDOn);
}
//----------------------------------------------------------------------------------------
// Read the moisture value from the sensor - returns a resistance reading between 0 and 1023
-uint16_t sfeDevSoilMoisture::readMoistureValue(void)
+uint16_t sfDevSoilMoisture::readMoistureValue(void)
{
if (_theBus == nullptr)
return 0;
uint16_t value = 0;
- if (_theBus->readRegisterWord(kCommandGetValue, value) != kSTkErrOk)
+ if (_theBus->readRegister(kCommandGetValue, value) != ksfTkErrOk)
return 0;
return value;
@@ -97,53 +96,53 @@ uint16_t sfeDevSoilMoisture::readMoistureValue(void)
//----------------------------------------------------------------------------------------
// Returns the moisture ratio from the sensor (0 - 1.0)
-float sfeDevSoilMoisture::readMoistureRatio(void)
+float sfDevSoilMoisture::readMoistureRatio(void)
{
if (_theBus == nullptr)
return 0.0;
- return (((float)SFE_SOIL_MOISTURE_MAX_VALUE - (float)readMoistureValue()) / (float)SFE_SOIL_MOISTURE_MAX_VALUE);
+ return (((float)SF_SOIL_MOISTURE_MAX_VALUE - (float)readMoistureValue()) / (float)SF_SOIL_MOISTURE_MAX_VALUE);
}
//----------------------------------------------------------------------------------------
// Returns the moisture percentage from the sensor (0 - 100%)
-float sfeDevSoilMoisture::readMoisturePercentage(void)
+float sfDevSoilMoisture::readMoisturePercentage(void)
{
return readMoistureRatio() * 100.0;
}
//----------------------------------------------------------------------------------------
// Change the I2C address of the sensor
-sfeTkError_t sfeDevSoilMoisture::setI2CAddress(uint8_t newAddress)
+sfTkError_t sfDevSoilMoisture::setI2CAddress(uint8_t newAddress)
{
if (_theBus == nullptr)
- return kSTkErrBusNotInit;
+ return ksfTkErrBusNotInit;
// Validate the new address
if (newAddress < 0x07 || newAddress > 0x78)
- return kSTkErrFail;
+ return ksfTkErrFail;
// If in I2C mode, is the address the same as the current address?
- if (_theBus->type() == kBusTypeI2C && ((sfeTkII2C *)_theBus)->address() == newAddress)
- return kSTkErrOk;
+ if (_theBus->type() == ksfTkBusTypeI2C && ((sfTkII2C *)_theBus)->address() == newAddress)
+ return ksfTkErrOk;
// Send the command to change the address. NOTE: Because of how the sensor works,
// the following will return an error (since the sensor side resets the bus)
- (void)_theBus->writeRegisterByte(kCommandChangeAddress, newAddress);
+ (void)_theBus->writeRegister(kCommandChangeAddress, newAddress);
- return kSTkErrOk;
+ return ksfTkErrOk;
}
//----------------------------------------------------------------------------------------
// Return the address of the sensor bus. For I2C this is the address of the sensor, for
// SPI this is the CS pin
-uint8_t sfeDevSoilMoisture::address(void)
+uint8_t sfDevSoilMoisture::address(void)
{
if (_theBus == nullptr)
return 0;
- if (_theBus->type() == kBusTypeSPI)
- return ((sfeTkISPI *)_theBus)->cs();
- else if (_theBus->type() == kBusTypeI2C)
- return ((sfeTkII2C *)_theBus)->address();
+ if (_theBus->type() == ksfTkBusTypeSPI)
+ return ((sfTkISPI *)_theBus)->cs();
+ else if (_theBus->type() == ksfTkBusTypeI2C)
+ return ((sfTkII2C *)_theBus)->address();
return 0;
}
diff --git a/src/sfeTk/sfeDevSoilMoisture.h b/src/sfTk/sfDevSoilMoisture.h
similarity index 79%
rename from src/sfeTk/sfeDevSoilMoisture.h
rename to src/sfTk/sfDevSoilMoisture.h
index 685144d..e610bac 100644
--- a/src/sfeTk/sfeDevSoilMoisture.h
+++ b/src/sfTk/sfDevSoilMoisture.h
@@ -1,5 +1,5 @@
/**
- * @file sfeDevSoilMoisture.h
+ * @file sfDevSoilMoisture.h
* @brief Header file for the soil moisture sensor class
*
* This file contains the class definition for the soil moisture sensor, including
@@ -20,18 +20,18 @@
#include
// include the sparkfun toolkit headers
-#include
+#include
// Bus interfaces
-#include
-#include
+#include
+#include
/**
* @brief Default I2C address for the soil moisture sensor
*
* This macro defines the default I2C address (0x28) used by the soil moisture sensor.
*/
-#define SFE_SOIL_MOISTURE_DEFAULT_I2C_ADDRESS 0x28
+#define SF_SOIL_MOISTURE_DEFAULT_I2C_ADDRESS 0x28
/**
* @brief Maximum value for the soil moisture sensor
@@ -39,7 +39,7 @@
* This macro defines the maximum value (1023) for the soil moisture sensor,
* which corresponds to the highest reading from the 10-bit ADC. 2^10 = 1024-1
*/
-#define SFE_SOIL_MOISTURE_MAX_VALUE 1023
+#define SF_SOIL_MOISTURE_MAX_VALUE 1023
/**
* @brief Class representing the soil moisture sensor
@@ -47,12 +47,12 @@
* This class provides an interface to the soil moisture sensor, allowing for
* initialization, reading moisture values and controlling the on-board LED.
*/
-class sfeDevSoilMoisture
+class sfDevSoilMoisture
{
public:
// ctor
- sfeDevSoilMoisture() : _theBus{nullptr}
+ sfDevSoilMoisture() : _theBus{nullptr}
{
}
@@ -63,36 +63,36 @@ class sfeDevSoilMoisture
* communication with the sensor using the provided I2C bus interface.
*
* @param theBus Pointer to an I2C toolkit object. If nullptr, uses previously set bus
- * @return kSTkErrOk if initialization succeeds
- * @return kSTkErrBusNotInit if no valid bus interface is provided
+ * @return ksfTkErrOk if initialization succeeds
+ * @return ksfTkErrBusNotInit if no valid bus interface is provided
*/
- sfeTkError_t begin(sfeTkIBus *theBus = nullptr);
+ sfTkError_t begin(sfTkIBus *theBus = nullptr);
/**
* @brief Turns off the on-board LED
*
* Disables the sensor's built-in LED
*
- * @return kSTkErrOk if LED was successfully turned off
- * @return kSTkErrBusNotInit if no bus interface is configured
- * @return kSTkErrFail if sensor doesn't respond or a communication error occurs
+ * @return ksfTkErrOk if LED was successfully turned off
+ * @return ksfTkErrBusNotInit if no bus interface is configured
+ * @return ksfTkErrFail if sensor doesn't respond or a communication error occurs
*
* @see LEDOn()
*/
- sfeTkError_t LEDOff(void);
+ sfTkError_t LEDOff(void);
/**
* @brief Turns on the on-board LED
*
* Enables the sensor's built-in LED by sending the appropriate command
*
- * @return kSTkErrOk if LED was successfully turned on
- * @return kSTkErrBusNotInit if no bus interface is configured
- * @return kSTkErrFail if sensor doesn't respond or a communication error occurs
+ * @return ksfTkErrOk if LED was successfully turned on
+ * @return ksfTkErrBusNotInit if no bus interface is configured
+ * @return ksfTkErrFail if sensor doesn't respond or a communication error occurs
*
* @see LEDOff()
*/
- sfeTkError_t LEDOn(void);
+ sfTkError_t LEDOn(void);
/**
* @brief Reads the moisture value from the sensor
@@ -134,10 +134,10 @@ class sfeDevSoilMoisture
* for all future I2C communication with the sensor. This value is persistent
*
* @param newAddress The new I2C address to assign to the sensor
- * @return kSTkErrOk if successful, otherwise an error code
+ * @return ksfTkErrOk if successful, otherwise an error code
* @note If communicating via I2C, the provided address is used for future I2C communication
*/
- sfeTkError_t setI2CAddress(uint8_t newAddress);
+ sfTkError_t setI2CAddress(uint8_t newAddress);
/**
* @brief Returns the current address of the sensor
@@ -156,6 +156,6 @@ class sfeDevSoilMoisture
* This member variable holds a pointer to the bus interface (I2C or SPI) used
* for communication with the soil moisture sensor.
*/
- sfeTkIBus *_theBus;
+ sfTkIBus *_theBus;
-}; // class sfeDevSoilMoisture
\ No newline at end of file
+}; // class sfDevSoilMoisture
\ No newline at end of file