Skip to content

Commit 3f232d2

Browse files
authored
Merge pull request #1 from sparkfun/v0.1.0
V0.1.0
2 parents f47d4c2 + adf8fcf commit 3f232d2

File tree

4 files changed

+23
-17
lines changed

4 files changed

+23
-17
lines changed

examples/Example1-GetReadings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def runExample():
4949
print("\nSparkFun Qwiic Soil Moisture Sensor Example 1\n")
5050
mySoilSensor = qwiic_soil_moisture_sensor.QwiicSoilMoistureSensor()
5151

52-
if mySoilSensor.is_connected == False:
52+
if mySoilSensor.is_connected() == False:
5353
print("The Qwiic Soil Moisture Sensor device isn't connected to the system. Please check your connection", \
5454
file=sys.stderr)
5555
return

examples/Example2-Change_I2C_Address.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,26 +44,32 @@
4444
import time
4545
import sys
4646

47+
# If you've already changed the I2C address, change this to the current address!
48+
currentAddress = qwiic_soil_moisture_sensor.SOIL_MOISTURE_SENSOR_DEFAULT_ADDRESS
49+
4750
def runExample():
4851

4952
print("\nSparkFun Qwiic Soil Moisture Sensor Example 2 - Change I2C Address\n")
50-
mySoilSensor = qwiic_soil_moisture_sensor.QwiicSoilMoistureSensor()
53+
mySoilSensor = qwiic_soil_moisture_sensor.QwiicSoilMoistureSensor(currentAddress)
5154

52-
status = mySoilSensor.begin()
53-
if status == False:
54-
print ("\nStatus: ", status)
55+
if mySoilSensor.is_connected() == False:
56+
print("The Qwiic Soil Moisture Sensor device isn't connected to the system. Please check your connection", \
57+
file=sys.stderr)
58+
return
59+
60+
mySoilSensor.begin()
5561

56-
print("\nReady!")
57-
print("\nEnter a new I2C address for the Qwiic Soil Moisture Sensor to use.")
58-
print("\nDon't use the 0x prefix. For instance if you wanted to")
59-
print("\nchange the address to 0x5B, you would type 5B and hit enter.")
60-
62+
print("Ready!")
63+
print("Enter a new I2C address for the Qwiic Soil Moisture Sensor to use.")
64+
print("Any address from 0x08 to 0x3F works.")
65+
print("Don't use the 0x prefix. For instance if you wanted to")
66+
print("change the address to 0x3B, you would type 3B and hit enter.")
6167

6268
newAddress = input("\nNew Address: ")
6369
newAddress = int(newAddress, 16)
6470

6571
# Check if the user entered a valid address
66-
if newAddress > 0x08 and newAddress < 0x77:
72+
if newAddress >= 0x08 and newAddress <= 0x3F:
6773
print("\nCharacters received and new address valid!")
6874
print("\nAttempting to set Soil Moisture Sensor address...")
6975

qwiic_soil_moisture_sensor.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@
3636
# Some devices have multiple available addresses - this is a list of these addresses.
3737
# NOTE: The first address in this list is considered the default I2C address for the
3838
# device.
39-
_FULL_ADDRESS_LIST = list(range(0x08,0x77+1)) # Full I2C Address List (excluding resrved addresses)
40-
_FULL_ADDRESS_LIST.remove(SOIL_MOISTURE_SENSOR_DEFAULT_ADDRESS >> 1) # Remove Default Address of Soil Moisture Sensor from list
41-
_AVAILABLE_I2C_ADDRESS = [SOIL_MOISTURE_SENSOR_DEFAULT_ADDRESS >> 1] # Initialize with Default Address of Soil Moisture Sensor
39+
_FULL_ADDRESS_LIST = list(range(0x08,0x40)) # Full I2C Address List (excluding resrved addresses)
40+
_FULL_ADDRESS_LIST.remove(SOIL_MOISTURE_SENSOR_DEFAULT_ADDRESS) # Remove Default Address of Soil Moisture Sensor from list
41+
_AVAILABLE_I2C_ADDRESS = [SOIL_MOISTURE_SENSOR_DEFAULT_ADDRESS] # Initialize with Default Address of Soil Moisture Sensor
4242
_AVAILABLE_I2C_ADDRESS.extend(_FULL_ADDRESS_LIST) # Add Full Range of I2C Addresses
4343

4444

@@ -173,8 +173,8 @@ def change_address(self, newAddress):
173173
:param newAddress: the new address to set the Soil Moisture Sensor reader to
174174
:rtype: bool
175175
"""
176-
if newAddress < 0x07 or newAddress > 0x78:
177-
return false
176+
if newAddress < 0x08 or newAddress > 0x3F:
177+
return False
178178

179179
self._i2c.writeByte(self.address, COMMAND_CHANGE_ADDRESS, newAddress)
180180

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
# Versions should comply with PEP440. For a discussion on single-sourcing
5252
# the version across setup.py and the project code, see
5353
# http://packaging.python.org/en/latest/tutorial.html#version
54-
version='0.0.2',
54+
version='0.1.0',
5555

5656
description='SparkFun Electronics Qwiic Soil Moisture Sensor',
5757
long_description=long_description,

0 commit comments

Comments
 (0)