Seesaw Soil Sensor on Pi Pico "try_Lock' error

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
davidtara
 
Posts: 9
Joined: Mon Jan 28, 2019 12:34 pm

Seesaw Soil Sensor on Pi Pico "try_Lock' error

Post by davidtara »

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 500 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.

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

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

Post by mikeysklar »

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.

User avatar
davidtara
 
Posts: 9
Joined: Mon Jan 28, 2019 12:34 pm

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

Post by davidtara »

image0.jpeg
image0.jpeg (128.01 KiB) Viewed 492 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 492 times

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

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

Post by mikeysklar »

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.

User avatar
adafruit2
 
Posts: 22111
Joined: Fri Mar 11, 2005 7:36 pm

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

Post by adafruit2 »

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

User avatar
MakerMelissa
 
Posts: 375
Joined: Wed Jun 05, 2013 2:10 am

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

Post by MakerMelissa »

Hi,

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

Melissa

User avatar
MakerMelissa
 
Posts: 375
Joined: Wed Jun 05, 2013 2:10 am

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

Post by MakerMelissa »

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

User avatar
davidtara
 
Posts: 9
Joined: Mon Jan 28, 2019 12:34 pm

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

Post by davidtara »

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

User avatar
MakerMelissa
 
Posts: 375
Joined: Wed Jun 05, 2013 2:10 am

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

Post by MakerMelissa »

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.

User avatar
davidtara
 
Posts: 9
Joined: Mon Jan 28, 2019 12:34 pm

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

Post by davidtara »

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 444 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 444 times


I appreciate you sticking with me on this project.

David

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

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

Post by mikeysklar »

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

# 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

User avatar
davidtara
 
Posts: 9
Joined: Mon Jan 28, 2019 12:34 pm

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

Post by davidtara »

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 138 times
David

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

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

Post by mikeysklar »

Hi David,

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

Code: Select all

i2c_bus = busio.I2C(scl=board.GP1, sda=board.GP0)

User avatar
davidtara
 
Posts: 9
Joined: Mon Jan 28, 2019 12:34 pm

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

Post by davidtara »

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 129 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

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

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

Post by mikeysklar »

Well done! Good luck with the next step.

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”