25
25
SparkFunSoilMoistureSensor mySoilSensor; // Create an instance of the sensor class
26
26
27
27
// Define our alternate I2C address - the default address + 1
28
- #define ALTERNATE_I2C_ADDRESS SFE_SOIL_MOISTURE_DEFAULT_I2C_ADDRESS + 1
28
+ #define ALTERNATE_I2C_ADDRESS SF_SOIL_MOISTURE_DEFAULT_I2C_ADDRESS + 1
29
29
30
30
// Some Dev boards have their QWIIC connector on Wire or Wire1
31
31
// This #ifdef will help this sketch work across more products
@@ -61,26 +61,26 @@ void setup()
61
61
if (mySoilSensor.begin () == false )
62
62
{
63
63
// Did the sensor get left at the alt address? Try the alt address
64
- SparkFunSoilMoistureSensorI2C tmpSensor;
64
+ SparkFunSoilMoistureSensor tmpSensor;
65
65
if (tmpSensor.begin (ALTERNATE_I2C_ADDRESS) == true )
66
66
{
67
67
Serial.println (" Sensor found at the alternate address. Changing the address back to the default." );
68
- tmpSensor.setI2CAddress (SFE_SOIL_MOISTURE_DEFAULT_I2C_ADDRESS );
68
+ tmpSensor.setI2CAddress (SF_SOIL_MOISTURE_DEFAULT_I2C_ADDRESS );
69
69
delay (3000 );
70
70
if (mySoilSensor.begin () == false )
71
71
{
72
- Serial.println (
73
- " Error: Soil Moisture Sensor not detected at default I2C address. Verify the sensor is connected. Stopping." );
72
+ Serial.println (" Error: Soil Moisture Sensor not detected at default I2C address. Verify the sensor is "
73
+ " connected. Stopping." );
74
74
while (1 )
75
75
;
76
76
}
77
77
}
78
78
else
79
79
{
80
- Serial.println (
81
- " Soil Moisture Sensor not detected at default or alternative I2C address. Verify the sensor is connected. Stopping." );
82
- while (1 )
83
- ;
80
+ Serial.println (" Soil Moisture Sensor not detected at default or alternative I2C address. Verify the sensor "
81
+ " is connected. Stopping." );
82
+ while (1 )
83
+ ;
84
84
}
85
85
}
86
86
Serial.println (" Soil Moisture Sensor found!" );
@@ -98,13 +98,13 @@ void setup()
98
98
// Now the percent moisture
99
99
Serial.print (mySoilSensor.readMoisturePercentage ());
100
100
Serial.println (" % wet" );
101
-
101
+
102
102
Serial.println ();
103
103
104
104
Serial.println (" Changing the I2C address of the sensor to: 0x" + String (ALTERNATE_I2C_ADDRESS, HEX));
105
105
106
106
// Change the I2C address
107
- if (mySoilSensor.setI2CAddress (ALTERNATE_I2C_ADDRESS) != kSTkErrOk )
107
+ if (mySoilSensor.setI2CAddress (ALTERNATE_I2C_ADDRESS) != ksfTkErrOk )
108
108
{
109
109
Serial.println (" ERROR: Unable to change the I2C address. Stopping." );
110
110
while (1 )
@@ -116,17 +116,17 @@ void setup()
116
116
Serial.println ();
117
117
118
118
// try the sensor at the new address
119
- SparkFunSoilMoistureSensorI2C mySoilSensorNewAddress; // Create an instance of the sensor class at new address
119
+ SparkFunSoilMoistureSensor mySoilSensorNewAddress; // Create an instance of the sensor class at new address
120
120
121
121
if (mySoilSensorNewAddress.begin (ALTERNATE_I2C_ADDRESS) == false )
122
122
{
123
- Serial.println (
124
- " Error: Soil Moisture Sensor not detected at new I2C address. Stopping." );
123
+ Serial.println (" Error: Soil Moisture Sensor not detected at new I2C address. Stopping." );
125
124
while (1 )
126
125
;
127
126
}
128
127
Serial.println (" Soil Moisture Sensor found at the new address!" );
129
- Serial.println ();;
128
+ Serial.println ();
129
+ ;
130
130
131
131
// write out the current value
132
132
Serial.print (" Sensor Address: 0x" );
@@ -140,12 +140,11 @@ void setup()
140
140
// Now the percent moisture
141
141
Serial.print (mySoilSensorNewAddress.readMoisturePercentage ());
142
142
Serial.println (" % wet" );
143
-
144
143
145
- Serial.println (" Changing the I2C address of the sensor to: 0x" + String (SFE_SOIL_MOISTURE_DEFAULT_I2C_ADDRESS , HEX));
144
+ Serial.println (" Changing the I2C address of the sensor to: 0x" + String (SF_SOIL_MOISTURE_DEFAULT_I2C_ADDRESS , HEX));
146
145
147
146
// Change the I2C address
148
- if (mySoilSensorNewAddress.setI2CAddress (SFE_SOIL_MOISTURE_DEFAULT_I2C_ADDRESS ) != kSTkErrOk )
147
+ if (mySoilSensorNewAddress.setI2CAddress (SF_SOIL_MOISTURE_DEFAULT_I2C_ADDRESS ) != ksfTkErrOk )
149
148
{
150
149
Serial.println (" ERROR: Unable to change the I2C address. Stopping." );
151
150
while (1 )
@@ -157,8 +156,7 @@ void setup()
157
156
158
157
Serial.println ();
159
158
Serial.println (" Address changing complete. Entering loop..." );
160
- Serial.println ();
161
-
159
+ Serial.println ();
162
160
}
163
161
164
162
// ----------------------------------------------------------------------------------------
@@ -175,6 +173,6 @@ void loop()
175
173
Serial.print (mySoilSensor.readMoisturePercentage ());
176
174
Serial.println (" % wet" );
177
175
178
- // loop delay
176
+ // loop delay
179
177
delay (5000 );
180
178
}
0 commit comments