Seesaw Soil Sensor on Pi Pico "try_Lock' error
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- davidtara
- Posts: 9
- Joined: Mon Jan 28, 2019 12:34 pm
Seesaw Soil Sensor on Pi Pico "try_Lock' error
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.
- mikeysklar
- Posts: 13824
- Joined: Mon Aug 01, 2016 8:10 pm
Re: Seesaw Soil Sensor on Pi Pico "try_Lock' error
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.
I have seen this come down to STEMMA cables that are not full pressed or third party not constructed as well.
- davidtara
- Posts: 9
- Joined: Mon Jan 28, 2019 12:34 pm
Re: Seesaw Soil Sensor on Pi Pico "try_Lock' error
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 (124.6 KiB) Viewed 491 times
- mikeysklar
- Posts: 13824
- Joined: Mon Aug 01, 2016 8:10 pm
Re: Seesaw Soil Sensor on Pi Pico "try_Lock' error
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.
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.
- adafruit2
- Posts: 22111
- Joined: Fri Mar 11, 2005 7:36 pm
Re: Seesaw Soil Sensor on Pi Pico "try_Lock' error
if you just want to get going, its best to use circuitpython on the pico instead of trying to use micropython+blinka
- MakerMelissa
- Posts: 375
- Joined: Wed Jun 05, 2013 2:10 am
Re: Seesaw Soil Sensor on Pi Pico "try_Lock' error
Hi,
I think to get it working, you need to be using busio.I2C() instead of machine.I2C(). It implements the lockable features.
Melissa
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: 375
- Joined: Wed Jun 05, 2013 2:10 am
Re: Seesaw Soil Sensor on Pi Pico "try_Lock' error
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
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
- davidtara
- Posts: 9
- Joined: Mon Jan 28, 2019 12:34 pm
Re: Seesaw Soil Sensor on Pi Pico "try_Lock' error
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
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
- MakerMelissa
- Posts: 375
- Joined: Wed Jun 05, 2013 2:10 am
Re: Seesaw Soil Sensor on Pi Pico "try_Lock' error
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.
Of course you'll want to change the GPIO pins the the ones you're using.
- davidtara
- Posts: 9
- Joined: Mon Jan 28, 2019 12:34 pm
Re: Seesaw Soil Sensor on Pi Pico "try_Lock' error
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.
I appreciate you sticking with me on this project.
David
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.
I appreciate you sticking with me on this project.
David
- mikeysklar
- Posts: 13824
- Joined: Mon Aug 01, 2016 8:10 pm
Re: Seesaw Soil Sensor on Pi Pico "try_Lock' error
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.
https://github.com/adafruit/Adafruit_Ci ... pletest.py
https://circuitpython.org/board/raspberry_pi_pico/
https://circuitpython.org/libraries
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://circuitpython.org/board/raspberry_pi_pico/
https://circuitpython.org/libraries
- davidtara
- Posts: 9
- Joined: Mon Jan 28, 2019 12:34 pm
Re: Seesaw Soil Sensor on Pi Pico "try_Lock' error
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. David
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. David
- mikeysklar
- Posts: 13824
- Joined: Mon Aug 01, 2016 8:10 pm
Re: Seesaw Soil Sensor on Pi Pico "try_Lock' error
Hi David,
Good progress. I think you only need a slight modification to the default code due to the RP2040 Pico.
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)
- davidtara
- Posts: 9
- Joined: Mon Jan 28, 2019 12:34 pm
Re: Seesaw Soil Sensor on Pi Pico "try_Lock' error
Mike,
That worked, just had to import busio
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
That worked, just had to import busio
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
- mikeysklar
- Posts: 13824
- Joined: Mon Aug 01, 2016 8:10 pm
Re: Seesaw Soil Sensor on Pi Pico "try_Lock' error
Well done! Good luck with the next step.
Please be positive and constructive with your questions and comments.