rcwl-1601 i2c issues

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
mjrussell77
 
Posts: 16
Joined: Thu May 26, 2022 12:16 am

rcwl-1601 i2c issues

Post by mjrussell77 »

I am trying to setup a rcwl-1601 to try to make a project to flag the correct distance to pull a car into a garage with the range finder and a neopixel strip to flag the correct location.

The rcwl-1601 seems to have the correct range that I am looking for.
This was going to be my first project using circuitpython with the qtpy esp32-s2 + neopixel driver bff and the rcwl-1601 on the stemma i2c connector.

First there is no library for the rcwl-1601, no problem, just use the base i2c for the board and simple write reads.

But for whatever reason the first read after the write to the sensor to take a measurement always errors out.
Initially I found that doing a scan in between worked, but it slows down the sensor loop which I want relatively fast.

Next I just put the read in a try statement to allow it to fail the first attempt, but I still get intermittent large return values or fails after 2 reads and I think that i2c timeout is impacting the loop time still.

Does anyone have experience with this sensor in circuit python and has some guidance on what could be the issue, I want to keep playing with circuitpython for this, but the setup seems limited. I am looking for the board library source code to see if the STEMMA_I2C function can adjust the i2c frequency, but scoping the interface with the 6k resistor pullups looks like the timing should be fine.

its close to working, but I need to understand the write/read issue to improve the loop time and I would like to improve the reliability of the measurement.

Thanks
matt

User avatar
danhalbert
 
Posts: 4613
Joined: Tue Aug 08, 2017 12:37 pm

Re: rcwl-1601 i2c issues

Post by danhalbert »

I have not used one, but the product description (https://www.adafruit.com/product/4007) says it is compatible with the HC-SR04. It's just that it's 3.3V compatible, and the HC is not. There is a library for the HC:
https://docs.circuitpython.org/projects ... en/latest/
https://github.com/adafruit/Adafruit_Ci ... hon_HCSR04
You can get it from the bundle or install with circup like our other libraries. So try the HC library.

User avatar
mjrussell77
 
Posts: 16
Joined: Thu May 26, 2022 12:16 am

Re: rcwl-1601 i2c issues

Post by mjrussell77 »

The HC-SR04 isnt i2c, it has a trigger and echo and you need to measure the time between to get the distance, The RCWL-1601 has an I2C interface, There doesnt seem to be documentation on if you can still use it in trig/echo mode, or how you would configure that.

User avatar
mjrussell77
 
Posts: 16
Joined: Thu May 26, 2022 12:16 am

Re: rcwl-1601 i2c issues

Post by mjrussell77 »

It looks like there is a version of the part that has the trig/echo, but that is not the one I have.

User avatar
mjrussell77
 
Posts: 16
Joined: Thu May 26, 2022 12:16 am

Re: rcwl-1601 i2c issues

Post by mjrussell77 »

Ok, if I watch the product video it talks about a jumper resistor, I suppose I could try moving it and using the hcsr04 library and see how that works...

User avatar
markwal
 
Posts: 12
Joined: Tue Apr 14, 2015 6:16 pm

Re: rcwl-1601 i2c issues

Post by markwal »

I realize this is more than a year later, but in case this could be helpful for other searchers like me. I think I've figured out how to make it work with a bit of experimentation.

I've created an Arduino library and an example here: https://github.com/markwal/RCWL_1601_i2c

It looks like the chip expects a stop (Wire.endTransmission) after reading before it lets go of the bus and will allow another read. I don't think that's a correct implementation of i2c, but it seems to work.

All of the other examples that I could find searching Google for i2c and this board turned up samples using the UART trigger and echo mode and if they used i2c at all it was to multiplex multiple boards still using UART.

Using the i2c mode lets the ranging chip on this board do the work of waiting for the echo and calculating the distance from the time to detect.

User avatar
LenStruttmann
 
Posts: 4
Joined: Sun Feb 05, 2023 8:57 pm

Re: rcwl-1601 i2c issues

Post by LenStruttmann »

What did you do to enable I2C mode? My RCWL-1601 modules are all stuck in Trig/Echo mode.

User avatar
LenStruttmann
 
Posts: 4
Joined: Sun Feb 05, 2023 8:57 pm

Re: rcwl-1601 i2c issues

Post by LenStruttmann »

Finally found an image that shows the value and placement of the resistor on the board to enable I2C.

https://www.flickr.com/photos/adafruit/52184390973/

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

Return to “Adafruit CircuitPython”