RCWL-1601 / HC-SR04 Ultrasound sensor...

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
JohnBottle
 
Posts: 23
Joined: Sat Apr 09, 2022 2:32 pm

RCWL-1601 / HC-SR04 Ultrasound sensor...

Post by JohnBottle »

Hi all,

I purchased a RCWL-1601 - which is supposed to be a 3.3v version of the HC-SR04 and compatible with the HC-SR04 library - which I am trying to use with my Itsy M0.

I've wired it up as follows:
wiredup.png
wiredup.png (661.87 KiB) Viewed 205 times
(as no resistors are needed to change voltage down from 5.5?)

And my code:

Code: Select all

import time
import board
import adafruit_hcsr04
sonar = adafruit_hcsr04.HCSR04(trigger_pin=board.RX, echo_pin=board.TX)

while True:
    try:
        print((sonar.distance,))
    except RuntimeError:
        print("Retrying!")
    time.sleep(0.1)
This produces the following in the serial:

Code: Select all

(17.1204,)
(0.0,)
(0.0,)
(0.0,)
(0.0,)
(17.1204,)
(17.1204,)
(17.1204,)
Which is just random - no relation to distance of anything in front of the sensor. It's always just jumping between 0.0 and 17.xx

What am I doing wrong? Thanks for any help.

User avatar
JohnBottle
 
Posts: 23
Joined: Sat Apr 09, 2022 2:32 pm

Re: RCWL-1601 / HC-SR04 Ultrasound sensor...

Post by JohnBottle »

Ok - I've tried this with an actual HC-SR04 now - using resistors to correct the voltage. I have tired following the guide found here:

https://learn.adafruit.com/ultrasonic-s ... cuitpython

With this set up:
adafruit_products_HC-SR04_FeatherM4_bb.png
adafruit_products_HC-SR04_FeatherM4_bb.png (217.95 KiB) Viewed 173 times
(I am using pins A1 and A2 as itsybitsy does not have a pin 6?)

I get the same results -

Code: Select all

(17.1204,)
(0.0,)
(0.0,)
(0.0,)
(0.0,)
(17.1204,)
(17.1204,)
(17.1204,)
The lowest result shown is 16.xx

If I put my had within 30cm of sensor - it just shows 0.00

The sensor claims to be able to do from 2cm up to over a meter.

Any help would be great.

As I am getting the same results with both the RCWL-1601 and the HC-SR04 - it must be something I have done wrong somewhere?

Thanks again.

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: RCWL-1601 / HC-SR04 Ultrasound sensor...

Post by adafruit_support_bill »

Please post a photo of your actual setup - showing all the soldering and connections.

User avatar
JohnBottle
 
Posts: 23
Joined: Sat Apr 09, 2022 2:32 pm

Re: RCWL-1601 / HC-SR04 Ultrasound sensor...

Post by JohnBottle »

OK - I have found the problem! It's not my fault either :)

Your adafruit_hcsr04.mpy does not work with CircuitPython 7.x -- To get the sensor to work, I had to install:

adafruit-circuitpython-gemma_m0-en_US-6.3.0.uf2

and then use:

adafruit-circuitpython-bundle-6.x-mpy-20211213.zip

After downgrading the Gemma to these version - the sensor now works perfect.

I tried multiple versions of 7.X - none worked, it was only when I downgraded back to 6.3.0 - that the sensor started working.
Last edited by JohnBottle on Sun May 08, 2022 6:25 am, edited 2 times in total.

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: RCWL-1601 / HC-SR04 Ultrasound sensor...

Post by adafruit_support_bill »

Thanks for the heads-up. I will let the CircuitPython team know.

User avatar
JohnBottle
 
Posts: 23
Joined: Sat Apr 09, 2022 2:32 pm

Re: RCWL-1601 / HC-SR04 Ultrasound sensor...

Post by JohnBottle »

adafruit_support_bill wrote:Thanks for the heads-up. I will let the CircuitPython team know.
That's great! Do they ever fix issues like this? Or should I continue working with 6.x project for now?

And... I've confirmed same problem with the itsybitsy m0 - the HC-SR04 does not work with 7.x version, nor does the 3.3v compatible RCWL-1601.
If i downgrade to the adafruit-circuitpython-itsybitsy_m0_express-en_US-6.3.0.uf2, and use the 6.x version of adafruit_hcsr04.mpy -- both sensors work fine.

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: RCWL-1601 / HC-SR04 Ultrasound sensor...

Post by adafruit_support_bill »

It'll likely get fixed. But when will depend on what else is in the queue. If it is working for you in 6.x, I'd continue with that for now.

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

Return to “Itsy Bitsy Boards”