Skip to content

Commit f6cc7f9

Browse files
committed
initial commit - works! (on an ESP32 c6)
1 parent 008f5c1 commit f6cc7f9

File tree

9 files changed

+3260
-0
lines changed

9 files changed

+3260
-0
lines changed

docs/doxygen/doxygen-config

Lines changed: 2818 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
:root {
2+
--side-nav-fixed-width: 300px;
3+
}
4+
5+
.github-corner svg {
6+
fill: var(--primary-light-color);
7+
color: var(--page-background-color);
8+
width: 72px;
9+
height: 72px;
10+
}
11+
12+
#projectnumber {
13+
margin-right: 22px;
14+
}
15+
16+
@media screen and (max-width: 767px) {
17+
.github-corner svg {
18+
width: 55px;
19+
height: 55px;
20+
}
21+
}
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
<!-- HTML header for doxygen 1.9.1-->
2+
<!DOCTYPE html
3+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4+
<html xmlns="http://www.w3.org/1999/xhtml">
5+
6+
<head>
7+
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8" />
8+
<meta http-equiv="X-UA-Compatible" content="IE=9" />
9+
<meta name="generator" content="Doxygen $doxygenversion" />
10+
<meta name="viewport" content="width=device-width, initial-scale=1" />
11+
12+
<!-- BEGIN opengraph metadata -->
13+
<meta property="og:title" content="SparkFun Toolkit" />
14+
<meta property="og:description" content="Common Functionality for Arduino Libraries" />
15+
<meta property="og:url" content="https://docs.sparkfun.com/SparkFun_Toolkit/" />
16+
<!-- END opengraph metadata -->
17+
18+
<!-- BEGIN twitter metadata -->
19+
<meta name="twitter:title" content="SparkFun Toolkit" />
20+
<meta name="twitter:description" content="Common Functionality for Arduino Libraries." />
21+
<!-- END twitter metadata -->
22+
23+
<!--BEGIN PROJECT_NAME-->
24+
<title>$projectname: $title</title><!--END PROJECT_NAME-->
25+
<!--BEGIN !PROJECT_NAME-->
26+
<title>$title</title><!--END !PROJECT_NAME-->
27+
<link href="$relpath^tabs.css" rel="stylesheet" type="text/css" />
28+
<link rel="icon" type="image/png" href="sfe_flame.png">
29+
<script type="text/javascript" src="$relpath^jquery.js"></script>
30+
<script type="text/javascript" src="$relpath^dynsections.js"></script>
31+
$treeview
32+
$search
33+
$mathjax
34+
<link href="$relpath^$stylesheet" rel="stylesheet" type="text/css" />
35+
$extrastylesheet
36+
</head>
37+
38+
<body>
39+
40+
<!-- https://tholman.com/github-corners/ -->
41+
<a href="https://github.com/sparkfun/SparkFun_Toolkit" class="github-corner" title="View source on GitHub">
42+
<svg viewBox="0 0 250 250" style="position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true">
43+
<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
44+
<path
45+
d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
46+
fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>
47+
<path
48+
d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
49+
fill="currentColor" class="octo-body"></path>
50+
</svg></a>
51+
<style>
52+
.github-corner:hover .octo-arm {
53+
animation: octocat-wave 560ms ease-in-out
54+
}
55+
56+
@keyframes octocat-wave {
57+
58+
0%,
59+
100% {
60+
transform: rotate(0)
61+
}
62+
63+
20%,
64+
60% {
65+
transform: rotate(-25deg)
66+
}
67+
68+
40%,
69+
80% {
70+
transform: rotate(10deg)
71+
}
72+
}
73+
74+
@media (max-width:500px) {
75+
.github-corner:hover .octo-arm {
76+
animation: none
77+
}
78+
79+
.github-corner .octo-arm {
80+
animation: octocat-wave 560ms ease-in-out
81+
}
82+
}
83+
</style>
84+
85+
86+
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
87+
88+
<!--BEGIN TITLEAREA-->
89+
<div id="titlearea">
90+
<table cellspacing="0" cellpadding="0">
91+
<tbody>
92+
<tr style="height: 56px;">
93+
<!--BEGIN PROJECT_LOGO-->
94+
<td id="projectlogo"><img alt="Logo" src="$relpath^$projectlogo" /></td>
95+
<!--END PROJECT_LOGO-->
96+
<!--BEGIN PROJECT_NAME-->
97+
<td id="projectalign" style="padding-left: 0.5em;">
98+
<div id="projectname">$projectname
99+
<!--BEGIN PROJECT_NUMBER-->&#160;<span
100+
id="projectnumber">$projectnumber</span><!--END PROJECT_NUMBER-->
101+
</div>
102+
<!--BEGIN PROJECT_BRIEF-->
103+
<div id="projectbrief">$projectbrief</div><!--END PROJECT_BRIEF-->
104+
</td>
105+
<!--END PROJECT_NAME-->
106+
<!--BEGIN !PROJECT_NAME-->
107+
<!--BEGIN PROJECT_BRIEF-->
108+
<td style="padding-left: 0.5em;">
109+
<div id="projectbrief">$projectbrief</div>
110+
</td>
111+
<!--END PROJECT_BRIEF-->
112+
<!--END !PROJECT_NAME-->
113+
<!--BEGIN DISABLE_INDEX-->
114+
<!--BEGIN SEARCHENGINE-->
115+
<td>$searchbox</td>
116+
<!--END SEARCHENGINE-->
117+
<!--END DISABLE_INDEX-->
118+
</tr>
119+
</tbody>
120+
</table>
121+
</div>
122+
<!--END TITLEAREA-->
123+
<!-- end header part -->
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
3+
*/
4+
5+
#include "SparkFun_Soil_Moisture_Sensor.h" // CTRL+Click here to get the library: http://librarymanager/All#SparkFun_Soil_Moisture
6+
#include <Wire.h>
7+
8+
SparkFunSoilMoistureSensor mySoilSensor; // Create an instance of the sensor class
9+
10+
// Some Dev boards have their QWIIC connector on Wire or Wire1
11+
// This #ifdef will help this sketch work across more products
12+
13+
#ifdef ARDUINO_SPARKFUN_THINGPLUS_RP2040
14+
#define wirePort Wire1
15+
#else
16+
#define wirePort Wire
17+
#endif
18+
19+
void setup()
20+
{
21+
Serial.begin(115200);
22+
23+
while (!Serial)
24+
delay(10); // Wait for Serial to become available.
25+
// Necessary for boards with native USB (like the SAMD51 Thing+).
26+
// For a final version of a project that does not need serial debug (or a USB cable plugged in),
27+
// Comment out this while loop, or it will prevent the remaining code from running.
28+
29+
Serial.println();
30+
Serial.println("Soil Sensor Example 1 - Basic Readings");
31+
32+
wirePort.begin();
33+
34+
if (mySoilSensor.begin() == false)
35+
{
36+
Serial.println("Soil Moisture Sensor not detected at default I2C address. Verify the sensor is connected "
37+
"correctly. Freezing...");
38+
while (1)
39+
;
40+
}
41+
Serial.println("Soil Moisture Sensor found!");
42+
}
43+
44+
void loop()
45+
{
46+
// Let's get some readings
47+
uint16_t soilMoisture = mySoilSensor.readMoistureValue();
48+
Serial.print("Soil Moisture: ");
49+
Serial.println(soilMoisture);
50+
51+
delay(2000);
52+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
3+
*/
4+
5+
#include "SparkFun_Soil_Moisture_Sensor.h" // CTRL+Click here to get the library: http://librarymanager/All#SparkFun_Soil_Moisture
6+
#include <Wire.h>
7+
8+
SparkFunSoilMoistureSensor mySoilSensor; // Create an instance of the sensor class
9+
10+
// Some Dev boards have their QWIIC connector on Wire or Wire1
11+
// This #ifdef will help this sketch work across more products
12+
13+
#ifdef ARDUINO_SPARKFUN_THINGPLUS_RP2040
14+
#define wirePort Wire1
15+
#else
16+
#define wirePort Wire
17+
#endif
18+
19+
void setup()
20+
{
21+
Serial.begin(115200);
22+
23+
while (!Serial)
24+
delay(10); // Wait for Serial to become available.
25+
// Necessary for boards with native USB (like the SAMD51 Thing+).
26+
// For a final version of a project that does not need serial debug (or a USB cable plugged in),
27+
// Comment out this while loop, or it will prevent the remaining code from running.
28+
29+
Serial.println();
30+
Serial.println("Soil Sensor Example 1 - Basic Readings");
31+
32+
wirePort.begin();
33+
34+
if (mySoilSensor.begin() == false)
35+
{
36+
Serial.println("Soil Moisture Sensor not detected at default I2C address. Verify the sensor is connected "
37+
"correctly. Freezing...");
38+
while (1)
39+
;
40+
}
41+
Serial.println("Soil Moisture Sensor found!");
42+
43+
mySoilSensor.LEDOff();
44+
}
45+
46+
void loop()
47+
{
48+
// Wink the LED during the reading
49+
mySoilSensor.LEDOn();
50+
// Let's get some readings
51+
uint16_t soilMoisture = mySoilSensor.readMoistureValue();
52+
Serial.print("Soil Moisture: ");
53+
Serial.println(soilMoisture);
54+
55+
delay(100);
56+
mySoilSensor.LEDOff();
57+
58+
delay(2000);
59+
}

library.properties

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name=SparkFun Soil Moisture Sensor
2+
version=0.9
3+
author=SparkFun Electronics
4+
maintainer=SparkFun Electronics
5+
sentence=An Arduino library for the SparkFun Qwiic Soil Moisture Sensor.
6+
paragraph=The SparkFun Soil Moisture Sensor is a simple breakout for measuring the moisture in soil and similar materials. The soil moisture sensor is pretty straight forward to use. The two large, exposed pads function as probes for the sensor, together acting as a variable resistor. The more water that is in the soil means the better the conductivity between the pads will be and will result in a lower resistance, and a higher SIG out. This version of the Soil Moisture Sensor includes a Qwiic connector, making it even easier to use this sensor.
7+
category=Sensor
8+
url=https://github.com/sparkfun/SparkFun_Soil_Moisture_Arduino_Library/tree/main
9+
architectures=*
10+
includes=SparkFun_Soil_Moisture_Sensor.h
11+
depends=SparkFun Toolkit
12+

src/SparkFun_Soil_Moisture_Sensor.h

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
2+
/*
3+
*---------------------------------------------------------------------------------
4+
*
5+
* Copyright (c) 2025, SparkFun Electronics Inc.
6+
*
7+
* SPDX-License-Identifier: MIT
8+
*
9+
*---------------------------------------------------------------------------------
10+
*/
11+
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
14+
15+
#pragma once
16+
17+
// To make the Arduino machine happy, include the toolkit header before the core implementation for this device
18+
#include <SparkFun_Toolkit.h>
19+
#include "sfeTk/sfeDevSoilMoisture.h"
20+
21+
22+
// make a nice Arduino define for the default address
23+
#define SFE_SOIL_MOISTURE_DEFAULT_I2C_ADDRESS kSfeDevSoilMoistureDefaultI2CAddress
24+
25+
// Define our Arduino Object
26+
class SparkFunSoilMoistureSensor : public sfeDevSoilMoisture
27+
{
28+
public:
29+
/// @brief Begins the Device
30+
/// @param address I2C device address to use for the sensor
31+
/// @param wirePort Wire port to use for I2C communication
32+
/// @return True if successful, false otherwise
33+
bool begin(const uint8_t address = SFE_SOIL_MOISTURE_DEFAULT_I2C_ADDRESS, TwoWire &wirePort = Wire)
34+
{
35+
// Setup Arduino I2C bus
36+
_theI2CBus.init(wirePort, address);
37+
38+
// Begin the sensor and make sure it's connected.
39+
return sfeDevSoilMoisture::begin(&_theI2CBus) == kSTkErrOk ? isConnected() : false;
40+
}
41+
42+
/// @brief Checks if the Device is connected
43+
/// @return True if the sensor is connected, false otherwise
44+
bool isConnected()
45+
{
46+
return _theI2CBus.ping() == kSTkErrOk;
47+
}
48+
49+
private:
50+
sfeTkArdI2C _theI2CBus;
51+
};

0 commit comments

Comments
 (0)