Skip to content

Commit c5a7ac5

Browse files
committed
needed to update to tk v1.0 - damn
1 parent 94b2c52 commit c5a7ac5

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

examples/Example_04_ChangeI2CAddress/Example_04_ChangeI2CAddress.ino

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
SparkFunSoilMoistureSensor mySoilSensor; // Create an instance of the sensor class
2626

2727
// 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
2929

3030
// Some Dev boards have their QWIIC connector on Wire or Wire1
3131
// This #ifdef will help this sketch work across more products
@@ -61,26 +61,26 @@ void setup()
6161
if (mySoilSensor.begin() == false)
6262
{
6363
// Did the sensor get left at the alt address? Try the alt address
64-
SparkFunSoilMoistureSensorI2C tmpSensor;
64+
SparkFunSoilMoistureSensor tmpSensor;
6565
if (tmpSensor.begin(ALTERNATE_I2C_ADDRESS) == true)
6666
{
6767
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);
6969
delay(3000);
7070
if (mySoilSensor.begin() == false)
7171
{
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.");
7474
while (1)
7575
;
7676
}
7777
}
7878
else
7979
{
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+
;
8484
}
8585
}
8686
Serial.println("Soil Moisture Sensor found!");
@@ -98,13 +98,13 @@ void setup()
9898
// Now the percent moisture
9999
Serial.print(mySoilSensor.readMoisturePercentage());
100100
Serial.println("% wet");
101-
101+
102102
Serial.println();
103103

104104
Serial.println("Changing the I2C address of the sensor to: 0x" + String(ALTERNATE_I2C_ADDRESS, HEX));
105105

106106
// Change the I2C address
107-
if (mySoilSensor.setI2CAddress(ALTERNATE_I2C_ADDRESS) != kSTkErrOk)
107+
if (mySoilSensor.setI2CAddress(ALTERNATE_I2C_ADDRESS) != ksfTkErrOk)
108108
{
109109
Serial.println("ERROR: Unable to change the I2C address. Stopping.");
110110
while (1)
@@ -116,17 +116,17 @@ void setup()
116116
Serial.println();
117117

118118
// 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
120120

121121
if (mySoilSensorNewAddress.begin(ALTERNATE_I2C_ADDRESS) == false)
122122
{
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.");
125124
while (1)
126125
;
127126
}
128127
Serial.println("Soil Moisture Sensor found at the new address!");
129-
Serial.println();;
128+
Serial.println();
129+
;
130130

131131
// write out the current value
132132
Serial.print("Sensor Address: 0x");
@@ -140,12 +140,11 @@ void setup()
140140
// Now the percent moisture
141141
Serial.print(mySoilSensorNewAddress.readMoisturePercentage());
142142
Serial.println("% wet");
143-
144143

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));
146145

147146
// 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)
149148
{
150149
Serial.println("ERROR: Unable to change the I2C address. Stopping.");
151150
while (1)
@@ -157,8 +156,7 @@ void setup()
157156

158157
Serial.println();
159158
Serial.println("Address changing complete. Entering loop...");
160-
Serial.println();
161-
159+
Serial.println();
162160
}
163161

164162
//----------------------------------------------------------------------------------------
@@ -175,6 +173,6 @@ void loop()
175173
Serial.print(mySoilSensor.readMoisturePercentage());
176174
Serial.println("% wet");
177175

178-
// loop delay
176+
// loop delay
179177
delay(5000);
180178
}

0 commit comments

Comments
 (0)