File tree Expand file tree Collapse file tree 2 files changed +17
-10
lines changed Expand file tree Collapse file tree 2 files changed +17
-10
lines changed Original file line number Diff line number Diff line change 4646
4747def runExample ():
4848
49- print ("\n SparkFun qwiic soil moisture sensor Example 1\n " )
49+ print ("\n SparkFun Qwiic Soil Moisture Sensor Example 1\n " )
5050 mySoilSensor = qwiic_soil_moisture_sensor .QwiicSoilMoistureSensor ()
5151
52- if mySoilSensor .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
Original file line number Diff line number Diff line change 1414
1515import qwiic_i2c
1616
17-
1817#======================================================================
19- # Define the device name and I2C addresses. These are set in the class defintion
20- # as class variables, making them avilable without having to create a class instance.
18+ # Basic setup of I2C commands and available I2C Addresses
2119#
2220#
2321# The name of this device - note this is private
2422_DEFAULT_NAME = "Qwiic Soil Moisture Sensor"
2523
26- # Some devices have multiple available addresses - this is a list of these addresses.
27- # NOTE: The first address in this list is considered the default I2C address for the
28- # device.
29- _AVAILABLE_I2C_ADDRESS = [0x28 , 0x29 ] ###LAC FIX ADDRESSES
3024
31- # Register addresses
25+ # Command addresses
3226COMMAND_LED_OFF = 0x00
3327COMMAND_LED_ON = 0x01
3428COMMAND_CHANGE_ADDRESS = 0x03
3529COMMAND_GET_VALUE = 0x05
3630COMMAND_NOTHING_NEW = 0x99
3731SENSOR_STATUS = 0x3F
32+ SOIL_MOISTURE_SENSOR_DEFAULT_ADDRESS = 0x28
33+
34+ ###############################################################################
35+ ###############################################################################
36+ # Some devices have multiple available addresses - this is a list of these addresses.
37+ # NOTE: The first address in this list is considered the default I2C address for the
38+ # 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
42+ _AVAILABLE_I2C_ADDRESS .extend (_FULL_ADDRESS_LIST ) # Add Full Range of I2C Addresses
43+
44+
3845
3946class QwiicSoilMoistureSensor (object ):
4047 """
You can’t perform that action at this time.
0 commit comments