SparkFun Soil Moisture Sensor  v1.0.1-2-g96f40cb
Library for the SparkFun Soil Moisture Sensor
Loading...
Searching...
No Matches
sfDevSoilMoisture.h
Go to the documentation of this file.
1
16// Actual implementation of the soil moisture sensor - this is a platform "independent" implementation
17
18#pragma once
19
20#include <stdint.h>
21
22// include the sparkfun toolkit headers
23#include <sfTk/sfToolkit.h>
24
25// Bus interfaces
26#include <sfTk/sfTkII2C.h>
27#include <sfTk/sfTkISPI.h>
28
34#define SF_SOIL_MOISTURE_DEFAULT_I2C_ADDRESS 0x28
35
42#define SF_SOIL_MOISTURE_MAX_VALUE 1023
43
51{
52
53 public:
54 // ctor
56 {
57 }
58
69 sfTkError_t begin(sfTkIBus *theBus = nullptr);
70
82 sfTkError_t LEDOff(void);
83
95 sfTkError_t LEDOn(void);
96
107 uint16_t readMoistureValue(void);
108
118 float readMoistureRatio(void);
119
128 float readMoisturePercentage(void);
129
140 sfTkError_t setI2CAddress(uint8_t newAddress);
141
150 uint8_t address(void);
151
152 protected:
159 sfTkIBus *_theBus;
160
161}; // class sfDevSoilMoisture
Class representing the soil moisture sensor.
Definition: sfDevSoilMoisture.h:51
uint16_t readMoistureValue(void)
Reads the moisture value from the sensor.
Definition: sfDevSoilMoisture.cpp:85
sfTkError_t begin(sfTkIBus *theBus=nullptr)
Initializes communication with the soil moisture sensor.
Definition: sfDevSoilMoisture.cpp:50
uint8_t address(void)
Returns the current address of the sensor.
Definition: sfDevSoilMoisture.cpp:137
float readMoisturePercentage(void)
Reads the sensor value and returns the moisture percentage from the sensor.
Definition: sfDevSoilMoisture.cpp:109
sfDevSoilMoisture()
Definition: sfDevSoilMoisture.h:55
sfTkError_t LEDOff(void)
Turns off the on-board LED.
Definition: sfDevSoilMoisture.cpp:64
sfTkIBus * _theBus
The toolkit bus the sensor is connected to.
Definition: sfDevSoilMoisture.h:159
float readMoistureRatio(void)
Reads the sensor value and returns the moisture ratio from the sensor.
Definition: sfDevSoilMoisture.cpp:99
sfTkError_t LEDOn(void)
Turns on the on-board LED.
Definition: sfDevSoilMoisture.cpp:74
sfTkError_t setI2CAddress(uint8_t newAddress)
Changes the I2C address of the sensor.
Definition: sfDevSoilMoisture.cpp:115