0

Feather RP2040 + HC-SR04 Ultrasonic Sonar Distance Sensor
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Feather RP2040 + HC-SR04 Ultrasonic Sonar Distance Sensor

by imhavoc on Sat Mar 27, 2021 11:26 pm

using the sample code from https://learn.adafruit.com/ultrasonic-s ... ce-sensors, I get the following results:
Code: Select all | TOGGLE FULL SIZE
code.py output:
0.272
0.272
0.272
0.272
0.272
0.272
0.272
0.272
0.272
0.272
0.272
0.272
Traceback (most recent call last):
  File "code.py", line 11, in <module>
  File "code.py", line 9, in <module>
  File "adafruit_hcsr04.py", line 144, in distance
  File "adafruit_hcsr04.py", line 159, in _dist_two_wire
AttributeError: 'HCSR04' object has no attribute '_timeout'

I loaded the code on a Isty Bitsy M0, and it works great.

I moved back to the Feather, and moved the echo pin, and got the exact same result.

imhavoc
 
Posts: 42
Joined: Thu Oct 05, 2017 10:32 pm

Re: Feather RP2040 + HC-SR04 Ultrasonic Sonar Distance Senso

by imhavoc on Mon Mar 29, 2021 11:40 am

Hooked up a neopixel ring, no problems. Looks like something in the HCSR04 library is not playing nice with the RP2040.

imhavoc
 
Posts: 42
Joined: Thu Oct 05, 2017 10:32 pm

Re: Feather RP2040 + HC-SR04 Ultrasonic Sonar Distance Senso

by imhavoc on Mon Mar 29, 2021 11:05 pm

Downloaded the latest libraries: adafruit-circuitpython-bundle-6.x-mpy-20210329

Still failing. It takes longer to fail, but it still fails.

imhavoc
 
Posts: 42
Joined: Thu Oct 05, 2017 10:32 pm

Re: Feather RP2040 + HC-SR04 Ultrasonic Sonar Distance Senso

by adafruit_support_carter on Tue Mar 30, 2021 12:40 pm

Which Feather RP2040 pins are you using for trigger and echo?

adafruit_support_carter
 
Posts: 21359
Joined: Tue Nov 29, 2016 2:45 pm

Re: Feather RP2040 + HC-SR04 Ultrasonic Sonar Distance Senso

by imhavoc on Tue Mar 30, 2021 12:58 pm

adafruit_support_carter wrote:Which Feather RP2040 pins are you using for trigger and echo?

Pin D5 for trigger,
Pin D6 for echo.

(It occurred to me last night that the Pin 5 on the Itsy Bisy is 5V, which may explain why it's working and the Feather is not. (?))

imhavoc
 
Posts: 42
Joined: Thu Oct 05, 2017 10:32 pm

Re: Feather RP2040 + HC-SR04 Ultrasonic Sonar Distance Senso

by adafruit_support_carter on Tue Mar 30, 2021 1:16 pm

While the Trig signal can be 3V or 5V, the 'return' Echo signal is 5V logic. For that reason, we include two 10K resistors, use these as a divider to convert the 5V logic level to a safe 2.5V that you can ready with your 3V device.


Are you setting up the voltage divider?

adafruit_support_carter
 
Posts: 21359
Joined: Tue Nov 29, 2016 2:45 pm

Re: Feather RP2040 + HC-SR04 Ultrasonic Sonar Distance Senso

by imhavoc on Tue Mar 30, 2021 2:04 pm

adafruit_support_carter wrote:Are you setting up the voltage divider?

Yes.

imhavoc
 
Posts: 42
Joined: Thu Oct 05, 2017 10:32 pm

Re: Feather RP2040 + HC-SR04 Ultrasonic Sonar Distance Senso

by adafruit_support_carter on Tue Mar 30, 2021 2:26 pm

Hmm. I think I'm seeing the same thing. It might be RP2040 related. There' still some issues being worked out for it. Want to open a new issue here?
https://github.com/adafruit/Adafruit_Ci ... R04/issues

adafruit_support_carter
 
Posts: 21359
Joined: Tue Nov 29, 2016 2:45 pm

Re: Feather RP2040 + HC-SR04 Ultrasonic Sonar Distance Senso

by imhavoc on Tue Mar 30, 2021 2:57 pm

here is a diagram:
Screenshot 2021-03-30 125412.png
Screenshot 2021-03-30 125412.png (155.51 KiB) Viewed 75 times

imhavoc
 
Posts: 42
Joined: Thu Oct 05, 2017 10:32 pm

Re: Feather RP2040 + HC-SR04 Ultrasonic Sonar Distance Senso

by stocksp on Fri Aug 20, 2021 3:44 pm

I'm have exactly the same results.

New Feather hardware (running the sample app with a voltage divider on the Echo) ... I get a dozen good reads and then the crash.

"AttributeError: 'HCSR04' object has no attribute '_timeout'"

Which doesn't make any sense (to me!) as the _timeout attribute does exist.
I moved the library source into my code and printed out the value on each loop (0.1)

Reading the discussion above I'm hearing this is a problem with the Feather and NOT the RP2040?

Did I understand correctly? as I see so many examples of the HCSR04 running on the 'naked' Pico.

Don't mind moving off the Feather till this is resolved ... IF this is a Feather problem and not also a RP2040 or CircuitPython issue...

thanks for any guidance!

P:)

stocksp
 
Posts: 2
Joined: Fri Aug 20, 2021 3:14 pm

Re: Feather RP2040 + HC-SR04 Ultrasonic Sonar Distance Senso

by stocksp on Mon Aug 23, 2021 12:51 am

I updated my CircuitPython from 6 to 7.0 alpha 6 and the Ultrasonic sensor works perfectly!!

oh happy days!

P:)

stocksp
 
Posts: 2
Joined: Fri Aug 20, 2021 3:14 pm

Re: Feather RP2040 + HC-SR04 Ultrasonic Sonar Distance Senso

by imhavoc on Thu Sep 23, 2021 10:15 am

stocksp wrote:I updated my CircuitPython from 6 to 7.0 alpha 6 and the Ultrasonic sensor works perfectly!!

oh happy days!

P:)

stocksp, good to know! Thanks for the info.

imhavoc
 
Posts: 42
Joined: Thu Oct 05, 2017 10:32 pm

Please be positive and constructive with your questions and comments.