Skip to content

Add retries for moisture reading #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 22, 2019
Merged

Conversation

caternuson
Copy link
Contributor

Test setup:
rpi_soil_test

Test script:

import time
import board, busio
from adafruit_seesaw.seesaw import Seesaw

i2c = busio.I2C(board.SCL, board.SDA)

ss = Seesaw(i2c, addr=0x36)

start_time = time.time()
count = 0

print("Reading...")

while True:
    count += 1
    if ss.moisture_read() > 4095:
        break
    time.sleep(0.1)

print("DONE")
print("count = {}  time = {}".format(count, time.time()-start_time))

BEFORE ☹️

pi@raspberrypi:~/soil_sensor $ python3 soil_test.py 
Reading...
DONE
count = 223  time = 24.15417194366455
pi@raspberrypi:~/soil_sensor $ python3 soil_test.py 
Reading...
DONE
count = 15  time = 1.5329132080078125
pi@raspberrypi:~/soil_sensor $ python3 soil_test.py 
Reading...
DONE
count = 283  time = 30.68214201927185
pi@raspberrypi:~/soil_sensor $ 

AFTER 😁
(ran for ~15 minutes before <CTRL><C>ing)

pi@raspberrypi:~/soil_sensor $ python3 soil_test.py 
Reading...

Basic reading still works:

pi@raspberrypi:~/soil_sensor $ python3
Python 3.5.3 (default, Sep 27 2018, 17:25:39) 
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import board, busio
>>> from adafruit_seesaw.seesaw import Seesaw
>>> i2c = busio.I2C(board.SCL, board.SDA)
>>> ss = Seesaw(i2c, addr=0x36)
>>> ss.moisture_read()
359
>>> ss.moisture_read()
1015
>>> ss.moisture_read()
362
>>> 

@ladyada ladyada merged commit a60e576 into adafruit:master Feb 22, 2019
@ladyada
Copy link
Member

ladyada commented Feb 22, 2019

thanks - please release a new minor semver!

@caternuson
Copy link
Contributor Author

thanks. done - released 1.3.0.

adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Feb 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants