0

Seesaw Soil Sensor on Pi Pico "try_Lock' error
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Seesaw Soil Sensor on Pi Pico "try_Lock' error

by davidtara on Sun Sep 19, 2021 12:07 am

Screen Shot 2021-09-18 at 9.09.14 PM.png
Screen Shot 2021-09-18 at 9.09.14 PM.png (172.36 KiB) Viewed 389 times


Hi,
Need help getting the Pi Pico to read the Seesaw soil sensor. I ran an i2c scan and it returns the boards address of 0x36. However, the following Traceback error is bering returned:

Traceback (most recent call last):
File "<stdin>", line 9, in <module>
File "/lib/adafruit_seesaw/seesaw.py", line 141, in __init__
File "/lib/adafruit_bus_device/i2c_device.py", line 50, in __init__
File "/lib/adafruit_bus_device/i2c_device.py", line 152, in __probe_for_device
AttributeError: 'I2C' object has no attribute 'try_lock'

Not sure what this means or how to resolve it.
Help is appreciated.

davidtara
 
Posts: 8
Joined: Mon Jan 28, 2019 12:34 pm

Re: Seesaw Soil Sensor on Pi Pico "try_Lock' error

by mikeysklar on Sun Sep 19, 2021 5:44 pm

Can you take a photo of your wiring between the Pico and the Soil Sensor?

I have seen this come down to STEMMA cables that are not full pressed or third party not constructed as well.

mikeysklar
 
Posts: 5767
Joined: Mon Aug 01, 2016 8:10 pm

Re: Seesaw Soil Sensor on Pi Pico "try_Lock' error

by davidtara on Sun Sep 19, 2021 8:20 pm

image0.jpeg
image0.jpeg (128.01 KiB) Viewed 381 times



Two photos are attached, one of the front and the other of the back of the set up.

As you will see, the Pico and a motor controller are soldered to a board and all wiring connections are made on the back (trying to keep the front clean). Continuity tests are good all the way from the physical connections on the sensor back to the pins on the Pico. Just to make certain the sensor is ok, I tested it on my Pi 4 and it reads it just fine. I double checked the i2c again, and it still comes back with the sensor address.
Attachments
image1.jpeg
image1.jpeg (124.6 KiB) Viewed 381 times

davidtara
 
Posts: 8
Joined: Mon Jan 28, 2019 12:34 pm

Re: Seesaw Soil Sensor on Pi Pico "try_Lock' error

by mikeysklar on Mon Sep 20, 2021 12:05 pm

Okay, a few things stand out here.

1) I can't verify your soldering the resolution combined with the distance from the board makes it hard to make out.

2) that is a really long i2c cable. Over 6" has the potential for noise causing communication issues.

3) is another i2c device involved (red board)?

Can you do a simple setup with only the Pico connected to the soil sensor over short leads? We need to get to a known good starting point with less stuff going on.

mikeysklar
 
Posts: 5767
Joined: Mon Aug 01, 2016 8:10 pm

Re: Seesaw Soil Sensor on Pi Pico "try_Lock' error

by adafruit2 on Tue Sep 21, 2021 11:44 am

if you just want to get going, its best to use circuitpython on the pico instead of trying to use micropython+blinka

adafruit2
Site Admin
 
Posts: 20261
Joined: Fri Mar 11, 2005 7:36 pm

Re: Seesaw Soil Sensor on Pi Pico "try_Lock' error

by MakerMelissa on Tue Sep 21, 2021 11:51 am

Hi,

I think to get it working, you need to be using busio.I2C() instead of machine.I2C(). It implements the lockable features.

Melissa

MakerMelissa
 
Posts: 263
Joined: Wed Jun 05, 2013 2:10 am

Re: Seesaw Soil Sensor on Pi Pico "try_Lock' error

by MakerMelissa on Tue Sep 21, 2021 11:57 am

Hi,

As a little background, I'm the person who added the Pico implementation to Blinka. The busio.I2C() implementation is really just a wrapper for the MicroPython I2C() that adds features such as try_lock() and unlock() so that it works with the CircuitPython libraries.

Melissa

MakerMelissa
 
Posts: 263
Joined: Wed Jun 05, 2013 2:10 am

Re: Seesaw Soil Sensor on Pi Pico "try_Lock' error

by davidtara on Fri Sep 24, 2021 12:04 am

Hi Mike, The cable in the pic is about 2' long, 22AWG stranded tinned copper, and it works when connected to a Pi 4. I ordered a new cable from adafruit to try on the Pico, should arrive soon. The second board is not set up for I2C, it is a motor controller connected to a PWM pin.

Hi Melissa, I tried using busio.I2C(), but it didn't work. Would this require rebooting the board and setting it up for CircuitPython? I have been using MicroPython on Thonny to connect to the Pico.

Appreciate all of the input.
Thank you.
David

davidtara
 
Posts: 8
Joined: Mon Jan 28, 2019 12:34 pm

Re: Seesaw Soil Sensor on Pi Pico "try_Lock' error

by MakerMelissa on Fri Sep 24, 2021 11:02 am

No it shouldn't require CircuitPython for that. I just remembered I wrote a guide on this with an I2C example. See here: https://learn.adafruit.com/circuitpytho ... ry-example

Of course you'll want to change the GPIO pins the the ones you're using.

MakerMelissa
 
Posts: 263
Joined: Wed Jun 05, 2013 2:10 am

Re: Seesaw Soil Sensor on Pi Pico "try_Lock' error

by davidtara on Wed Sep 29, 2021 1:37 am

Hi MakerMelissa,

Good news, now that a shorter cable is being used (Thanks for the suggestion, Mike) the i2c scan finds the sensor provided the machine library is used. However, using busio results in an error.

It should also be noted that I changed the board and moved to a different set of pins, just in case something was wrong with that board. The results are the same, the scan works with the machine library but not the busio. Please see the pics for the example code with output.

Screen Shot 2021-09-28 at 10.39.30 PM.png
Screen Shot 2021-09-28 at 10.39.30 PM.png (161.51 KiB) Viewed 333 times



Screen Shot 2021-09-28 at 10.31.22 PM.png
Screen Shot 2021-09-28 at 10.31.22 PM.png (248.93 KiB) Viewed 333 times




I appreciate you sticking with me on this project.

David

davidtara
 
Posts: 8
Joined: Mon Jan 28, 2019 12:34 pm

Re: Seesaw Soil Sensor on Pi Pico "try_Lock' error

by mikeysklar on Wed Sep 29, 2021 4:00 pm

Hi David,

I am glad to hear the shorter cable worked.

You should run our current CircuitPython Release 7.x / 7.x libs and our example seesaw_soil_simpletest.py to get started.

Code: Select all | TOGGLE FULL SIZE
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT

import time

import board

from adafruit_seesaw.seesaw import Seesaw

i2c_bus = board.I2C()

ss = Seesaw(i2c_bus, addr=0x36)

while True:
    # read moisture level through capacitive touch pad
    touch = ss.moisture_read()

    # read temperature from the temperature sensor
    temp = ss.get_temp()

    print("temp: " + str(temp) + "  moisture: " + str(touch))
    time.sleep(1)


https://github.com/adafruit/Adafruit_Ci ... pletest.py

https://circuitpython.org/board/raspberry_pi_pico/
https://circuitpython.org/libraries

mikeysklar
 
Posts: 5767
Joined: Mon Aug 01, 2016 8:10 pm

Re: Seesaw Soil Sensor on Pi Pico "try_Lock' error

by davidtara on Thu Sep 30, 2021 11:08 pm

Hi Mike,
I rebooted the Pico, loaded the latest CircuitPython, downloaded the latest library, used the code you provided, and the following error occurs.

Please see the attached photo.
Screen Shot 2021-09-30 at 8.02.52 PM.png
Screen Shot 2021-09-30 at 8.02.52 PM.png (257.48 KiB) Viewed 27 times

David

davidtara
 
Posts: 8
Joined: Mon Jan 28, 2019 12:34 pm

Re: Seesaw Soil Sensor on Pi Pico "try_Lock' error

by mikeysklar on Fri Oct 01, 2021 12:46 pm

Hi David,

Good progress. I think you only need a slight modification to the default code due to the RP2040 Pico.

Code: Select all | TOGGLE FULL SIZE
i2c_bus = busio.I2C(scl=board.GP1, sda=board.GP0)

mikeysklar
 
Posts: 5767
Joined: Mon Aug 01, 2016 8:10 pm

Re: Seesaw Soil Sensor on Pi Pico "try_Lock' error

by davidtara on Fri Oct 01, 2021 5:25 pm

Mike,
That worked, just had to import busio

Screen Shot 2021-10-01 at 2.17.46 PM.png
Screen Shot 2021-10-01 at 2.17.46 PM.png (348.33 KiB) Viewed 18 times


Now on to the next part of the project, controlling the pump. Ultimately, the goal is to maintain proper moisture content for muliple plants. Hoping the I2C Multiplexer is compatible with this controller.

Thank you so much for the support, you guys are awesome!
David

davidtara
 
Posts: 8
Joined: Mon Jan 28, 2019 12:34 pm

Re: Seesaw Soil Sensor on Pi Pico "try_Lock' error

by mikeysklar on Sun Oct 03, 2021 1:57 pm

Well done! Good luck with the next step.

mikeysklar
 
Posts: 5767
Joined: Mon Aug 01, 2016 8:10 pm

Please be positive and constructive with your questions and comments.